From a8e2362f3bd97ba89c63af4eb827f0780722c985 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 22 Jul 2023 16:55:36 +0100 Subject: [PATCH] feat: simpler topic names --- data/topics.json | 9 +++-- src/components/site/SiteHeader.tsx | 2 +- src/lib/i18n/locales/zh-TW/index.json | 5 +-- src/lib/i18n/locales/zh/index.json | 5 +-- src/models/home.model.ts | 58 +++++++++++++++++---------- 5 files changed, 46 insertions(+), 33 deletions(-) diff --git a/data/topics.json b/data/topics.json index 845d94be..d3b6a54b 100644 --- a/data/topics.json +++ b/data/topics.json @@ -3,7 +3,8 @@ "name": "xLog", "description": "Let's talk about xLog, whether to praise or criticize it.", "includeTags": ["xLog"], - "includeKeywords": ["xLog"] + "includeKeywords": ["xLog"], + "excludeKeywords": ["同步更新至 xLog"] }, { "name": "Web3", @@ -27,15 +28,15 @@ ] }, { - "name": "Artificial Intelligence", + "name": "AI", "description": "The world is undergoing changes, and we are at the center of it.", "includeTags": ["AI"], "includeKeywords": ["GPT", "Midjourney", "AIGC", " AI ", "OpenAI"] }, { - "name": "Life Journal", + "name": "Journal", "description": "Discover new perspectives and insights in others' weekly, monthly, or yearly journal.", - "includeTags": ["Life", "生活"], + "includeTags": ["Journal", "日记"], "includeKeywords": [ "Review", "Weekly", diff --git a/src/components/site/SiteHeader.tsx b/src/components/site/SiteHeader.tsx index a95ad4c2..f3f19015 100644 --- a/src/components/site/SiteHeader.tsx +++ b/src/components/site/SiteHeader.tsx @@ -126,7 +126,7 @@ export const SiteHeader = async ({ {!hideNavigation && (
-
+
{leftLinks.map((link, i) => { return })} diff --git a/src/lib/i18n/locales/zh-TW/index.json b/src/lib/i18n/locales/zh-TW/index.json index 5e904393..65bca727 100644 --- a/src/lib/i18n/locales/zh-TW/index.json +++ b/src/lib/i18n/locales/zh-TW/index.json @@ -62,11 +62,10 @@ "Topic Keywords" : "關鍵字", "Topic Tags": "標籤", "Let's talk about xLog, whether to praise or criticize it." : "讚美與批評,推進著 xLog 的成長。", - "Artificial Intelligence": "人工智慧", "The world is undergoing changes, and we are at the center of it.": "世界正在變革,我們站在時代的風頭浪尖。", - "Life Journal": "生活隨筆", + "Life Journal": "日誌", "Discover new perspectives and insights in others' weekly, monthly, or yearly journal.": "分享你剛編的故事。", - "Fiction": "虛構小說", + "Fiction": "小說", "Experience a world of imagination through these fiction stories." : "年輕人的第一個虛擬世界。", "Coding": "Coding", "Participate in Topic": "加入話題" diff --git a/src/lib/i18n/locales/zh/index.json b/src/lib/i18n/locales/zh/index.json index 96fdb9fe..bc2dcb94 100644 --- a/src/lib/i18n/locales/zh/index.json +++ b/src/lib/i18n/locales/zh/index.json @@ -62,11 +62,10 @@ "Topic Keywords": "话题关键词", "Topic Tags": "话题标签", "Let's talk about xLog, whether to praise or criticize it.": "让我们来谈谈 xLog,无论赞美和批评。", - "Artificial Intelligence": "人工智能", "The world is undergoing changes, and we are at the center of it.": "世界正在发生变革,而我们正处其中心。", - "Life Journal": "生活日记", + "Journal": "日记", "Discover new perspectives and insights in others' weekly, monthly, or yearly journal.": "在别人的周月年记中发现新观点和见解。", - "Fiction": "虚构小说", + "Fiction": "小说", "Experience a world of imagination through these fiction stories.": "体验一个充满想象力的虚构世界。", "Coding": "编程", "Podcast": "播客", diff --git a/src/models/home.model.ts b/src/models/home.model.ts index 9c9a28fc..6804e251 100644 --- a/src/models/home.model.ts +++ b/src/models/home.model.ts @@ -308,17 +308,20 @@ export async function getFeed({ equals: false, }, metadata: { - AND: [{ - content: { - path: "sources", - array_contains: "xlog" + AND: [ + { + content: { + path: "sources", + array_contains: "xlog" + }, }, - }, { - content: { - path: "tags", - array_contains: "post" + { + content: { + path: "tags", + array_contains: "post" + } } - }] + ] }, OR: [ { @@ -370,6 +373,12 @@ export async function getFeed({ count: list?.length || 0, } } else { + const excludeString = [ + ...(info.excludeKeywords?.map( + (topicExcludeKeyword) => + `{ NOT: { content: { path: "content", string_contains: "${topicExcludeKeyword}" } } },`, + ) || []), + ].join("\n") const result = await client .query( gql` @@ -383,21 +392,26 @@ export async function getFeed({ equals: false, }, metadata: { - AND: [{ - content: { - path: "sources", - array_contains: "xlog" + AND: [ + { + content: { + path: "sources", + array_contains: "xlog" + }, }, - }, { - content: { - path: "tags", - array_contains: "post" + { + content: { + path: "tags", + array_contains: "post" + } + }, + ${excludeString}, + { + OR: [ + ${includeString} + ] } - }, { - OR: [ - ${includeString} - ] - }] + ] }, }, orderBy: [{ createdAt: desc }],