diff --git a/scripts/sitemap.js b/scripts/sitemap.js index 7154fe094..5dd21007b 100644 --- a/scripts/sitemap.js +++ b/scripts/sitemap.js @@ -2,7 +2,8 @@ const fs = require('fs'); const path = require('path'); const guides = require('../storage/guides'); -const { getPageRoutes, getGuideRoutes, getRoadmapRoutes } = require('./path-map'); +const roadmaps = require('../storage/roadmaps'); +const { getPageRoutes, getGuideRoutes } = require('./path-map'); const DOMAIN = 'https://roadmap.sh'; const PAGES_DIR = path.join(__dirname, '../pages'); @@ -31,7 +32,7 @@ const getSlugPriority = (pageSlug) => { ]; const foundIndex = slugPriorities.findIndex( - routes => routes.some(route => pageSlug.startsWith(route)) + routes => routes.some(route => pageSlug.startsWith(route)), ); if (foundIndex !== -1) { @@ -48,13 +49,13 @@ function generateNode({ fileName, priority = null, date = null, - frequency = 'monthly' + frequency = 'monthly', }) { const pagePath = path.join(basePath, fileName); let pageStats = {}; try { pageStats = fs.lstatSync(pagePath); - } catch(e) { + } catch (e) { console.log(`File not found: ${pagePath}`); pageStats = { mtime: (new Date()) } } @@ -72,7 +73,7 @@ function generateSiteMap() { const pageSlugs = Object.keys(pageRoutes) .filter(route => ![ '/privacy', - '/terms' + '/terms', ].includes(route)); const pagesChunk = pageSlugs.map(pageSlug => { @@ -85,7 +86,7 @@ function generateSiteMap() { // Chunks for each of the guides const guideRoutes = getGuideRoutes(); - const guideSlugs = Object.keys(guideRoutes); + const guideSlugs = Object.keys(guideRoutes); const guidesChunk = guideSlugs.map(guideSlug => { const foundGuide = guides.find(guide => guide.url === guideSlug) || {}; return generateNode({ @@ -98,17 +99,32 @@ function generateSiteMap() { }); // Chunks for each of the roadmaps - const roadmapRoutes = getRoadmapRoutes(); - const roadmapSlugs = Object.keys(roadmapRoutes); - const roadmapsChunk = roadmapSlugs.map(roadmapSlug => { - const [, role, year = 'latest'] = roadmapSlug.split('/'); - return generateNode({ - basePath: STATIC_PATH, - fileName: `/roadmaps/${year}/${role}.png`, - slug: roadmapSlug, - priority: '1.0', - }); - }); + const roadmapsChunk = roadmaps.reduce((roadmapsNodes, roadmap) => { + return [ + ...roadmapsNodes, + generateNode({ + basePath: STORAGE_PATH, + fileName: roadmap.path, + slug: roadmap.url, + priority: '1.0', + }), + ...Object + .values(roadmap.sidebar || {}) + .reduce((pageNodes, menuPages) => { + return [ + ...pageNodes, + ...menuPages.map(menuPage => { + return generateNode({ + basePath: STORAGE_PATH, + fileName: menuPage.path, + slug: menuPage.url, + priority: '1.0', + }) + }) + ]; + }, []) + ] + }, []); const nodes = [ ...roadmapsChunk, diff --git a/static/sitemap.xml b/static/sitemap.xml index de78a6ab6..046a8c828 100644 --- a/static/sitemap.xml +++ b/static/sitemap.xml @@ -1,201 +1,171 @@ - https://roadmap.sh/1-frontend + https://roadmap.sh/frontend monthly - 2019-11-27T20:16:53.144Z + 2019-11-25T16:20:19.426Z 1.0 - https://roadmap.sh/1-frontend/junior + https://roadmap.sh/frontend/junior monthly - 2019-11-27T20:16:53.144Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/intermediate + https://roadmap.sh/frontend/intermediate monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/senior + https://roadmap.sh/frontend/senior monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/job-ready + https://roadmap.sh/frontend/job-ready monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/write-better-css + https://roadmap.sh/frontend/write-better-css monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/build-tools + https://roadmap.sh/frontend/build-tools monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/modern-frontend-applications + https://roadmap.sh/frontend/modern-frontend-applications monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/automated-testing + https://roadmap.sh/frontend/automated-testing monthly - 2019-11-27T20:16:53.145Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/static-type-checkers + https://roadmap.sh/frontend/static-type-checkers monthly - 2019-11-27T20:16:53.146Z + 2019-11-25T16:18:18.890Z 1.0 - https://roadmap.sh/1-frontend/server-side-rendering + https://roadmap.sh/frontend/server-side-rendering monthly - 2019-11-27T20:16:53.146Z + 2019-11-25T16:18:18.891Z 1.0 - https://roadmap.sh/1-frontend/go-beyond + https://roadmap.sh/frontend/go-beyond monthly - 2019-11-27T20:16:53.146Z + 2019-11-25T16:18:18.891Z 1.0 - https://roadmap.sh/1-frontend/summary + https://roadmap.sh/backend monthly - 2019-11-27T20:16:53.146Z + 2019-11-27T20:13:58.873Z 1.0 - https://roadmap.sh/2-backend + https://roadmap.sh/backend/junior monthly - 2019-11-27T20:16:53.146Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/2-backend/junior + https://roadmap.sh/backend/intermediate monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/2-backend/intermediate + https://roadmap.sh/backend/senior monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/2-backend/senior + https://roadmap.sh/devops monthly - 2019-11-27T20:16:53.148Z + 2019-11-27T20:14:19.847Z 1.0 - https://roadmap.sh/2-backend/summary + https://roadmap.sh/devops/junior monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/3-devops + https://roadmap.sh/devops/intermediate monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/3-devops/junior + https://roadmap.sh/devops/senior monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/3-devops/intermediate + https://roadmap.sh/fullstack monthly - 2019-11-27T20:16:53.148Z + 2019-11-27T20:14:37.663Z 1.0 - https://roadmap.sh/3-devops/senior + https://roadmap.sh/fullstack/junior monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/3-devops/summary + https://roadmap.sh/fullstack/intermediate monthly - 2019-11-27T20:16:53.148Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/4-fullstack + https://roadmap.sh/fullstack/senior monthly - 2019-11-27T20:16:53.149Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/4-fullstack/junior + https://roadmap.sh/qa monthly - 2019-11-27T20:16:53.149Z + 2019-11-27T20:14:50.558Z 1.0 - https://roadmap.sh/4-fullstack/intermediate + https://roadmap.sh/qa/junior monthly - 2019-11-27T20:16:53.149Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/4-fullstack/senior + https://roadmap.sh/qa/intermediate monthly - 2019-11-27T20:16:53.149Z + 2019-11-25T16:18:18.000Z 1.0 - https://roadmap.sh/4-fullstack/summary + https://roadmap.sh/qa/senior monthly - 2019-11-27T20:16:53.149Z - 1.0 - - - https://roadmap.sh/5-qa - monthly - 2019-11-27T20:16:53.149Z - 1.0 - - - https://roadmap.sh/5-qa/junior - monthly - 2019-11-27T20:16:53.149Z - 1.0 - - - https://roadmap.sh/5-qa/intermediate - monthly - 2019-11-27T20:16:53.149Z - 1.0 - - - https://roadmap.sh/5-qa/senior - monthly - 2019-11-27T20:16:53.149Z - 1.0 - - - https://roadmap.sh/5-qa/summary - monthly - 2019-11-27T20:16:53.149Z + 2019-11-25T16:18:18.000Z 1.0