Add and wire extended site env config
This commit is contained in:
@@ -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 && (
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user