@@ -3,6 +3,10 @@ import { getCollection } from 'astro:content';
33import BaseLayout from ' @layouts/BaseLayout.astro' ;
44import BlogCard from ' @components/BlogCard.astro' ;
55import { readingTime } from ' @utils/helpers' ;
6+ import { getLangFromUrl , useTranslations } from ' @i18n/utils' ;
7+
8+ const currentLang = getLangFromUrl (Astro .url );
9+ const t = useTranslations (currentLang );
610
711// Get all published blog posts
812const allPosts = await getCollection (' blog' , ({ data }) => {
@@ -21,15 +25,15 @@ const featuredPost = sortedPosts[0];
2125---
2226
2327<BaseLayout
24- title =" Blog "
25- description =" Learning, building, and sharing insights about AI, ML, NLP, and software engineering "
28+ title ={ t . blog . title }
29+ description ={ t . blog . subtitle }
2630>
2731 <div class =" container py-12" >
2832 <!-- Header -->
2933 <div class =" text-center mb-12" >
30- <h1 class =" text-4xl md:text-5xl font-bold mb-4" >✍️ Blog </h1 >
34+ <h1 class =" text-4xl md:text-5xl font-bold mb-4" >✍️ { t . blog . title } </h1 >
3135 <p class =" text-xl text-[var(--color-text-muted)] max-w-2xl mx-auto" >
32- Learning, building, and sharing insights about AI/ML, NLP, RAG, and software engineering
36+ { t . blog . subtitle }
3337 </p >
3438 </div >
3539
@@ -39,7 +43,7 @@ const featuredPost = sortedPosts[0];
3943 class =" filter-btn active px-4 py-2 rounded-lg font-medium transition-all"
4044 data-filter =" all"
4145 >
42- All Posts ({ sortedPosts .length } )
46+ { t . blog . allPosts } ({ sortedPosts .length } )
4347 </button >
4448 { languages .map ((lang ) => {
4549 const count = sortedPosts .filter ((p ) => p .data .language === lang ).length ;
@@ -48,7 +52,7 @@ const featuredPost = sortedPosts[0];
4852 class = " filter-btn px-4 py-2 rounded-lg font-medium transition-all"
4953 data-filter = { ` lang-${lang } ` }
5054 >
51- { lang === ' en' ? ' 🇺🇸 English ' : ' 🇻🇳 Vietnamese ' } ({ count } )
55+ { lang === ' en' ? t . blog . english : t . blog . vietnamese } ({ count } )
5256 </button >
5357 );
5458 })}
@@ -70,7 +74,7 @@ const featuredPost = sortedPosts[0];
7074 <div class = " mb-16 card bg-gradient-to-br from-primary-50 to-accent-cyan/5 dark:from-primary-950 dark:to-slate-900 border-primary-200 dark:border-primary-800" >
7175 <div class = " flex items-center gap-2 mb-3" >
7276 <span class = " px-3 py-1 bg-primary-600 text-white text-sm font-bold rounded-full" >
73- 📌 FEATURED
77+ 📌 { t . blog . featured }
7478 </span >
7579 </div >
7680 <h2 class = " text-3xl font-bold mb-3" >
@@ -90,11 +94,11 @@ const featuredPost = sortedPosts[0];
9094 { new Date (featuredPost .data .date ).toLocaleDateString (' en-US' , { year: ' numeric' , month: ' long' , day: ' numeric' })}
9195 </span >
9296 <span class = " text-sm text-[var(--color-text-muted)]" >
93- { readingTime (featuredPost .body )} min read
97+ { readingTime (featuredPost .body )} { t . blog . minRead }
9498 </span >
9599 </div >
96100 <a href = { ` /blog/${featuredPost .slug } ` } class = " mt-4 btn-primary inline-flex items-center" >
97- Read Article
101+ { t . blog . readArticle }
98102 <svg class = " w-5 h-5 ml-2" fill = " none" stroke = " currentColor" viewBox = " 0 0 24 24" >
99103 <path stroke-linecap = " round" stroke-linejoin = " round" stroke-width = " 2" d = " M14 5l7 7m0 0l-7 7m7-7H3" ></path >
100104 </svg >
@@ -104,7 +108,7 @@ const featuredPost = sortedPosts[0];
104108
105109 <!-- All Posts Grid -->
106110 <div class =" mb-8" >
107- <h2 class =" text-2xl font-bold mb-6" >All Posts ({ sortedPosts .length } )</h2 >
111+ <h2 class =" text-2xl font-bold mb-6" >{ t . blog . allPosts } ({ sortedPosts .length } )</h2 >
108112 </div >
109113
110114 <div class =" grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" id =" posts-grid" >
@@ -129,9 +133,9 @@ const featuredPost = sortedPosts[0];
129133
130134 <!-- Empty State -->
131135 <div id =" empty-state" class =" hidden text-center py-16" >
132- <p class =" text-2xl text-[var(--color-text-muted)] mb-4" >No posts found </p >
136+ <p class =" text-2xl text-[var(--color-text-muted)] mb-4" >{ t . blog . emptyState } </p >
133137 <button id =" reset-filters" class =" link text-lg" >
134- Clear filters
138+ { t . blog . clearFilters }
135139 </button >
136140 </div >
137141 </div >
0 commit comments