mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-13 21:02:08 +08:00
fix(tools): use dashed name for live version of challenge in editor (#59401)
This commit is contained in:
parent
2e452761a6
commit
aeeae20c97
@ -7,11 +7,11 @@ export const getStepContent = async (
|
||||
sup: string,
|
||||
block: string,
|
||||
step: string
|
||||
): Promise<{ name: string; fileData: string }> => {
|
||||
): Promise<{ name: string; dashedName: string; fileData: string }> => {
|
||||
const filePath = join(CHALLENGE_DIR, sup, block, step);
|
||||
|
||||
const fileData = await readFile(filePath, 'utf8');
|
||||
const name = matter(fileData).data.title as string;
|
||||
|
||||
return { name, fileData };
|
||||
const dashedName = matter(fileData).data.dashedName as string;
|
||||
return { name, dashedName, fileData };
|
||||
};
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
export interface ChallengeContent {
|
||||
name: string;
|
||||
fileData: string;
|
||||
dashedName: string;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ const Editor = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [items, setItems] = useState({
|
||||
name: '',
|
||||
dashedName: '',
|
||||
fileData: ''
|
||||
});
|
||||
const [stepContent, setStepContent] = useState('');
|
||||
@ -90,7 +91,9 @@ const Editor = () => {
|
||||
</p>
|
||||
<p>
|
||||
<Link
|
||||
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${superBlockNameMap[superblock || '']}/${block || ''}/${items.name.replace(/[\s]+/g, '-').toLowerCase() || ''}`}
|
||||
to={`${import.meta.env.CHALLENGE_EDITOR_LEARN_CLIENT_LOCATION}/learn/${superBlockNameMap[superblock || '']}/${block || ''}/${
|
||||
items.dashedName
|
||||
}`}
|
||||
target='_blank'
|
||||
>
|
||||
View Live Version of the Challenge in your running development
|
||||
|
||||
Loading…
Reference in New Issue
Block a user