mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-12 07:02:42 -04:00
feat(tools): add link to live version of challenge in challenge editor (#58027)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@ tasks:
|
||||
export API_LOCATION=$(gp url 3000)
|
||||
export CHALLENGE_EDITOR_API_LOCATION=$(gp url 3200)
|
||||
export CHALLENGE_EDITOR_CLIENT_LOCATION=$(gp url 3300)
|
||||
export CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION=$(gp url 8000)
|
||||
' >> ~/.bashrc;
|
||||
exit;
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
CHALLENGE_EDITOR_API_LOCATION=http://localhost:3200
|
||||
CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION=http://localhost:8000
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ChallengeContent } from '../../../interfaces/challenge-content';
|
||||
import SaveChallenge from '../buttons/save-challenge';
|
||||
import './editor.css';
|
||||
import { API_LOCATION } from '../../utils/handle-request';
|
||||
import { superBlockNameMap } from '../../utils/block-name-translator';
|
||||
|
||||
const Editor = () => {
|
||||
const [error, setError] = useState<Error | null>(null);
|
||||
@@ -87,6 +88,15 @@ const Editor = () => {
|
||||
<p>
|
||||
<Link to={`/${superblock || ''}/${block || ''}`}>Return to Block</Link>
|
||||
</p>
|
||||
<p>
|
||||
<Link
|
||||
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${superBlockNameMap[superblock || '']}/${block || ''}/${items.name.replace(/[\s]+/g, '-').toLowerCase() || ''}`}
|
||||
target='_blank'
|
||||
>
|
||||
View Live Version of the Challenge in your running development
|
||||
environment
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
export const superBlockNameMap: { [key: string]: string } = {
|
||||
'01-responsive-web-design': 'responsive-web-design',
|
||||
'02-javascript-algorithms-and-data-structures':
|
||||
'javascript-algorithms-and-data-structures',
|
||||
'03-front-end-development-libraries': 'front-end-development-libraries',
|
||||
'04-data-visualization': 'data-visualization',
|
||||
'05-back-end-development-and-apis': 'back-end-development-and-apis',
|
||||
'06-quality-assurance': 'quality-assurance',
|
||||
'07-scientific-computing-with-python': 'scientific-computing-with-python',
|
||||
'08-data-analysis-with-python': 'data-analysis-with-python',
|
||||
'09-information-security': 'information-security',
|
||||
'10-coding-interview-prep': 'coding-interview-prep',
|
||||
'11-machine-learning-with-python': 'machine-learning-with-python',
|
||||
'13-relational-databases': 'relational-databases',
|
||||
'14-responsive-web-design-22': '2022/responsive-web-design',
|
||||
'15-javascript-algorithms-and-data-structures-22':
|
||||
'javascript-algorithms-and-data-structures-v8',
|
||||
'16-the-odin-project': 'the-odin-project',
|
||||
'17-college-algebra-with-python': 'college-algebra-with-python',
|
||||
'18-project-euler': 'project-euler',
|
||||
'19-foundational-c-sharp-with-microsoft':
|
||||
'foundational-c-sharp-with-microsoft',
|
||||
'21-a2-english-for-developers': 'a2-english-for-developers',
|
||||
'22-rosetta-code': 'rosetta-code',
|
||||
'23-python-for-everybody': 'python-for-everybody',
|
||||
'24-b1-english-for-developers': 'b1-english-for-developers',
|
||||
'25-front-end-development': 'full-stack-developer'
|
||||
};
|
||||
@@ -1 +1,9 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user