feat: etiketen edukia sortzen du
This commit is contained in:
1 parent
4db754ea16
commit
eebcff2a3c
3 files changed
+36
-5
No files matched your search
@@ -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 };
|
||||
@@ -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 Header from "../../components/Header.astro";
|
||||
import Footer from "../../components/Footer.astro";
|
||||
@@ -38,6 +38,12 @@ export async function getStaticPaths() {
|
||||
const { tag } = Astro.props;
|
||||
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(
|
||||
(a, b) => new Date(b.data.added).valueOf() - new Date(a.data.added).valueOf(),
|
||||
);
|
||||
@@ -52,7 +58,18 @@ let sortedPosts = tag.sort(
|
||||
</Container>
|
||||
<main>
|
||||
<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} />
|
||||
</content>
|
||||
</main>
|
||||
@@ -63,9 +80,18 @@ let sortedPosts = tag.sort(
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
h3 {
|
||||
<style lang="scss">
|
||||
h1 {
|
||||
color: var(--gray);
|
||||
line-height: 1.1;
|
||||
font-size: 1.17em;
|
||||
margin-bottom: 2em;
|
||||
margin-top: 0;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
|
||||
&.has-description {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -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.
|
||||
Reference in new issue
Block a user