From 918e51e030af4e4c3027bfbd9a329e457635b95c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 5 Nov 2024 13:45:08 +0100 Subject: [PATCH] Add generators for anime pages --- _config.ts | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/_config.ts b/_config.ts index facaa66..8f5e393 100644 --- a/_config.ts +++ b/_config.ts @@ -20,6 +20,7 @@ site.data("date", "Git Created") site.data("layout", "index.tsx", "/index.md") site.data("tags", ["index"], "/index.md") + site.data("url", "/games/index.html", "/list-games.md") site.data("layout", "list-games.tsx", "/list-games.md") site.data("tags", ["list", "list-games"], "/list-games.md") @@ -40,6 +41,7 @@ site.use(fileData({ }) } })) + site.use(fileData({ query: "list-games", urlizer(_data) { @@ -52,6 +54,7 @@ site.use(fileData({ }) } })) + site.use(fileData({ query: "game", urlizer(data) { @@ -60,6 +63,7 @@ site.use(fileData({ contentizer(data) { return JSON.stringify({ name: data.name ?? null, + name_sort: data.name_sort ?? null, rating: data.rating ?? null, content: data.content ?? null, active: data.active ?? null, @@ -74,6 +78,7 @@ site.use(fileData({ }) } })) + site.use(feed({ output: ["/games/feed.rss", "/games/feed.json"], query: "game", @@ -86,4 +91,60 @@ site.use(feed({ } })) + +site.data("url", "/anime/index.html", "/list-anime.md") +site.data("layout", "list-anime.tsx", "/list-anime.md") +site.data("tags", ["list", "list-anime"], "/list-anime.md") + +site.data("layout", "anime.tsx", "/anime") +site.data("tags", ["review", "anime"], "/anime") + +site.use(fileData({ + query: "list-anime", + urlizer(_data) { + return "/anime/index.json" + }, + contentizer(data) { + return JSON.stringify({ + content: data.content, + items: site.search.pages("anime").map((data) => data.url.replace(".html", ".json")) + }) + } +})) + +site.use(fileData({ + query: "anime", + urlizer(data) { + return data.url.replace(".html", ".json") + }, + contentizer(data) { + return JSON.stringify({ + name: data.name ?? null, + name_sort: data.name_sort ?? null, + name_original: data.name_original ?? null, + rating: data.rating ?? null, + content: data.content ?? null, + active: data.active ?? null, + progress: data.progress ?? null, + started_on: data.started_on ?? null, + completed_on: data.completed_on ?? null, + mastered_on: data.mastered_on ?? null, + identifiers: data.identifiers ?? null, + }) + } +})) + +site.use(feed({ + output: ["/anime/feed.rss", "/anime/feed.json"], + query: "anime", + limit: 10, + info: { + title: "Anime", // TODO: Change this to your site's anime section's name! + }, + items: { + title: "=name" + } +})) + + export default site;