mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 12:22:45 +02:00
Sitemap local (#157)
* Better support for localized pages in sitemap * clean console
This commit is contained in:
parent
73b9a1128b
commit
c97da9d3f7
1 changed files with 14 additions and 12 deletions
|
@ -34,6 +34,7 @@ Metadata = require("../core/metadata.js");
|
||||||
readMetadata.generateMetadataBlog();
|
readMetadata.generateMetadataBlog();
|
||||||
MetadataBlog = require("../core/MetadataBlog.js");
|
MetadataBlog = require("../core/MetadataBlog.js");
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
module.exports = function(callback) {
|
module.exports = function(callback) {
|
||||||
|
@ -41,7 +42,7 @@ module.exports = function(callback) {
|
||||||
|
|
||||||
let urls = [];
|
let urls = [];
|
||||||
|
|
||||||
let files = glob.sync(CWD + "/pages/**/*.js");
|
let files = glob.sync(CWD + "/pages/en/**/*.js");
|
||||||
|
|
||||||
// English-only is the default.
|
// English-only is the default.
|
||||||
let enabledLanguages = [{
|
let enabledLanguages = [{
|
||||||
|
@ -60,16 +61,13 @@ module.exports = function(callback) {
|
||||||
|
|
||||||
// create a url mapping to all the enabled languages files
|
// create a url mapping to all the enabled languages files
|
||||||
files.map(file => {
|
files.map(file => {
|
||||||
enabledLanguages.map(lang => {
|
let url = file.split("/pages/en")[1];
|
||||||
let url = file.split("/pages/en")[1];
|
url = url.replace(/\.js$/, ".html");
|
||||||
let tag = "";
|
let links = enabledLanguages.map(lang => {
|
||||||
if (lang.tag != "en") {
|
let langUrl = lang.tag + url;
|
||||||
tag = lang.tag;
|
return { lang: lang.tag, url: langUrl };
|
||||||
}
|
|
||||||
url = tag + url;
|
|
||||||
url = url.replace(/\.js$/, ".html");
|
|
||||||
urls.push({ url: "/" + url, changefreq: "weekly", priority: 0.5 });
|
|
||||||
});
|
});
|
||||||
|
urls.push({ url, changefreq: "weekly", priority: 0.5, links });
|
||||||
});
|
});
|
||||||
|
|
||||||
let htmlFiles = glob.sync(CWD + "/pages/**/*.html");
|
let htmlFiles = glob.sync(CWD + "/pages/**/*.html");
|
||||||
|
@ -82,9 +80,13 @@ module.exports = function(callback) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.keys(Metadata).map(key => {
|
Object.keys(Metadata).filter(key => Metadata[key].language === "en").map(key => {
|
||||||
let doc = Metadata[key];
|
let doc = Metadata[key];
|
||||||
urls.push({ url: doc.permalink, changefreq: "hourly", priority: 1.0 });
|
let links = enabledLanguages.map(lang => {
|
||||||
|
let langUrl = doc.permalink.replace("docs/en/", `docs/${lang.tag}/`);
|
||||||
|
return { lang: lang.tag, url: langUrl };
|
||||||
|
});
|
||||||
|
urls.push({ url: doc.permalink, changefreq: "hourly", priority: 1.0, links });
|
||||||
});
|
});
|
||||||
|
|
||||||
const sm = sitemap.createSitemap({
|
const sm = sitemap.createSitemap({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue