From 502090d8fd26da95120822b1ec53524f0f67ab41 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 10:31:09 +0800 Subject: [PATCH 1/8] poem list --- src/app/[lang]/list/[page]/page.tsx | 39 ++++++++--------------------- src/dictionaries/en.json | 3 +++ src/dictionaries/index.ts | 6 ++--- src/dictionaries/ja.json | 3 +++ src/dictionaries/ko.json | 3 +++ src/dictionaries/zh-Hans.json | 3 +++ src/dictionaries/zh-Hant.json | 3 +++ src/utils/index.ts | 6 +++++ 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/app/[lang]/list/[page]/page.tsx b/src/app/[lang]/list/[page]/page.tsx index 70a2ad32..c45be404 100644 --- a/src/app/[lang]/list/[page]/page.tsx +++ b/src/app/[lang]/list/[page]/page.tsx @@ -9,10 +9,10 @@ import { Pagination } from "~/components/pagination"; import { type Locale, getDictionary, - getLangText, getMetaDataAlternates, } from "~/dictionaries"; import { type Metadata } from "next"; +import { stringFormat } from "~/utils"; interface Props { params: { page: string; lang: Locale }; @@ -24,44 +24,25 @@ export async function generateMetadata({ searchParams, }: Props): Promise { const pageIndex = Number(params.page); + const dict = await getDictionary(params.lang); if (pageIndex < 1 || isNaN(pageIndex)) notFound(); let text = ""; let description = ""; if (searchParams?.sort === "createdAt" || !searchParams?.sort) { - text = getLangText({ "zh-Hans": "最新", "zh-Hant": "最新" }, params.lang); - description = getLangText( - { - "zh-Hans": "当前诗词列表按照最近修改时间倒序排列", - "zh-Hant": "當前詩詞列表按照最近修改時間倒序排列", - }, - params.lang, - ); + text = dict.poem_list.tab_new; + description = dict.poem_list.description_improve; } else if (searchParams?.sort === "improve") { - text = getLangText( - { "zh-Hans": "待完善", "zh-Hant": "待完善" }, - params.lang, - ); - description = getLangText( - { - "zh-Hans": - "当前诗词列表按照完善程度倒序排列,需要完善的诗词排在最前面。", - "zh-Hant": - "當前詩詞列表按照完善程度倒序排列,需要完善的詩詞排在最前面。", - }, - params.lang, - ); + text = dict.poem_list.tab_improve; + description = dict.poem_list.description_new; } return { - title: getLangText( - { - "zh-Hans": `${text}诗词列表 第${pageIndex}页`, - "zh-Hant": `${text}詩詞列表 第${pageIndex}頁`, - }, - params.lang, - ), + title: stringFormat(dict.poem_list.title_meta, [ + text, + pageIndex.toString(), + ]), description, alternates: getMetaDataAlternates(`/list/${pageIndex}`, params.lang), }; diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index edaf7084..e9b42f57 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -57,7 +57,10 @@ }, "poem_list": { "title": "Poem List", + "title_meta": "{0} Poem List Page {1}", "empty": "No relevant poems found", + "description_new": "The latest poems are here, come and read them!", + "description_improve": "The poems that need to be improved are here, come and help us improve them!", "tab_new": "Newest", "tab_improve": "To be improved" }, diff --git a/src/dictionaries/index.ts b/src/dictionaries/index.ts index 38e75e7d..75cfa187 100644 --- a/src/dictionaries/index.ts +++ b/src/dictionaries/index.ts @@ -1,3 +1,4 @@ +import { merge } from "lodash-es"; import "server-only"; export const defaultLocale = "zh-Hans"; @@ -32,10 +33,7 @@ export const getDictionary = async (locale: Locale = "zh-Hans") => { const zhHans = await dictionaries["zh-Hans"](); const result = await dictionaries[locale](); - return { - ...zhHans, - ...result, - }; + return merge(zhHans, result); }; export type Dictionary = Awaited>; diff --git a/src/dictionaries/ja.json b/src/dictionaries/ja.json index ca84fcf7..25f54d89 100644 --- a/src/dictionaries/ja.json +++ b/src/dictionaries/ja.json @@ -57,7 +57,10 @@ }, "poem_list": { "title": "詩のリスト", + "title_meta": "{0}詩のリスト ページ {1}", "empty": "関連する詩が見つかりませんでした", + "description_new": "最新の詩がここにあります、読んでみてください!", + "description_improve": "改善が必要な詩がここにあります、改善に協力してください!", "tab_new": "最新", "tab_improve": "改善待ち" }, diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index ea89a74c..c4e73ff5 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -57,7 +57,10 @@ }, "poem_list": { "title": "시 목록", + "title_meta": "{0} 시 목록 페이지 {1}", "empty": "관련 시를 찾을 수 없습니다", + "description_new": "최신 시가 여기 있습니다. 읽어보세요!", + "description_improve": "보완이 필요한 시가 여기 있습니다. 보완에 도움을 주", "tab_new": "최신", "tab_improve": "보완 필요" }, diff --git a/src/dictionaries/zh-Hans.json b/src/dictionaries/zh-Hans.json index 1eb823b0..5336d4be 100644 --- a/src/dictionaries/zh-Hans.json +++ b/src/dictionaries/zh-Hans.json @@ -57,7 +57,10 @@ }, "poem_list": { "title": "诗词列表", + "title_meta": "{0}诗词列表 第 {1} 页", "empty": "没有找到相关诗词", + "description_new": "最新的诗词都在这里,快来阅读吧!", + "description_improve": "需要完善的诗词都在这里,快来帮助我们完善吧!", "tab_new": "最新", "tab_improve": "待完善" }, diff --git a/src/dictionaries/zh-Hant.json b/src/dictionaries/zh-Hant.json index b1887144..3421b040 100644 --- a/src/dictionaries/zh-Hant.json +++ b/src/dictionaries/zh-Hant.json @@ -57,7 +57,10 @@ }, "poem_list": { "title": "詩詞列表", + "title_meta": "{0}詩詞列表 第 {1} 頁", "empty": "沒有找到相關詩詞", + "description_new": "最新的詩詞在這裡,快來閱讀吧!", + "description_improve": "需要完善的詩詞在這裡,快來幫助我們完善吧!", "tab_new": "最新", "tab_improve": "待完善" }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 930e0b02..8d5f6bf6 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -43,3 +43,9 @@ export const splitChineseSymbol = (str: string, separator = true) => { .split(/。|!|?|,|;/) .filter((s) => !!s); }; + +export const stringFormat = (str: string, arr: string[]) => { + return str.replace(/{(\d+)}/g, (match, number: number) => { + return typeof arr[number] !== "undefined" ? arr[number] : match; + }); +}; From b2aa85dba887f4b88f6cf2535cd4f46db4733f66 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 10:44:19 +0800 Subject: [PATCH 2/8] en ja ko website title --- src/dictionaries/en.json | 2 +- src/dictionaries/ja.json | 4 ++-- src/dictionaries/ko.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index e9b42f57..8213ceab 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -1,6 +1,6 @@ { "title": "Learn Chinese Poems Website", - "description": "aspoem.com is a modern poetry learning website that offers a comprehensive site search feature, allowing you to quickly search for regulated verse, quatrains, and works by various poets. We have also optimized the display of pinyin annotations, annotations, and vernacular Chinese, making poetry easier to read. Additionally, we provide a poetry printing tool to assist you in better studying ancient poetry. Come and experience the charm of our website!", + "description": "aspoem.com is a learning chinese poetry website that offers a comprehensive site search feature, allowing you to quickly search for regulated verse, quatrains, and works by various poets. We have also optimized the display of pinyin annotations, annotations, and vernacular Chinese, making poetry easier to read. Additionally, we provide a poetry printing tool to assist you in better studying ancient poetry. Come and experience the charm of our website!", "point_keywords": [ "poetry learning", "learning ancient poetry", diff --git a/src/dictionaries/ja.json b/src/dictionaries/ja.json index 25f54d89..acc4e14b 100644 --- a/src/dictionaries/ja.json +++ b/src/dictionaries/ja.json @@ -1,6 +1,6 @@ { - "title": "近代詩学習ウェブサイト", - "description": "aspoem.comは、近代詩学習のためのモダンなウェブサイトであり、サイト全体の検索機能を提供しています。この機能を利用することで、律詩や絶句、詩人たちの作品をより迅速に検索することができます。また、私たちは拼音の表示方法、注釈や白話文の展示方法などを最適化し、詩をより読みやすくしています。さらに、古代詩学の学習をサポートする詩学印刷ツールも提供しています。ぜひ、私たちのウェブサイトの魅力を体験してください!", + "title": "中国の詩を学ぶウェブサイト", + "description": "aspoem.comは中国の詩学習ウェブサイトであり、包括的なサイト検索機能を提供しています。規範詩、四行詩、さまざまな詩人の作品を素早く検索することができます。また、拼音注釈、注釈、口語中国語の表示を最適化し、詩を読みやすくしています。さらに、古代詩の学習をサポートする詩の印刷ツールも提供しています。ぜひ、当ウェブサイトの魅力を体験してください!", "point_keywords": [ "詩学習", "古詩学習", diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index c4e73ff5..950bbe7d 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -1,6 +1,6 @@ { - "title": "현대시 학습 웹사이트", - "description": "aspoem.com은 현대화된 시 학습 웹사이트로, 전체 사이트 검색 기능을 제공합니다. 리듀시, 절, 그리고 다양한 시인들의 작품을 더 빠르게 검색할 수 있도록 편리한 전체 사이트 검색 기능을 제공합니다. 또한 우리는 발음 표기, 주석, 평문 등의 표시 방식을 최적화하여 시를 더욱 쉽게 읽을 수 있도록 했습니다. 게다가 고대 시를 공부하기 위한 시인프린터 도구도 제공합니다. 지금 저희 웹사이트의 매력을 경험해보세요!", + "title": "중국 시 학습 웹사이트", + "description": "aspoem.com은 다양한 시인의 정규 시, 사백곡 및 작품을 빠르게 검색할 수 있는 포괄적인 사이트 검색 기능을 제공하는 중국 시 학습 웹사이트입니다. 또한, 우리는 발음 주석, 주석 및 구어 중국어의 표시를 최적화하여 시를 더 쉽게 읽을 수 있도록 하였습니다. 게다가, 고대 시를 더 잘 공부할 수 있도록 도와주는 시 인쇄 도구도 제공합니다. 저희 웹사이트의 매력을 경험해보세요!", "point_keywords": [ "시 학습", "고대 시 학습", From 3e9be9986e47b604509d9bc3141cf8fcd878c184 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 11:14:45 +0800 Subject: [PATCH 3/8] ci pai ming --- src/app/[lang]/ci-pai-ming/[page]/page.tsx | 29 ++++++---------------- src/dictionaries/en.json | 4 +++ src/dictionaries/index.ts | 4 +-- src/dictionaries/ja.json | 4 +++ src/dictionaries/ko.json | 4 +++ src/dictionaries/zh-Hans.json | 4 +++ src/dictionaries/zh-Hant.json | 4 +++ 7 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/app/[lang]/ci-pai-ming/[page]/page.tsx b/src/app/[lang]/ci-pai-ming/[page]/page.tsx index aeebbf76..db405fd3 100644 --- a/src/app/[lang]/ci-pai-ming/[page]/page.tsx +++ b/src/app/[lang]/ci-pai-ming/[page]/page.tsx @@ -6,25 +6,18 @@ import { HeaderMain } from "~/components/ui/header"; import { api } from "~/trpc/server"; import { getDictionary, - getLangText, getLangUrl, getMetaDataAlternates, type Locale, } from "~/dictionaries"; import { type Metadata } from "next"; import { cache } from "react"; +import { stringFormat } from "~/utils"; interface Props { params: { page: string; lang: Locale }; } -const description = { - "zh-Hans": - "词的一种制式曲调的名称,亦即唐宋时代经常用以填词的大致固定的一部分乐曲的原名,有固定的格式与声律,决定着词的节奏与音律。", - "zh-Hant": - "詞的一種制式曲調的名稱,亦即唐宋時代經常用以填詞的大致固定的一部分樂曲的原名,有固定的格式與聲律,決定着詞的節奏與音律。", -}; - const getItem = cache(({ params }: Props) => { const pageIndex = Number(params.page || 1); if (pageIndex < 1 || isNaN(pageIndex)) notFound(); @@ -43,15 +36,9 @@ export async function generateMetadata(props: Props): Promise { const { data, page } = await getItem(props); return { - title: getLangText( - { - "zh-Hans": `${dict.menu.ci_pai_ming} 第${page}页`, - "zh-Hant": `${dict.menu.ci_pai_ming} 第${page}頁`, - }, - params.lang, - ), + title: stringFormat(dict.ci_pai_ming.title_meta, [page.toString()]), alternates: getMetaDataAlternates(`/ci-pai-ming/${page}`, params.lang), - description: getLangText(description, params.lang), + description: dict.ci_pai_ming.description, keywords: data.map((item) => item.name), }; } @@ -74,12 +61,12 @@ export default async function Page(props: Props) {

{dict.menu.ci_pai_ming} - + cí pái míng

-

- {getLangText(description, params.lang)} +

+ {dict.ci_pai_ming.description}

@@ -90,7 +77,7 @@ export default async function Page(props: Props) { className="group relative cursor-pointer justify-between rounded-md border border-border bg-card p-4 text-card-foreground transition-all hover:bg-accent hover:text-accent-foreground hover:shadow-md" >
-
+
-

+

{item.introduce}

diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index 8213ceab..37401c10 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -70,6 +70,10 @@ "author_detail": { "title": "Poets" }, + "ci_pai_ming": { + "title_meta": "Ci Pai Ming Page {0}", + "description": "A name for a standardized tune of a poem, that is, the original name of a large part of the music that was frequently used to fill in the poems in the Tang and Song dynasties, with a fixed format and tone, determining the rhythm and tone of the poem." + }, "search": { "placeholder": "Search for poems, poets, etc.", "empty": "No search results found" diff --git a/src/dictionaries/index.ts b/src/dictionaries/index.ts index 75cfa187..150916a8 100644 --- a/src/dictionaries/index.ts +++ b/src/dictionaries/index.ts @@ -1,4 +1,4 @@ -import { merge } from "lodash-es"; +import { defaultsDeep } from "lodash-es"; import "server-only"; export const defaultLocale = "zh-Hans"; @@ -33,7 +33,7 @@ export const getDictionary = async (locale: Locale = "zh-Hans") => { const zhHans = await dictionaries["zh-Hans"](); const result = await dictionaries[locale](); - return merge(zhHans, result); + return defaultsDeep(result, zhHans) as typeof zhHans; }; export type Dictionary = Awaited>; diff --git a/src/dictionaries/ja.json b/src/dictionaries/ja.json index acc4e14b..86f37e5e 100644 --- a/src/dictionaries/ja.json +++ b/src/dictionaries/ja.json @@ -70,6 +70,10 @@ "author_detail": { "title": "詩人詳細" }, + "ci_pai_ming": { + "title_meta": "詞牌名 ページ {0}", + "description": "詩の標準的な旋律の名称であり、唐宋時代に詩にしばしば用いられ、固定された形式と音調によって詩のリズムと音調を決定する大部分の音楽の元の名称です。" + }, "search": { "placeholder": "詩人、詩、名言を検索", "empty": "関連する詩が見つかりませんでした" diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index 950bbe7d..31cf0627 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -70,6 +70,10 @@ "author_detail": { "title": "시인" }, + "ci_pai_ming": { + "title_meta": "사파명 페이지 {0}", + "description": "시의 표준적인 곡조를 위한 이름으로, 즉, 당송시대에 자주 사용되어 시에 삽입되는 음악의 큰 부분의 원래 이름입니다. 고정된 형식과 음조로, 시의 리듬과 음조를 결정합니다." + }, "search": { "placeholder": "시인, 시, 명구 검색", "empty": "관련 시를 찾을 수 없습니다" diff --git a/src/dictionaries/zh-Hans.json b/src/dictionaries/zh-Hans.json index 5336d4be..3f35b0fb 100644 --- a/src/dictionaries/zh-Hans.json +++ b/src/dictionaries/zh-Hans.json @@ -70,6 +70,10 @@ "author_detail": { "title": "诗人" }, + "ci_pai_ming": { + "title_meta": "词牌名 第 {0} 页", + "description": "词的一种制式曲调的名称,亦即唐宋时代经常用以填词的大致固定的一部分乐曲的原名,有固定的格式与声律,决定着词的节奏与音律。" + }, "search": { "placeholder": "查找诗人、诗词、名句", "empty": "没有找到相关诗词" diff --git a/src/dictionaries/zh-Hant.json b/src/dictionaries/zh-Hant.json index 3421b040..9e173de1 100644 --- a/src/dictionaries/zh-Hant.json +++ b/src/dictionaries/zh-Hant.json @@ -70,6 +70,10 @@ "author_detail": { "title": "詩人" }, + "ci_pai_ming": { + "title_meta": "詞牌名 第 {0} 頁", + "description": "詞的一種製式曲調的名稱,亦即唐宋時代經常用以填詞的大致固定的一部分樂曲的原名,有固定的格式與聲律,決定著詞的節奏與音律。" + }, "search": { "placeholder": "查找詩人、詩詞、名句", "empty": "沒有找到相關詩詞" From 5cc3e7918558d7b3fd99d0ea1b7eea5f472a0995 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 11:23:29 +0800 Subject: [PATCH 4/8] tag --- src/app/[lang]/tag/page.tsx | 17 +++-------------- src/dictionaries/en.json | 4 ++++ src/dictionaries/ja.json | 4 ++++ src/dictionaries/ko.json | 4 ++++ src/dictionaries/zh-Hans.json | 4 ++++ src/dictionaries/zh-Hant.json | 4 ++++ 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/app/[lang]/tag/page.tsx b/src/app/[lang]/tag/page.tsx index f3b296e5..e8564935 100644 --- a/src/app/[lang]/tag/page.tsx +++ b/src/app/[lang]/tag/page.tsx @@ -10,6 +10,7 @@ import { type Locale, } from "~/dictionaries"; import { api } from "~/trpc/server"; +import { stringFormat } from "~/utils"; interface Props { params: { lang: Locale }; @@ -31,20 +32,8 @@ export async function generateMetadata(props: Props): Promise { const keywords = tags.slice(0, 15).map((item) => item.name); return { - title: getLangText( - { - "zh-Hans": "标签", - "zh-Hant": "標籤", - }, - params.lang, - ), - description: getLangText( - { - "zh-Hans": `诗词分类常用标签包括:${keywords.join(",")}等`, - "zh-Hant": `詩詞分類常用標籤包括:${keywords.join(",")}等`, - }, - params.lang, - ), + title: dict.menu.tag, + description: stringFormat(dict.tag.description, [keywords.join(",")]), alternates: getMetaDataAlternates("/tag", params.lang), keywords: keywords.concat(dict.point_keywords), }; diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index 37401c10..fcf8cadb 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -78,6 +78,10 @@ "placeholder": "Search for poems, poets, etc.", "empty": "No search results found" }, + "tag": { + "title": "Tags", + "description": "Popular tags for poetry: {0}" + }, "pagination": { "prev": "Previous", "next": "Next" diff --git a/src/dictionaries/ja.json b/src/dictionaries/ja.json index 86f37e5e..b3cb5620 100644 --- a/src/dictionaries/ja.json +++ b/src/dictionaries/ja.json @@ -78,6 +78,10 @@ "placeholder": "詩人、詩、名言を検索", "empty": "関連する詩が見つかりませんでした" }, + "tag": { + "title": "タグ", + "description": "人気のある詩のタグ: {0}" + }, "pagination": { "prev": "前へ", "next": "次へ" diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index 31cf0627..4c2324dc 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -78,6 +78,10 @@ "placeholder": "시인, 시, 명구 검색", "empty": "관련 시를 찾을 수 없습니다" }, + "tag": { + "title": "태그", + "description": "시에 대한 인기 있는 태그: {0}" + }, "pagination": { "prev": "이전", "next": "다음" diff --git a/src/dictionaries/zh-Hans.json b/src/dictionaries/zh-Hans.json index 3f35b0fb..2cdd2bcb 100644 --- a/src/dictionaries/zh-Hans.json +++ b/src/dictionaries/zh-Hans.json @@ -78,6 +78,10 @@ "placeholder": "查找诗人、诗词、名句", "empty": "没有找到相关诗词" }, + "tag": { + "title": "标签", + "description": "诗词热门标签:{0}" + }, "pagination": { "prev": "上一页", "next": "下一页" diff --git a/src/dictionaries/zh-Hant.json b/src/dictionaries/zh-Hant.json index 9e173de1..098a1d0f 100644 --- a/src/dictionaries/zh-Hant.json +++ b/src/dictionaries/zh-Hant.json @@ -78,6 +78,10 @@ "placeholder": "查找詩人、詩詞、名句", "empty": "沒有找到相關詩詞" }, + "tag": { + "title": "標籤", + "description": "詩詞熱門標籤:{0}" + }, "pagination": { "prev": "上一頁", "next": "下一頁" From 290385a791327883b952523a18b48447b3314e13 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 14:09:44 +0800 Subject: [PATCH 5/8] build --- src/dictionaries/index.ts | 6 ++++-- src/utils/index.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dictionaries/index.ts b/src/dictionaries/index.ts index 150916a8..38e75e7d 100644 --- a/src/dictionaries/index.ts +++ b/src/dictionaries/index.ts @@ -1,4 +1,3 @@ -import { defaultsDeep } from "lodash-es"; import "server-only"; export const defaultLocale = "zh-Hans"; @@ -33,7 +32,10 @@ export const getDictionary = async (locale: Locale = "zh-Hans") => { const zhHans = await dictionaries["zh-Hans"](); const result = await dictionaries[locale](); - return defaultsDeep(result, zhHans) as typeof zhHans; + return { + ...zhHans, + ...result, + }; }; export type Dictionary = Awaited>; diff --git a/src/utils/index.ts b/src/utils/index.ts index 8d5f6bf6..79fdb4f9 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -45,7 +45,7 @@ export const splitChineseSymbol = (str: string, separator = true) => { }; export const stringFormat = (str: string, arr: string[]) => { - return str.replace(/{(\d+)}/g, (match, number: number) => { - return typeof arr[number] !== "undefined" ? arr[number] : match; + return str.replace(/{(\d+)}/g, (match = "", number: number) => { + return arr[number] || match; }); }; From 9d28eb69c5bf1b3d09328ecd427a61e5c9758579 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 14:22:51 +0800 Subject: [PATCH 6/8] rm keywords --- src/app/[lang]/tag/page.tsx | 1 - src/dictionaries/en.json | 24 ------------------------ src/dictionaries/index.ts | 13 +++++++++---- src/dictionaries/ja.json | 24 ------------------------ src/dictionaries/ko.json | 25 ------------------------- src/dictionaries/zh-Hans.json | 24 ------------------------ src/dictionaries/zh-Hant.json | 24 ------------------------ 7 files changed, 9 insertions(+), 126 deletions(-) diff --git a/src/app/[lang]/tag/page.tsx b/src/app/[lang]/tag/page.tsx index e8564935..ba0e08da 100644 --- a/src/app/[lang]/tag/page.tsx +++ b/src/app/[lang]/tag/page.tsx @@ -35,7 +35,6 @@ export async function generateMetadata(props: Props): Promise { title: dict.menu.tag, description: stringFormat(dict.tag.description, [keywords.join(",")]), alternates: getMetaDataAlternates("/tag", params.lang), - keywords: keywords.concat(dict.point_keywords), }; } diff --git a/src/dictionaries/en.json b/src/dictionaries/en.json index fcf8cadb..db389530 100644 --- a/src/dictionaries/en.json +++ b/src/dictionaries/en.json @@ -1,30 +1,6 @@ { "title": "Learn Chinese Poems Website", "description": "aspoem.com is a learning chinese poetry website that offers a comprehensive site search feature, allowing you to quickly search for regulated verse, quatrains, and works by various poets. We have also optimized the display of pinyin annotations, annotations, and vernacular Chinese, making poetry easier to read. Additionally, we provide a poetry printing tool to assist you in better studying ancient poetry. Come and experience the charm of our website!", - "point_keywords": [ - "poetry learning", - "learning ancient poetry", - "Three Hundred Tang Poems", - "Three Hundred Song Lyrics", - "Complete Works of Li Bai", - "Complete Works of Du Fu" - ], - "keywords": [ - "poetry learning", - "learning ancient poetry", - "Three Hundred Tang Poems", - "Three Hundred Song Lyrics", - "Complete Works of Li Bai", - "Complete Works of Du Fu", - "ancient poetry", - "poetry", - "poet statistics", - "poetry search", - "poetry pinyin", - "poetry annotations", - "poetry translation", - "pinyin" - ], "menu": { "poem": "Poems", "author": "Poets", diff --git a/src/dictionaries/index.ts b/src/dictionaries/index.ts index 38e75e7d..8fab0144 100644 --- a/src/dictionaries/index.ts +++ b/src/dictionaries/index.ts @@ -1,3 +1,4 @@ +import { assign, cloneDeep, merge } from "lodash-es"; import "server-only"; export const defaultLocale = "zh-Hans"; @@ -32,10 +33,14 @@ export const getDictionary = async (locale: Locale = "zh-Hans") => { const zhHans = await dictionaries["zh-Hans"](); const result = await dictionaries[locale](); - return { - ...zhHans, - ...result, - }; + const targetLocale = cloneDeep(zhHans); + const keys = Object.keys(zhHans) as (keyof typeof zhHans)[]; + + for (const key of keys) { + // targetLocale[key] = result[key] || zhHans[key]; + } + + return merge(result, zhHans); }; export type Dictionary = Awaited>; diff --git a/src/dictionaries/ja.json b/src/dictionaries/ja.json index b3cb5620..a9f75dac 100644 --- a/src/dictionaries/ja.json +++ b/src/dictionaries/ja.json @@ -1,30 +1,6 @@ { "title": "中国の詩を学ぶウェブサイト", "description": "aspoem.comは中国の詩学習ウェブサイトであり、包括的なサイト検索機能を提供しています。規範詩、四行詩、さまざまな詩人の作品を素早く検索することができます。また、拼音注釈、注釈、口語中国語の表示を最適化し、詩を読みやすくしています。さらに、古代詩の学習をサポートする詩の印刷ツールも提供しています。ぜひ、当ウェブサイトの魅力を体験してください!", - "point_keywords": [ - "詩学習", - "古詩学習", - "唐詩300首", - "宋詞300首", - "李白詩集", - "杜甫詩集" - ], - "keywords": [ - "詩学習", - "古詩学習", - "唐詩300首", - "宋詞300首", - "李白詩集", - "杜甫詩集", - "古詩", - "詩", - "詩人統計", - "詩検索", - "詩の拼音", - "詩の注釈", - "詩の翻訳", - "ピンイン" - ], "menu": { "poem": "詩", "author": "詩人", diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index 4c2324dc..359a18f2 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -1,30 +1,5 @@ { "title": "중국 시 학습 웹사이트", - "description": "aspoem.com은 다양한 시인의 정규 시, 사백곡 및 작품을 빠르게 검색할 수 있는 포괄적인 사이트 검색 기능을 제공하는 중국 시 학습 웹사이트입니다. 또한, 우리는 발음 주석, 주석 및 구어 중국어의 표시를 최적화하여 시를 더 쉽게 읽을 수 있도록 하였습니다. 게다가, 고대 시를 더 잘 공부할 수 있도록 도와주는 시 인쇄 도구도 제공합니다. 저희 웹사이트의 매력을 경험해보세요!", - "point_keywords": [ - "시 학습", - "고대 시 학습", - "당시 삼백곡", - "송시 삼백곡", - "이백 시 전집", - "두풀 시 전집" - ], - "keywords": [ - "시 학습", - "고대 시 학습", - "당시 삼백곡", - "송시 삼백곡", - "이백 시 전집", - "두풀 시 전집", - "고대 시", - "시", - "시인 통계", - "시 검색", - "시 발음", - "시 주석", - "시 번역", - "pinyin" - ], "menu": { "poem": "시", "author": "시인", diff --git a/src/dictionaries/zh-Hans.json b/src/dictionaries/zh-Hans.json index 2cdd2bcb..a9f9f41f 100644 --- a/src/dictionaries/zh-Hans.json +++ b/src/dictionaries/zh-Hans.json @@ -1,30 +1,6 @@ { "title": "现代化诗词学习网站", "description": "aspoem.com 是现代化的诗词学习网站,提供全站搜索,提供便捷的全站搜索功能,让您更快地查询律诗、绝句和各位诗人的作品。我们还优化了拼音标注、注释和白话文等的展示方式,使诗词更加易于阅读。此外,我们还提供了诗词打印工具,助您更好地学习古代诗词。快来体验我们网站的魅力吧!", - "point_keywords": [ - "诗词学习", - "学习古诗词", - "唐诗三百首", - "宋词三百首", - "李白诗词全集", - "杜甫诗词全集" - ], - "keywords": [ - "诗词学习", - "学习古诗词", - "唐诗三百首", - "宋词三百首", - "李白诗词全集", - "杜甫诗词全集", - "古诗", - "诗词", - "诗人统计", - "诗词搜索", - "诗词拼音", - "诗词注释", - "诗词翻译", - "pinyin" - ], "menu": { "poem": "诗词", "author": "诗人", diff --git a/src/dictionaries/zh-Hant.json b/src/dictionaries/zh-Hant.json index 098a1d0f..a77bfc2a 100644 --- a/src/dictionaries/zh-Hant.json +++ b/src/dictionaries/zh-Hant.json @@ -1,30 +1,6 @@ { "title": "現代化詩詞學習網站", "description": "aspoem.com 是現代化的詩詞學習網站,提供全站搜索,提供便捷的全站搜索功能,讓您更快地查詢律詩、絕句和各位詩人的作品。我們還優化了拼音標註、注釋和白話文等的展示方式,使詩詞更加易於閱讀。此外,我們還提供了詩詞打印工具,助您更好地學習古代詩詞。快來體驗我們網站的魅力吧!", - "point_keywords": [ - "詩詞學習", - "學習古詩詞", - "唐詩三百首", - "宋詞三百首", - "李白詩詞全集", - "杜甫詩詞全集" - ], - "keywords": [ - "詩詞學習", - "學習古詩詞", - "唐詩三百首", - "宋詞三百首", - "李白詩詞全集", - "杜甫詩詞全集", - "詩詞", - "古詩", - "詩人統計", - "詩詞搜索", - "詩詞拼音", - "詩詞注釋", - "詩詞翻譯", - "pinyin" - ], "menu": { "poem": "詩詞", "author": "詩人", From 542f5361f9fdbb71848db715e1da30c2dcfdba48 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 15:03:14 +0800 Subject: [PATCH 7/8] rm keywords --- src/app/[lang]/layout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/[lang]/layout.tsx b/src/app/[lang]/layout.tsx index d670c442..0c70010c 100644 --- a/src/app/[lang]/layout.tsx +++ b/src/app/[lang]/layout.tsx @@ -31,7 +31,6 @@ export async function generateMetadata({ description: dict.description, icons: [{ rel: "icon", url: "/favicon.ico" }], alternates: getMetaDataAlternates("/", params.lang), - keywords: dict.keywords, metadataBase: new URL(MyHost), twitter: { site: `${MyHost}/${params.lang}`, From cda3450a25a9faf57e320791bc85fc73c76f0934 Mon Sep 17 00:00:00 2001 From: meetqy Date: Fri, 5 Apr 2024 15:22:50 +0800 Subject: [PATCH 8/8] lang --- src/dictionaries/index.ts | 30 ++++++++++++++++++++---------- src/dictionaries/ko.json | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/dictionaries/index.ts b/src/dictionaries/index.ts index 8fab0144..07f635f0 100644 --- a/src/dictionaries/index.ts +++ b/src/dictionaries/index.ts @@ -1,4 +1,3 @@ -import { assign, cloneDeep, merge } from "lodash-es"; import "server-only"; export const defaultLocale = "zh-Hans"; @@ -29,18 +28,29 @@ export const getMetaDataAlternates = (suffix: string, lang: Locale) => { }; }; -export const getDictionary = async (locale: Locale = "zh-Hans") => { - const zhHans = await dictionaries["zh-Hans"](); - const result = await dictionaries[locale](); +const defaultsConfig = ( + de: Record, + target: Record, +) => { + for (const key in de) { + if (target[key] === undefined) { + target[key] = de[key]; + } else if (typeof de[key] === "object") { + defaultsConfig( + de[key] as Record, + target[key] as Record, + ); + } + } - const targetLocale = cloneDeep(zhHans); - const keys = Object.keys(zhHans) as (keyof typeof zhHans)[]; + return target; +}; - for (const key of keys) { - // targetLocale[key] = result[key] || zhHans[key]; - } +export const getDictionary = async (locale: Locale = "zh-Hans") => { + const zhHans = await dictionaries["zh-Hans"](); + const targetLocale = await dictionaries[locale](); - return merge(result, zhHans); + return defaultsConfig(zhHans, targetLocale) as typeof zhHans; }; export type Dictionary = Awaited>; diff --git a/src/dictionaries/ko.json b/src/dictionaries/ko.json index 359a18f2..4d9a2390 100644 --- a/src/dictionaries/ko.json +++ b/src/dictionaries/ko.json @@ -1,5 +1,6 @@ { "title": "중국 시 학습 웹사이트", + "description": "aspoem.com은 다양한 시인들의 정규 시, 사파, 그리고 작품을 빠르게 검색할 수 있는 포괄적인 사이트 검색 기능을 제공하는 중국 시 학습 웹사이트입니다. 또한, 우리는 발음 주석, 주석, 그리고 구어 중국어의 표시를 최적화하여 시를 더 쉽게 읽을 수 있도록 하였습니다. 게다가, 고전 시를 더 잘 공부할 수 있도록 도와주는 시 인쇄 도구도 제공합니다. 저희 웹사이트의 매력을 경험해보세요!", "menu": { "poem": "시", "author": "시인",