Add env-based site configuration
This commit is contained in:
8
.env.local.example
Normal file
8
.env.local.example
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copy this file to `.env.local` and adjust values.
|
||||||
|
# All vars prefixed with NEXT_PUBLIC_ are exposed to the browser.
|
||||||
|
|
||||||
|
NEXT_PUBLIC_SITE_NAME="Your Name"
|
||||||
|
NEXT_PUBLIC_SITE_TITLE="Your Personal Site"
|
||||||
|
NEXT_PUBLIC_SITE_DESCRIPTION="Personal homepage and blog."
|
||||||
|
NEXT_PUBLIC_SITE_URL="https://example.com"
|
||||||
|
NEXT_PUBLIC_SITE_AUTHOR="Your Name"
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { getAllPostsSorted } from '@/lib/posts';
|
import { getAllPostsSorted } from '@/lib/posts';
|
||||||
|
import { siteConfig } from '@/lib/config';
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const posts = getAllPostsSorted().slice(0, 5);
|
const posts = getAllPostsSorted().slice(0, 5);
|
||||||
@@ -7,7 +8,9 @@ export default function HomePage() {
|
|||||||
return (
|
return (
|
||||||
<section className="space-y-6">
|
<section className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-3xl font-bold">你好,我是 Your Name</h1>
|
<h1 className="text-3xl font-bold">
|
||||||
|
你好,我是 {siteConfig.name}
|
||||||
|
</h1>
|
||||||
<p className="mt-2 text-gray-600 dark:text-gray-300">
|
<p className="mt-2 text-gray-600 dark:text-gray-300">
|
||||||
這裡是我的個人首頁與技術 Blog。
|
這裡是我的個人首頁與技術 Blog。
|
||||||
</p>
|
</p>
|
||||||
@@ -39,4 +42,3 @@ export default function HomePage() {
|
|||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
import { siteConfig } from '@/lib/config';
|
||||||
|
|
||||||
export function SiteFooter() {
|
export function SiteFooter() {
|
||||||
return (
|
return (
|
||||||
<footer className="border-t py-4 text-center text-sm text-gray-500">
|
<footer className="border-t py-4 text-center text-sm text-gray-500">
|
||||||
© {new Date().getFullYear()} Your Name
|
© {new Date().getFullYear()} {siteConfig.author}
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { ThemeToggle } from './theme-toggle';
|
import { ThemeToggle } from './theme-toggle';
|
||||||
|
import { siteConfig } from '@/lib/config';
|
||||||
|
|
||||||
export function SiteHeader() {
|
export function SiteHeader() {
|
||||||
return (
|
return (
|
||||||
<header className="border-b bg-white/80 dark:bg-gray-950/80 backdrop-blur">
|
<header className="border-b bg-white/80 dark:bg-gray-950/80 backdrop-blur">
|
||||||
<div className="container mx-auto flex items-center justify-between px-4 py-3">
|
<div className="container mx-auto flex items-center justify-between px-4 py-3">
|
||||||
<Link href="/" className="font-semibold">
|
<Link href="/" className="font-semibold">
|
||||||
個人首頁
|
{siteConfig.title}
|
||||||
</Link>
|
</Link>
|
||||||
<nav className="flex items-center gap-4 text-sm">
|
<nav className="flex items-center gap-4 text-sm">
|
||||||
<Link href="/blog">Blog</Link>
|
<Link href="/blog">Blog</Link>
|
||||||
@@ -17,4 +18,3 @@ export function SiteHeader() {
|
|||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
export const siteConfig = {
|
export const siteConfig = {
|
||||||
name: 'Your Name',
|
name: process.env.NEXT_PUBLIC_SITE_NAME || 'Your Name',
|
||||||
title: 'Your Personal Site',
|
title: process.env.NEXT_PUBLIC_SITE_TITLE || 'Your Personal Site',
|
||||||
description: 'Personal homepage and blog.',
|
description:
|
||||||
url: 'http://localhost:3000'
|
process.env.NEXT_PUBLIC_SITE_DESCRIPTION ||
|
||||||
|
'Personal homepage and blog.',
|
||||||
|
url: process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000',
|
||||||
|
author: process.env.NEXT_PUBLIC_SITE_AUTHOR || 'Your Name'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user