Add logic for content file path generation

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

@ -39,7 +39,7 @@
"imagePath": "/roadmaps/frontend.png", "imagePath": "/roadmaps/frontend.png",
"resourcesPath": "/roadmaps/100-frontend/resources.md", "resourcesPath": "/roadmaps/100-frontend/resources.md",
"pdfUrl": "https://kamranahmedse.gumroad.com/l/frontend-roadmap", "pdfUrl": "https://kamranahmedse.gumroad.com/l/frontend-roadmap",
"contentPathsFilePath": "/100-frontend/content-paths.json", "contentPathsFilePath": "/roadmaps/100-frontend/content-paths.json",
"id": "frontend", "id": "frontend",
"metaPath": "/roadmaps/100-frontend/meta.json", "metaPath": "/roadmaps/100-frontend/meta.json",
"isUpcoming": false "isUpcoming": false

@ -38,5 +38,5 @@
"imagePath": "/roadmaps/frontend.png", "imagePath": "/roadmaps/frontend.png",
"resourcesPath": "./resources.md", "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" "contentPathsFilePath": "./content-paths.json"
} }

@ -3,7 +3,7 @@
<url> <url>
<loc>https://roadmap.sh/frontend</loc> <loc>https://roadmap.sh/frontend</loc>
<changefreq>monthly</changefreq> <changefreq>monthly</changefreq>
<lastmod>2021-12-03T13:36:03.206Z</lastmod> <lastmod>2021-12-03T14:00:37.506Z</lastmod>
<priority>1.0</priority> <priority>1.0</priority>
</url> </url>
<url> <url>

@ -223,6 +223,6 @@ const roadmapMetaFilePath = path.join(roadmapDirPath, 'meta.json');
const roadmapMeta = require(roadmapMetaFilePath); const roadmapMeta = require(roadmapMetaFilePath);
// Put the content paths file path in the roadmap meta // Put the content paths file path in the roadmap meta
roadmapMeta.contentPathsFilePath = contentPathsFilePath.replace(CONTENT_DIR, ''); roadmapMeta.contentPathsFilePath = contentPathsFilePath.replace(roadmapDirPath, '.');
fs.writeFileSync(roadmapMetaFilePath, JSON.stringify(roadmapMeta, null, 2)); fs.writeFileSync(roadmapMetaFilePath, JSON.stringify(roadmapMeta, null, 2));

@ -17,12 +17,17 @@ const roadmapsMeta = roadmapDirs.reduce((metaAcc, roadmapDirName) => {
// So, we remove it and use the path relative to content directory // So, we remove it and use the path relative to content directory
let landingPath = roadmapMeta.landingPath; let landingPath = roadmapMeta.landingPath;
if (landingPath) { if (landingPath) {
landingPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), roadmapMeta.landingPath); landingPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), landingPath);
} }
let resourcesPath = roadmapMeta.resourcesPath; let resourcesPath = roadmapMeta.resourcesPath;
if (resourcesPath) { if (resourcesPath) {
resourcesPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), roadmapMeta.resourcesPath); resourcesPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), resourcesPath);
}
let contentPathsFilePath = roadmapMeta.contentPathsFilePath;
if (contentPathsFilePath) {
contentPathsFilePath = path.join(roadmapDir.replace(STORAGE_PATH, ''), contentPathsFilePath);
} }
let metaPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), 'meta.json'); let metaPath = path.join(roadmapDir.replace(STORAGE_PATH, ''), 'meta.json');
@ -38,6 +43,7 @@ const roadmapsMeta = roadmapDirs.reduce((metaAcc, roadmapDirName) => {
id: roadmapSlug, id: roadmapSlug,
landingPath: landingPath, landingPath: landingPath,
resourcesPath: resourcesPath, resourcesPath: resourcesPath,
contentPathsFilePath: contentPathsFilePath,
metaPath: metaPath, metaPath: metaPath,
isUpcoming: roadmapMeta.isUpcoming || false isUpcoming: roadmapMeta.isUpcoming || false
} }

Loading…
Cancel
Save