From cdc362625aeb4d88dc7795ffe1a11461691db8e0 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 3 Dec 2021 14:36:31 +0100 Subject: [PATCH] Add logic for content file path generation --- content/roadmaps.json | 1 + content/roadmaps/100-frontend/meta.json | 5 +++-- package.json | 1 + public/sitemap.xml | 2 +- scripts/content-skeleton.ts | 12 +++++++++++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/content/roadmaps.json b/content/roadmaps.json index 28585a80c..05bd32670 100644 --- a/content/roadmaps.json +++ b/content/roadmaps.json @@ -39,6 +39,7 @@ "imagePath": "/roadmaps/frontend.png", "resourcesPath": "/roadmaps/100-frontend/resources.md", "pdfUrl": "https://kamranahmedse.gumroad.com/l/frontend-roadmap", + "contentPathsFilePath": "/100-frontend/content-paths.json", "id": "frontend", "metaPath": "/roadmaps/100-frontend/meta.json", "isUpcoming": false diff --git a/content/roadmaps/100-frontend/meta.json b/content/roadmaps/100-frontend/meta.json index 08a0470ab..5e684fb49 100644 --- a/content/roadmaps/100-frontend/meta.json +++ b/content/roadmaps/100-frontend/meta.json @@ -37,5 +37,6 @@ "featured": true, "imagePath": "/roadmaps/frontend.png", "resourcesPath": "./resources.md", - "pdfUrl": "https://kamranahmedse.gumroad.com/l/frontend-roadmap" -} + "pdfUrl": "https://kamranahmedse.gumroad.com/l/frontend-roadmap", + "contentPathsFilePath": "/100-frontend/content-paths.json" +} \ No newline at end of file diff --git a/package.json b/package.json index 18127011a..d433358a0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "meta:roadmaps": "node ./scripts/roadmaps-meta.js", "meta": "npm run meta:roadmaps && npm run meta:sitemap", "roadmap-content": "ts-node scripts/content-skeleton.ts", + "postroadmap-content": "npm run meta", "postinstall": "husky install" }, "dependencies": { diff --git a/public/sitemap.xml b/public/sitemap.xml index b66facb43..61153c2e3 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -3,7 +3,7 @@ https://roadmap.sh/frontend monthly - 2021-11-27T18:10:50.401Z + 2021-12-03T13:36:03.206Z 1.0 diff --git a/scripts/content-skeleton.ts b/scripts/content-skeleton.ts index d8743979e..f21844374 100644 --- a/scripts/content-skeleton.ts +++ b/scripts/content-skeleton.ts @@ -213,6 +213,16 @@ function createDirTree( return filePaths; } +// Create directories and get back the paths for created directories const filePaths = createDirTree(roadmapContentDirPath, dirTree, dirSortOrders); +const contentPathsFilePath = path.join(roadmapDirPath, 'content-paths.json'); -fs.writeFileSync(path.join(roadmapDirPath, 'content-paths.json'), JSON.stringify(filePaths, null, 2)); +fs.writeFileSync(contentPathsFilePath, JSON.stringify(filePaths, null, 2)); + +const roadmapMetaFilePath = path.join(roadmapDirPath, 'meta.json'); +const roadmapMeta = require(roadmapMetaFilePath); + +// Put the content paths file path in the roadmap meta +roadmapMeta.contentPathsFilePath = contentPathsFilePath.replace(CONTENT_DIR, ''); + +fs.writeFileSync(roadmapMetaFilePath, JSON.stringify(roadmapMeta, null, 2));