Add translations for tags and improve feed

This commit is contained in:
Bad Manners 2024-10-09 10:26:03 -03:00
parent ecb8618a67
commit 1dda4c9af8
No known key found for this signature in database
GPG key ID: 8C88292CCB075609
12 changed files with 75 additions and 24 deletions

View file

@ -3,6 +3,7 @@ import { getCollection } from "astro:content";
import { slug } from "github-slugger";
import GalleryLayout from "@layouts/GalleryLayout.astro";
import { markdownToPlaintext } from "@utils/markdown_to_plaintext";
import { DEFAULT_LANG } from "@i18n";
interface Tag {
id: string;
@ -38,7 +39,12 @@ const categorizedTags = tagCategories
})
.map((category) => {
const tagList = category.data.tags.map<Tag>(({ name, description }) => {
description = description && markdownToPlaintext(description).replaceAll(/\n+/g, " ");
description =
description &&
markdownToPlaintext(typeof description === "object" ? description[DEFAULT_LANG] : description).replaceAll(
/\n+/g,
" ",
);
const tag = typeof name === "string" ? name : name.en;
return { id: slug(tag), name: tag, description };
});

View file

@ -62,7 +62,10 @@ export const getStaticPaths: GetStaticPaths = async () => {
if (key in acc) {
throw new Error(`Duplicated tag "${key}" found in multiple tag-categories lists`);
}
acc[key] = { description, related: related.length > 0 ? related : undefined };
acc[key] = {
description: typeof description === "object" ? description[DEFAULT_LANG] : description,
related: related.length > 0 ? related : undefined,
};
});
return acc;
},