diff options
author | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-27 19:38:41 -0300 |
---|---|---|
committer | João Augusto Costa Branco Marado Torres <torres.dev@disroot.org> | 2025-07-27 19:38:41 -0300 |
commit | 102e58a077bcc267c54fd11a9c346210c346b747 (patch) | |
tree | 5dd662177c1393c09a418f24fc6460101efaf916 /src/pages/blog/keywords | |
parent | 487d5ef7d48c0dcb4acde9fa950623fcb9b53382 (diff) |
feat: keywords
Signed-off-by: João Augusto Costa Branco Marado Torres <torres.dev@disroot.org>
Diffstat (limited to 'src/pages/blog/keywords')
-rw-r--r-- | src/pages/blog/keywords/index.astro | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/pages/blog/keywords/index.astro b/src/pages/blog/keywords/index.astro index 255fbf4..8830af3 100644 --- a/src/pages/blog/keywords/index.astro +++ b/src/pages/blog/keywords/index.astro @@ -1,21 +1,46 @@ --- import { getCollection } from "astro:content"; import Base from "@layouts/Base.astro"; +import KeywordsList from "@components/organisms/KeywordsList.astro"; -const title = "Keywords"; -const description = "Keywords"; +const title = "Palavras-Chave"; +const description = "Palavras-Chave"; const blogs = await getCollection("blog"); -let keywords = [ - ...new Set([ - ...blogs.flatMap(({ data }) => [...(data.keywords ?? [])]), - ]), -]; + +const map: Map<string, number> = new Map(); +for (const { data } of blogs) { + if (!("keywords" in data)) { + continue; + } + + for (const k of data.keywords) { + const n = map.get(k) ?? 0; + map.set(k, n + 1); + } +} + +let keywords = Array.from(map.entries()).sort(([, a], [, b]) => b - a).map(( + [x], +) => x); --- <Base {title} {description} {keywords}> - <h1>Keywords</h1> - <ul> - {keywords.map((k) => <li><a href={`/blog/keywords/${k}`}>{k}</a></li>)} - </ul> + <main + itemprop="mainContentOfPage" + itemscope + itemtype="https://schema.org/WebPageElement" + > + <h2 itemprop="name description">Palavras-Chave</h2> + <div> + <KeywordsList {keywords} /> + </div> + </main> </Base> + +<style> + div { + display: flex; + margin-inline: auto; + } +</style> |