Browse Source

GRA-164: updates sitemap build step

GRA-164-adds-sitemap-to-grapesjs-update
Mark Danial 3 months ago
parent
commit
fee85f0234
  1. 1
      docs/.vuepress/config.js
  2. 28
      docs/.vuepress/plugins/sitemap-index.js
  3. 5
      docs/.vuepress/public/robots.txt

1
docs/.vuepress/config.js

@ -148,5 +148,6 @@ module.exports = {
plugins: [
['@vuepress/google-analytics', { ga: 'UA-74284223-1' }],
['sitemap', { hostname: 'https://grapesjs.com' }],
['./plugins/sitemap-index'],
],
};

28
docs/.vuepress/plugins/sitemap-index.js

@ -0,0 +1,28 @@
const fs = require('fs');
const path = require('path');
module.exports = (options, context) => {
return {
generated() {
const sitemapIndexPath = path.resolve(context.outDir || options.dest, 'sitemap-index.xml');
const sitemaps = [
'https://grapesjs.com/sitemap.xml',
'https://grapesjs.com/docs/sitemap.xml',
'https://app.grapesjs.com/sitemap.xml',
];
const now = new Date().toISOString();
const sitemapIndexXml = `<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${sitemaps.map(sitemap => ` <sitemap>
<loc>${sitemap}</loc>
<lastmod>${now}</lastmod>
</sitemap>`).join('\n')}
</sitemapindex>`;
fs.writeFileSync(sitemapIndexPath, sitemapIndexXml);
console.log(`\n✅ Sitemap index generated at ${sitemapIndexPath}`);
},
};
};

5
docs/.vuepress/public/robots.txt

@ -0,0 +1,5 @@
User-agent: *
Allow: /
Sitemap: https://grapesjs.com/docs/sitemap-index.xml
Loading…
Cancel
Save