mirror of
https://github.com/10h30/blog-balodeplao.git
synced 2026-05-12 15:21:15 +09:00
feat: add tag pages and integrate tags component in post layout
This commit is contained in:
@@ -13,7 +13,7 @@ const { tags, class: className = "text-sm" } = Astro.props;
|
|||||||
{tags.map((tag) => (
|
{tags.map((tag) => (
|
||||||
<li class="inline-block relative">
|
<li class="inline-block relative">
|
||||||
<a
|
<a
|
||||||
href={`/tags/${tag}`}
|
href={`/tag/${tag}`}
|
||||||
class="inline-block bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground px-3 py-1 rounded-full border border-border transition-colors duration-200"
|
class="inline-block bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground px-3 py-1 rounded-full border border-border transition-colors duration-200"
|
||||||
>
|
>
|
||||||
#{tag}
|
#{tag}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||||
import Schema from "@/components/seo/Schema.astro";
|
import Schema from "@/components/seo/Schema.astro";
|
||||||
|
import Tags from "@/components/ui/Tags.astro";
|
||||||
|
import Categories from "@/components/ui/Categories.astro";
|
||||||
|
|
||||||
import { getCollection, render } from "astro:content";
|
import { getCollection, render } from "astro:content";
|
||||||
|
|
||||||
@@ -14,7 +16,8 @@ export async function getStaticPaths() {
|
|||||||
|
|
||||||
const { post } = Astro.props;
|
const { post } = Astro.props;
|
||||||
const { Content, remarkPluginFrontmatter } = await render(post);
|
const { Content, remarkPluginFrontmatter } = await render(post);
|
||||||
const { title, description, pubDate, author, image } = post.data;
|
const { title, description, pubDate, author, image, categories, tags } =
|
||||||
|
post.data;
|
||||||
|
|
||||||
const formattedDate = pubDate.toLocaleDateString("vi-VN", {
|
const formattedDate = pubDate.toLocaleDateString("vi-VN", {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
@@ -48,6 +51,13 @@ const metadata = {
|
|||||||
<section class="relative px-4 py-8 sm:px-6 lg:px-8 md:py-12">
|
<section class="relative px-4 py-8 sm:px-6 lg:px-8 md:py-12">
|
||||||
<div class="relative mx-auto max-w-3xl">
|
<div class="relative mx-auto max-w-3xl">
|
||||||
<div class="reveal mb-10 text-center">
|
<div class="reveal mb-10 text-center">
|
||||||
|
{
|
||||||
|
categories && categories.length > 0 && (
|
||||||
|
<div class="mb-3 flex flex-wrap justify-center gap-2">
|
||||||
|
<Categories categories={categories} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
<p class="text-sm font-semibold tracking-wide text-primary uppercase">
|
<p class="text-sm font-semibold tracking-wide text-primary uppercase">
|
||||||
{formattedDate} • {author}
|
{formattedDate} • {author}
|
||||||
{readingTime && ` • ${readingTime}`}
|
{readingTime && ` • ${readingTime}`}
|
||||||
@@ -72,6 +82,13 @@ const metadata = {
|
|||||||
>
|
>
|
||||||
<Content />
|
<Content />
|
||||||
</div>
|
</div>
|
||||||
|
{
|
||||||
|
tags && tags.length > 0 && (
|
||||||
|
<div class="mt-4 relative z-20">
|
||||||
|
<Tags tags={tags} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user