Update sitemap generation for roadmap pages

pull/1657/head
Kamran Ahmed 5 years ago
parent 2d7828590b
commit a8df86de2e
  1. 50
      scripts/sitemap.js
  2. 142
      static/sitemap.xml

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

@ -1,201 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://roadmap.sh/1-frontend</loc>
<loc>https://roadmap.sh/frontend</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.144Z</lastmod>
<lastmod>2019-11-25T16:20:19.426Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/junior</loc>
<loc>https://roadmap.sh/frontend/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.144Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/intermediate</loc>
<loc>https://roadmap.sh/frontend/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/senior</loc>
<loc>https://roadmap.sh/frontend/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/job-ready</loc>
<loc>https://roadmap.sh/frontend/job-ready</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/write-better-css</loc>
<loc>https://roadmap.sh/frontend/write-better-css</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/build-tools</loc>
<loc>https://roadmap.sh/frontend/build-tools</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/modern-frontend-applications</loc>
<loc>https://roadmap.sh/frontend/modern-frontend-applications</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/automated-testing</loc>
<loc>https://roadmap.sh/frontend/automated-testing</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.145Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/static-type-checkers</loc>
<loc>https://roadmap.sh/frontend/static-type-checkers</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.146Z</lastmod>
<lastmod>2019-11-25T16:18:18.890Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/server-side-rendering</loc>
<loc>https://roadmap.sh/frontend/server-side-rendering</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.146Z</lastmod>
<lastmod>2019-11-25T16:18:18.891Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/go-beyond</loc>
<loc>https://roadmap.sh/frontend/go-beyond</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.146Z</lastmod>
<lastmod>2019-11-25T16:18:18.891Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/1-frontend/summary</loc>
<loc>https://roadmap.sh/backend</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.146Z</lastmod>
<lastmod>2019-11-27T20:13:58.873Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/2-backend</loc>
<loc>https://roadmap.sh/backend/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.146Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/2-backend/junior</loc>
<loc>https://roadmap.sh/backend/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/2-backend/intermediate</loc>
<loc>https://roadmap.sh/backend/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/2-backend/senior</loc>
<loc>https://roadmap.sh/devops</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-27T20:14:19.847Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/2-backend/summary</loc>
<loc>https://roadmap.sh/devops/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/3-devops</loc>
<loc>https://roadmap.sh/devops/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/3-devops/junior</loc>
<loc>https://roadmap.sh/devops/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/3-devops/intermediate</loc>
<loc>https://roadmap.sh/fullstack</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-27T20:14:37.663Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/3-devops/senior</loc>
<loc>https://roadmap.sh/fullstack/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/3-devops/summary</loc>
<loc>https://roadmap.sh/fullstack/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.148Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/4-fullstack</loc>
<loc>https://roadmap.sh/fullstack/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/4-fullstack/junior</loc>
<loc>https://roadmap.sh/qa</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<lastmod>2019-11-27T20:14:50.558Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/4-fullstack/intermediate</loc>
<loc>https://roadmap.sh/qa/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/4-fullstack/senior</loc>
<loc>https://roadmap.sh/qa/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/4-fullstack/summary</loc>
<loc>https://roadmap.sh/qa/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/5-qa</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/5-qa/junior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/5-qa/intermediate</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/5-qa/senior</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://roadmap.sh/5-qa/summary</loc>
<changefreq>monthly</changefreq>
<lastmod>2019-11-27T20:16:53.149Z</lastmod>
<lastmod>2019-11-25T16:18:18.000Z</lastmod>
<priority>1.0</priority>
</url>
<url>

Loading…
Cancel
Save