Add translations for tags and improve feed
This commit is contained in:
parent
ecb8618a67
commit
1dda4c9af8
12 changed files with 75 additions and 24 deletions
|
|
@ -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 };
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue