feat: etiketen edukia sortzen du

This commit is contained in:
txarli committed 2026-11-19 10:44:44 +01:00
1 parent 4db754ea16
commit eebcff2a3c
3 files changed
+36 -5

No files matched your search

+5 -1
View File
@@ -17,4 +17,8 @@ const posts = defineCollection({
}), }),
}); });
export const collections = { posts }; const tags = defineCollection({
loader: glob({ pattern: "*.md", base: "./tags" }),
});
export const collections = { posts, tags };
+30 -4
View File
@@ -1,5 +1,5 @@
--- ---
import { getCollection, type CollectionEntry } from "astro:content"; import { getCollection, render, type CollectionEntry } from "astro:content";
import BaseHead from "../../components/BaseHead.astro"; import BaseHead from "../../components/BaseHead.astro";
import Header from "../../components/Header.astro"; import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro"; import Footer from "../../components/Footer.astro";
@@ -38,6 +38,12 @@ export async function getStaticPaths() {
const { tag } = Astro.props; const { tag } = Astro.props;
const { tag: currentTag } = Astro.params; const { tag: currentTag } = Astro.params;
const allTags = await getCollection("tags");
const contentTag = allTags.find(({ id }) => id === currentTag);
const Content = contentTag ? (await render(contentTag)).Content : null;
let sortedPosts = tag.sort( let sortedPosts = tag.sort(
(a, b) => new Date(b.data.added).valueOf() - new Date(a.data.added).valueOf(), (a, b) => new Date(b.data.added).valueOf() - new Date(a.data.added).valueOf(),
); );
@@ -52,7 +58,18 @@ let sortedPosts = tag.sort(
</Container> </Container>
<main> <main>
<content> <content>
<h3>"{currentTag}" etiketarekin markatutako postak</h3> <h1 class={Content ? "has-description" : null}>
"{currentTag}" etiketarekin markatutako postak
</h1>
{
Content && (
<Container>
<Content />
</Container>
)
}
<PostGrid posts={sortedPosts} /> <PostGrid posts={sortedPosts} />
</content> </content>
</main> </main>
@@ -63,9 +80,18 @@ let sortedPosts = tag.sort(
</body> </body>
</html> </html>
<style> <style lang="scss">
h3 { h1 {
color: var(--gray);
line-height: 1.1;
font-size: 1.17em;
margin-bottom: 2em; margin-bottom: 2em;
margin-top: 0; margin-top: 0;
text-align: center;
font-weight: bold;
&.has-description {
margin-bottom: 1em;
}
} }
</style> </style>
+1
View File
@@ -0,0 +1 @@
Etiketa honekin markatu ditudan post-ek, kutxu teknikoa dute. Nire interesak, batez ere, internet eta sareetako zerbitzuak, software librea eta sistema txertatuak (Raspberry Pi Pico eta horrelakoak erabiltzea maite dut) dira. Horretaz gain, lanean (informatikako lanbide heziketako irakaslea naiz) ikasitako gauzatxoak ere jasotzen ditut.