refactor: optimize multilingual article routing logic, modify slug to abbrlink

This commit is contained in:
radishzzz 2025-03-11 00:34:30 +00:00
parent 16491dae50
commit e5165dd740
16 changed files with 673 additions and 133 deletions

View file

@ -21,7 +21,7 @@ const postsByYear = await getPostsByYear(lang)
<ul>
{pinnedPosts.map(post => (
<li>
<a href={`/${lang}/posts/${post.data.slug || post.slug}/`}>
<a href={`/${lang}/posts/${post.data.abbrlink || post.slug}/`}>
{post.data.title}
<time class="block lg:inline lg:before:content-['_']">
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}
@ -45,7 +45,7 @@ const postsByYear = await getPostsByYear(lang)
// Single Post
<li class="mt-6">
{/* Post Title */}
<a href={`/${lang}/posts/${post.data.slug || post.slug}`}>{post.data.title}</a>
<a href={`/${lang}/posts/${post.data.abbrlink || post.slug}/`}>{post.data.title}</a>
{/* Post Date */}
<time class="block text-5.6 leading-7 font-navbar opacity-30 lg:inline lg:before:content-['_']">
{post.data.published.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' }).replace('/', '-')}

View file

@ -27,7 +27,7 @@ const allTags = await getAllTags()
<ul>
{posts.map(post => (
<li>
<a href={`/${lang}/posts/${post.data.slug || post.slug}/`}>{post.data.title}</a>
<a href={`/${lang}/posts/${post.data.abbrlink || post.slug}/`}>{post.data.title}</a>
</li>
))}
</ul>