🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
43
node_modules/@astrojs/sitemap/dist/generate-sitemap.js
generated
vendored
Normal file
43
node_modules/@astrojs/sitemap/dist/generate-sitemap.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { parseUrl } from "./utils/parse-url.js";
|
||||
function generateSitemap(pages, finalSiteUrl, opts) {
|
||||
const { changefreq, priority, lastmod: lastmodSrc, i18n } = opts;
|
||||
const urls = [...pages];
|
||||
urls.sort((a, b) => a.localeCompare(b, "en", { numeric: true }));
|
||||
const lastmod = lastmodSrc == null ? void 0 : lastmodSrc.toISOString();
|
||||
const { locales, defaultLocale } = i18n || {};
|
||||
const localeCodes = Object.keys(locales || {});
|
||||
const getPath = (url) => {
|
||||
const result = parseUrl(url, (i18n == null ? void 0 : i18n.defaultLocale) || "", localeCodes, finalSiteUrl);
|
||||
return result == null ? void 0 : result.path;
|
||||
};
|
||||
const getLocale = (url) => {
|
||||
const result = parseUrl(url, (i18n == null ? void 0 : i18n.defaultLocale) || "", localeCodes, finalSiteUrl);
|
||||
return result == null ? void 0 : result.locale;
|
||||
};
|
||||
const urlData = urls.map((url) => {
|
||||
let links;
|
||||
if (defaultLocale && locales) {
|
||||
const currentPath = getPath(url);
|
||||
if (currentPath) {
|
||||
const filtered = urls.filter((subUrl) => getPath(subUrl) === currentPath);
|
||||
if (filtered.length > 1) {
|
||||
links = filtered.map((subUrl) => ({
|
||||
url: subUrl,
|
||||
lang: locales[getLocale(subUrl)]
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
url,
|
||||
links,
|
||||
lastmod,
|
||||
priority,
|
||||
changefreq
|
||||
};
|
||||
});
|
||||
return urlData;
|
||||
}
|
||||
export {
|
||||
generateSitemap
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue