Add and wire extended site env config

This commit is contained in:
2025-11-17 16:51:59 +08:00
parent e64ec9a35d
commit 237bb083cd
7 changed files with 116 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import { notFound } from 'next/navigation';
import type { Metadata } from 'next';
import { allPosts } from 'contentlayer/generated';
import { getPostBySlug } from '@/lib/posts';
import { siteConfig } from '@/lib/config';
export function generateStaticParams() {
return allPosts.map((post) => ({
@@ -44,7 +45,9 @@ export default function BlogPostPage({ params }: Props) {
)}
{post.published_at && (
<p className="text-xs text-gray-500">
{new Date(post.published_at).toLocaleDateString('zh-TW')}
{new Date(post.published_at).toLocaleDateString(
siteConfig.defaultLocale
)}
</p>
)}
{post.tags && (

View File

@@ -1,5 +1,6 @@
import Link from 'next/link';
import { getAllPostsSorted } from '@/lib/posts';
import { siteConfig } from '@/lib/config';
export const metadata = {
title: 'Blog'
@@ -22,7 +23,9 @@ export default function BlogIndexPage() {
</Link>
<div className="text-xs text-gray-500">
{post.published_at &&
new Date(post.published_at).toLocaleDateString('zh-TW')}
new Date(post.published_at).toLocaleDateString(
siteConfig.defaultLocale
)}
{post.tags && post.tags.length > 0 && (
<span className="ml-2">
{post.tags.map((t) => (
@@ -47,4 +50,3 @@ export default function BlogIndexPage() {
</section>
);
}

View File

@@ -9,7 +9,22 @@ export const metadata: Metadata = {
default: siteConfig.title,
template: `%s | ${siteConfig.title}`
},
description: siteConfig.description
description: siteConfig.description,
metadataBase: new URL(siteConfig.url),
openGraph: {
title: siteConfig.title,
description: siteConfig.description,
url: siteConfig.url,
siteName: siteConfig.title,
images: [siteConfig.ogImage]
},
twitter: {
card: siteConfig.twitterCard,
site: siteConfig.social.twitter || undefined,
title: siteConfig.title,
description: siteConfig.description,
images: [siteConfig.ogImage]
}
};
export default function RootLayout({
@@ -18,7 +33,7 @@ export default function RootLayout({
children: React.ReactNode;
}) {
return (
<html lang="zh-Hant" suppressHydrationWarning>
<html lang={siteConfig.defaultLocale} suppressHydrationWarning>
<body>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<LayoutShell>{children}</LayoutShell>
@@ -27,4 +42,3 @@ export default function RootLayout({
</html>
);
}

View File

@@ -3,7 +3,7 @@ import { getAllPostsSorted } from '@/lib/posts';
import { siteConfig } from '@/lib/config';
export default function HomePage() {
const posts = getAllPostsSorted().slice(0, 5);
const posts = getAllPostsSorted().slice(0, siteConfig.postsPerPage);
return (
<section className="space-y-6">
@@ -12,7 +12,7 @@ export default function HomePage() {
{siteConfig.name}
</h1>
<p className="mt-2 text-gray-600 dark:text-gray-300">
Blog
{siteConfig.tagline}
</p>
</div>
@@ -26,7 +26,9 @@ export default function HomePage() {
</Link>
{post.published_at && (
<span className="ml-2 text-xs text-gray-500">
{new Date(post.published_at).toLocaleDateString('zh-TW')}
{new Date(post.published_at).toLocaleDateString(
siteConfig.defaultLocale
)}
</span>
)}
</li>