diff --git a/i18n/index.ts b/i18n/index.ts
index 97150331..cd40d1d5 100644
--- a/i18n/index.ts
+++ b/i18n/index.ts
@@ -1,9 +1,9 @@
-export const defaultLocale = 'zh-TW';
+export const defaultLocale = 'zh';
export const locales = [defaultLocale, 'en'] as const;
export type Locale = (typeof locales)[number];
const dictionaries = {
- 'zh-TW': () => import('./locales/zh-TW').then((module) => module.default),
+ zh: () => import('./locales/zh').then((module) => module.default),
en: () => import('./locales/en').then((module) => module.default),
};
diff --git a/i18n/locales/zh-TW/common.ts b/i18n/locales/zh/common.ts
similarity index 100%
rename from i18n/locales/zh-TW/common.ts
rename to i18n/locales/zh/common.ts
diff --git a/i18n/locales/zh-TW/index.ts b/i18n/locales/zh/index.ts
similarity index 79%
rename from i18n/locales/zh-TW/index.ts
rename to i18n/locales/zh/index.ts
index df66dd3e..d4f77504 100644
--- a/i18n/locales/zh-TW/index.ts
+++ b/i18n/locales/zh/index.ts
@@ -2,10 +2,10 @@ import common from './common';
import metadata from './metadata';
import notFound from './notFound';
-const zhTW = {
+const zh = {
common,
metadata,
notFound,
};
-export default zhTW;
+export default zh;
diff --git a/i18n/locales/zh-TW/metadata.ts b/i18n/locales/zh/metadata.ts
similarity index 100%
rename from i18n/locales/zh-TW/metadata.ts
rename to i18n/locales/zh/metadata.ts
diff --git a/i18n/locales/zh-TW/notFound.ts b/i18n/locales/zh/notFound.ts
similarity index 100%
rename from i18n/locales/zh-TW/notFound.ts
rename to i18n/locales/zh/notFound.ts
diff --git a/src/assets/css/globals.css b/src/app/css/globals.css
similarity index 100%
rename from src/assets/css/globals.css
rename to src/app/css/globals.css
diff --git a/src/assets/css/prism-plus.css b/src/app/css/prism-plus.css
similarity index 100%
rename from src/assets/css/prism-plus.css
rename to src/app/css/prism-plus.css
diff --git a/src/assets/css/prism-vsc-dark-plus.css b/src/app/css/prism-vsc-dark-plus.css
similarity index 100%
rename from src/assets/css/prism-vsc-dark-plus.css
rename to src/app/css/prism-vsc-dark-plus.css
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index f4a7ad1a..e71e2da1 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -3,10 +3,10 @@ import type { Metadata } from 'next';
import { locales } from '~/i18n';
import { createMetadata, createFeedOptions } from '~/data/metadata';
import generateRSS from '@/utils/generateRSS';
-import '@/assets/css/globals.css';
import Html from './Html';
import Providers from './Providers';
+import './css/globals.css';
export const dynamic = 'force-static';
diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx
index a2962fcb..77a2e8db 100644
--- a/src/components/Card/Card.tsx
+++ b/src/components/Card/Card.tsx
@@ -1,11 +1,10 @@
-import Image from 'next/image';
-
import { BsCalendar4Week } from 'react-icons/bs';
import { MdOutlineWidgets } from 'react-icons/md';
import { AiOutlineTags } from 'react-icons/ai';
import { formatDate } from '@/utils/date';
import Link from '../Link';
+import Image from '../Image';
type CardProps = DataFrontmatter;
@@ -25,7 +24,7 @@ function Card({
{image && (
{
+ const isActiveLink = (href: DynamicRoutesWithoutLocalePath) => {
const locale = getLocale(pathname) || '';
const localePrefix = new RegExp(`^/${locale}/?`);
const adjustedPathname = pathname.replace(localePrefix, '/');
diff --git a/src/components/Link/Link.tsx b/src/components/Link/Link.tsx
index a43b6fda..3ceeca26 100644
--- a/src/components/Link/Link.tsx
+++ b/src/components/Link/Link.tsx
@@ -26,19 +26,11 @@ function Link({
}: LinkProps) {
const pathname = usePathname();
- const isObjectHref = typeof href === 'object';
+ const isObjectHref = typeof href === 'object' || href.startsWith('#');
const isAnchorLink = !isObjectHref && href.startsWith('#');
const isInternalLink = !isObjectHref && href.startsWith('/');
- if (isObjectHref) {
- return (
-
- {children}
-
- );
- }
-
- if (isAnchorLink) {
+ if (isObjectHref || isAnchorLink) {
return (
{children}
@@ -66,7 +58,7 @@ function Link({
href={href}
target="_blank"
rel="noopener noreferrer"
- className={cn('inline-flex align-top', className)}
+ className={cn('inline-flex', className)}
{...otherProps}
>
{children}
diff --git a/src/components/Link/link.test.tsx b/src/components/Link/link.test.tsx
index 9696d375..adbf1a48 100644
--- a/src/components/Link/link.test.tsx
+++ b/src/components/Link/link.test.tsx
@@ -33,8 +33,8 @@ describe('Link component', () => {
it.each([
['/internal', '/internal'],
['/en/internal', '/en/internal'],
- ['/zh-TW/internal', '/zh-TW/internal'],
- ['/fr-CH/internal', '/internal'],
+ ['/zh/internal', '/zh/internal'],
+ ['/fr/internal', '/internal'],
])(
'should render correct link element with pathname %s',
(pathname, expected) => {
diff --git a/src/hooks/__tests__/useI18n.test.ts b/src/hooks/__tests__/useI18n.test.ts
index 6bb43170..c4da28a5 100644
--- a/src/hooks/__tests__/useI18n.test.ts
+++ b/src/hooks/__tests__/useI18n.test.ts
@@ -13,10 +13,10 @@ describe('useI18n hook', () => {
});
it.each([
- ['/test/path', 'zh-TW'],
+ ['/test/path', 'zh'],
['/en/test/path', 'en'],
- ['/zh-TW/test/path', 'zh-TW'],
- ['/fr-CH/test/path', 'zh-TW'],
+ ['/zh/test/path', 'zh'],
+ ['/fr/test/path', 'zh'],
])(
'should return the correct language code and dictionary',
(pathname, expected) => {
diff --git a/src/middleware.ts b/src/middleware.ts
index e231820f..81a8d644 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -15,7 +15,7 @@ export function middleware(request: NextRequest) {
const locale = getLocale(acceptLanguage, defaultLocale);
const redirectURL = new URL(`/${locale}${pathname}`, request.url);
- if (locale !== 'zh-TW') {
+ if (locale !== defaultLocale) {
return NextResponse.redirect(redirectURL);
}
diff --git a/src/utils/__tests__/getLocale.test.ts b/src/utils/__tests__/getLocale.test.ts
index ddfcda35..5539d41c 100644
--- a/src/utils/__tests__/getLocale.test.ts
+++ b/src/utils/__tests__/getLocale.test.ts
@@ -8,9 +8,9 @@ describe('get locale function', () => {
});
it.each([
- ['zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'zh-TW'],
+ ['zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'zh'],
['en-US,en;q=0.9,zh-TW;q=0.8,ja;q=0.7', 'en'],
- ['fr-CH,fr;q=0.9,de-CH;q=0.8,de;q=0.7', 'zh-TW'],
+ ['fr-CH,fr;q=0.9,de-CH;q=0.8,de;q=0.7', 'zh'],
])(
'should extract the preferred language code from the Accept-Language header',
(acceptLanguage, expected) => {
@@ -19,10 +19,10 @@ describe('get locale function', () => {
);
it.each([
- ['/test/path', 'zh-TW'],
+ ['/test/path', 'zh'],
['/en/test/path', 'en'],
- ['/zh-TW/test/path', 'zh-TW'],
- ['/fr-CH/test/path', 'zh-TW'],
+ ['/zh/test/path', 'zh'],
+ ['/fr/test/path', 'zh'],
])(
'should extract the language code from the path string',
(pathname, expected) => {
diff --git a/tailwind.config.js b/tailwind.config.js
index 9d21d20e..4cd607a2 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -7,13 +7,13 @@ const tailwindcssConfig = {
theme: {
extend: {
colors: {
- primary: { ...colors.cyan, DEFAULT: colors.cyan[500] }
+ primary: { ...colors.lime, DEFAULT: colors.lime[500] },
},
typography: {
DEFAULT: {
css: {
a: {
- textDecoration: 'none'
+ textDecoration: 'none',
},
code: {
margin: '0 4px',
@@ -22,6 +22,11 @@ const tailwindcssConfig = {
background: '#1e1e1e',
color: '#ff8888',
},
+ li: {
+ a: {
+ margin: 0,
+ },
+ },
'code::before': { content: '' },
'code::after': { content: '' },
},