Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 6x 6x 6x 12x 12x 13x 6x 13x 7x 11x 6x 6x 5x 12x 1x | import { getArticleIndex } from "../../services/articleIndex";
import { getCategories } from "../../services/categories";
import { isHiddenTerm } from "../../services/hiddenTerms";
export default defineSitemapEventHandler(async (event) => {
const {
public: { pageSlugs },
} = useRuntimeConfig(event);
const content = useContent(event);
const [articles, categories, pageReads] = await Promise.all([
getArticleIndex(event),
getCategories(event),
Promise.allSettled(pageSlugs.map((slug) => content.getEntry("pages", slug))),
]);
const pages = pageReads.flatMap((read) => (read.status === "fulfilled" ? [read.value] : []));
const authorSlugs = new Set(articles.flatMap(({ authors }) => authors.map(({ slug }) => slug)));
return [
...articles
.filter(({ noindex }) => !noindex)
.map(({ slug, updatedAt, publishedAt }) => ({
loc: `/${slug}/`,
lastmod: updatedAt ?? publishedAt,
})),
...pages
.filter(({ seo }) => !seo?.noindex)
.map(({ slug, updatedAt }) => ({ loc: `/${slug}/`, lastmod: updatedAt })),
...categories
.filter((category) => !isHiddenTerm(category))
.map(({ slug }) => ({ loc: `/areas/${slug}/` })),
...[...authorSlugs].map((slug) => ({ loc: `/colaboradores/${slug}/` })),
];
});
defineRouteMeta({
openAPI: {
tags: ["SEO"],
summary: "The content URLs the sitemap lists beside the app's own pages",
},
});
|