diff --git a/src/components/blog/PostItem.astro b/src/components/blog/PostItem.astro index 9795723..96c3f80 100644 --- a/src/components/blog/PostItem.astro +++ b/src/components/blog/PostItem.astro @@ -1,5 +1,6 @@ --- import Tags from "@/components/ui/Tags.astro"; +import Categories from "@/components/ui/Categories.astro"; import { type CollectionEntry, render } from "astro:content"; export interface Props { @@ -10,7 +11,7 @@ const { post } = Astro.props; const { remarkPluginFrontmatter } = await render(post); const readingTime = remarkPluginFrontmatter?.minutesRead - ? `${Math.ceil(remarkPluginFrontmatter.minutesRead)} min read` + ? `${Math.ceil(remarkPluginFrontmatter.minutesRead)} phút đọc` : ""; --- @@ -34,7 +35,7 @@ const readingTime = remarkPluginFrontmatter?.minutesRead {post.data.author}

@@ -55,7 +56,7 @@ const readingTime = remarkPluginFrontmatter?.minutesRead

+ { + post.data.categories && ( +
+ +
+ ) + } + { post.data.tags && (
diff --git a/src/components/layout/Footer.astro b/src/components/layout/Footer.astro index dc15b61..e01077d 100644 --- a/src/components/layout/Footer.astro +++ b/src/components/layout/Footer.astro @@ -13,25 +13,18 @@ import { siteConfig } from "@/config/site";
TwitterInstagram GitHub - DiscordFacebook
@@ -39,7 +32,7 @@ import { siteConfig } from "@/config/site"; class="mt-8 border-t border-border pt-8 text-center text-xs text-muted-foreground" > © {new Date().getFullYear()} - {siteConfig.author}. All rights reserved. + {siteConfig.name}. All rights reserved. diff --git a/src/components/seo/Schema.astro b/src/components/seo/Schema.astro index 9abb2b6..b76820a 100644 --- a/src/components/seo/Schema.astro +++ b/src/components/seo/Schema.astro @@ -28,7 +28,7 @@ if (type === "WebSite") { "@type": "Person", name: siteConfig.author, }, - sameAs: [siteConfig.socialLinks.twitter, siteConfig.socialLinks.github], + sameAs: [siteConfig.socialLinks.instagram, siteConfig.socialLinks.facebook], }; } else if (type === "BlogPosting") { schema = { diff --git a/src/components/ui/Categories.astro b/src/components/ui/Categories.astro new file mode 100644 index 0000000..8fc8979 --- /dev/null +++ b/src/components/ui/Categories.astro @@ -0,0 +1,25 @@ +--- +export interface Props { + categories: string[]; + class?: string; +} + +const { categories, class: className = "text-sm" } = Astro.props; +--- + +{ + categories && Array.isArray(categories) && ( + + ) +} diff --git a/src/components/ui/Pagination.astro b/src/components/ui/Pagination.astro index 92d3523..5ac2532 100644 --- a/src/components/ui/Pagination.astro +++ b/src/components/ui/Pagination.astro @@ -28,7 +28,7 @@ const { prev, next } = url; )}
- Página {currentPage} de {lastPage} + Trang {currentPage} / {lastPage}
{next ? ( (
  • #{tag} diff --git a/src/config/site.ts b/src/config/site.ts index 452142f..7ee5047 100644 --- a/src/config/site.ts +++ b/src/config/site.ts @@ -2,25 +2,21 @@ import ogImage from "@/assets/og-image.png"; export const siteConfig = { name: "Astro Starter Pro", - description: - "Starter template optimized for SEO and performance. A solid foundation to start your projects with best practices.", - url: "https://astrostarterpro.com", - lang: "en", - locale: "en_US", - author: "Devgelo", - twitter: "@Devgelo", + description: "Just another Astro blog", + url: "https://thuanbui.me", + lang: "vi", + locale: "vi_VN", + author: "Thuan Bui", + twitter: "@10h30", ogImage: ogImage, socialLinks: { - twitter: "https://twitter.com", - github: "https://github.com/devgelo-labs/astro-starter-pro", - discord: "https://discord.com", + instagram: "https://instagram.com/", + facebook: "https://facebook.com/", }, navLinks: [ { text: "Home", href: "/" }, { text: "About", href: "/about" }, - { text: "Services", href: "/services" }, { text: "Blog", href: "/blog" }, { text: "Contact", href: "/contact" }, - { text: "Widgets", href: "/widgets" }, ], }; diff --git a/src/content.config.ts b/src/content.config.ts index b7dfab7..364bed4 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -5,12 +5,12 @@ const blog = defineCollection({ loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/content/blog" }), schema: z.object({ title: z.string(), - description: z.string(), + description: z.string().optional(), pubDate: z.coerce.date(), author: z.string(), image: z.string().optional(), tags: z.array(z.string()).optional(), - category: z.string().optional(), + categories: z.array(z.string()).optional(), }), }); diff --git a/src/pages/blog/[...slug].astro b/src/pages/[...slug].astro similarity index 87% rename from src/pages/blog/[...slug].astro rename to src/pages/[...slug].astro index bf7a971..5046c10 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/[...slug].astro @@ -16,14 +16,14 @@ const { post } = Astro.props; const { Content, remarkPluginFrontmatter } = await render(post); const { title, description, pubDate, author, image } = post.data; -const formattedDate = pubDate.toLocaleDateString("es-ES", { +const formattedDate = pubDate.toLocaleDateString("vi-VN", { year: "numeric", month: "long", day: "numeric", }); const readingTime = remarkPluginFrontmatter?.minutesRead - ? `${Math.ceil(remarkPluginFrontmatter.minutesRead)} min de lectura` + ? `${Math.ceil(remarkPluginFrontmatter.minutesRead)} phút đọc` : ""; const metadata = { @@ -62,7 +62,11 @@ const metadata = { { image && (
    - {title} + {title}
    ) } diff --git a/src/pages/blog/category/[category].astro b/src/pages/category/[category].astro similarity index 89% rename from src/pages/blog/category/[category].astro rename to src/pages/category/[category].astro index 8d3572d..3a8adcd 100644 --- a/src/pages/blog/category/[category].astro +++ b/src/pages/category/[category].astro @@ -10,9 +10,7 @@ export async function getStaticPaths() { const categories = new Set(); posts.forEach((post) => { - if (post.data.category) { - categories.add(post.data.category); - } + post.data.categories?.forEach((tag) => categories.add(tag)); }); return Array.from(categories).map((category) => { @@ -20,7 +18,9 @@ export async function getStaticPaths() { params: { category: category as string }, props: { category, - posts: posts.filter((post) => post.data.category === category), + posts: posts.filter((post) => + post.data.categories?.includes(category as string), + ), }, }; }); @@ -50,7 +50,7 @@ const metadata = { />
    diff --git a/src/pages/blog/tags/[tag].astro b/src/pages/tags/[tag].astro similarity index 98% rename from src/pages/blog/tags/[tag].astro rename to src/pages/tags/[tag].astro index d7b0b15..e17968b 100644 --- a/src/pages/blog/tags/[tag].astro +++ b/src/pages/tags/[tag].astro @@ -48,7 +48,7 @@ const metadata = { />