diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 8c8da4074d..c4cc58a182 100644 --- a/docs/.vuepress/config.js +++ b/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'], ], }; diff --git a/docs/.vuepress/plugins/sitemap-index.js b/docs/.vuepress/plugins/sitemap-index.js new file mode 100644 index 0000000000..6a31d3af24 --- /dev/null +++ b/docs/.vuepress/plugins/sitemap-index.js @@ -0,0 +1,31 @@ +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 = ` + +${sitemaps + .map( + (sitemap) => ` + ${sitemap} + ${now} + `, + ) + .join('\n')} +`; + + fs.writeFileSync(sitemapIndexPath, sitemapIndexXml); + console.log(`\n✅ Sitemap index generated at ${sitemapIndexPath}`); + }, + }; +}; diff --git a/docs/.vuepress/public/robots.txt b/docs/.vuepress/public/robots.txt new file mode 100644 index 0000000000..47fe73182c --- /dev/null +++ b/docs/.vuepress/public/robots.txt @@ -0,0 +1,5 @@ +User-agent: * +Allow: / + +Sitemap: https://grapesjs.com/docs/sitemap-index.xml +