Add logic for content file path generation

pull/1657/head
Kamran Ahmed 3 years ago
parent f986d9e170
commit 3d23ce8a07
  1. 1
      content/roadmaps.json
  2. 5
      content/roadmaps/100-frontend/meta.json
  3. 1
      package.json
  4. 2
      public/sitemap.xml
  5. 12
      scripts/content-skeleton.ts

@ -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

@ -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"
}

@ -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": {

@ -3,7 +3,7 @@
<url>
<loc>https://roadmap.sh/frontend</loc>
<changefreq>monthly</changefreq>
<lastmod>2021-11-27T18:10:50.401Z</lastmod>
<lastmod>2021-12-03T13:36:03.206Z</lastmod>
<priority>1.0</priority>
</url>
<url>

@ -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));

Loading…
Cancel
Save