diff options
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> |