From 7ddb50fb7b0aab8f015ff5fcd159a2983e6650eb Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 18 May 2024 14:24:02 +0800 Subject: [PATCH] feat: rename twitter --- src/browser/app/editor/editor.component.html | 2 +- src/server/dtos/repo-info.dto.ts | 6 +++--- src/shared/markdown/md-parser.ts | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/browser/app/editor/editor.component.html b/src/browser/app/editor/editor.component.html index cc7b11c7..474bf2ce 100644 --- a/src/browser/app/editor/editor.component.html +++ b/src/browser/app/editor/editor.component.html @@ -239,7 +239,7 @@ 输入标签的相关链接,如指向{{ ((inputs.namespace | async) || (original.namespace | async)) === 'artist' - ? '画师的微博、pixiv、Twitter 或个人主页' + ? '画师的微博、pixiv、X 或个人主页' : ((inputs.namespace | async) || (original.namespace | async)) === 'group' ? '社团或公司的官方网站' : ((inputs.namespace | async) || (original.namespace | async)) === 'parody' diff --git a/src/server/dtos/repo-info.dto.ts b/src/server/dtos/repo-info.dto.ts index c529754a..50c3c3d5 100644 --- a/src/server/dtos/repo-info.dto.ts +++ b/src/server/dtos/repo-info.dto.ts @@ -314,7 +314,7 @@ export class RepoInfoDto implements RepoInfo { raw: 'twinbox', name: 'TwinBox', intro: '「TwinBox」是`hanahanamaki`和`sousouman`共同的同人社团名称,同时也是商业活动的笔名。\n', - links: '[Twitter](https://twitter.com/digimon215) [pixiv](https://www.pixiv.net/users/264932) [微博](https://weibo.com/u/5189316437) [官方网站](https://www.twinbox-tb.com)\n', + links: '[X](https://x.com/digimon215) [pixiv](https://www.pixiv.net/users/264932) [微博](https://weibo.com/u/5189316437) [官方网站](https://www.twinbox-tb.com)\n', }, }, count: 12406, @@ -337,7 +337,7 @@ export class RepoInfoDto implements RepoInfo { raw: 'oouso', name: '大嘘', intro: '![大嘘头像](https://tva1.sinaimg.cn/large/6c84b2d6gy1fjkes482gzj204q04qmxx.jpg)\n袜控,尻控,女子高中生(误)画家。\n', - links: '[Twitter](https://twitter.com/u_s_o) [pixiv](https://www.pixiv.net/users/457541)\n', + links: '[X](https://x.com/u_s_o) [pixiv](https://www.pixiv.net/users/457541)\n', }, }, count: 12072, @@ -360,7 +360,7 @@ export class RepoInfoDto implements RepoInfo { raw: 'sayako', name: 'さやこ', intro: '', - links: '[Twitter](https://twitter.com/sayako_cos)', + links: '[X](https://x.com/sayako_cos)', }, }, count: 49, diff --git a/src/shared/markdown/md-parser.ts b/src/shared/markdown/md-parser.ts index 51aa937e..605892c1 100644 --- a/src/shared/markdown/md-parser.ts +++ b/src/shared/markdown/md-parser.ts @@ -60,7 +60,7 @@ function normalizeUrl(url: string): { return { url, nsfw: eh.groups['domain'].includes('exhentai') ? 'R18' : undefined }; } - for (const [reg, rep] of konwnPermlinks) { + for (const [reg, rep] of knownPermalinks) { url = url.replace(reg, rep); } return { url }; @@ -81,7 +81,7 @@ const knownHosts = new Map([ ['bilibili.com', '哔哩哔哩'], ['youtube.com', 'YouTube'], ['weibo.com', '微博'], - ['twitter.com', 'Twitter'], + ['x.com', 'X'], ['instagram.com', 'Instagram'], ['facebook.com', '脸书'], ['tumblr.com', 'Tumblr'], @@ -98,7 +98,9 @@ const knownHosts = new Map([ ['dlsite.com', 'DLsite'], ]); -const konwnPermlinks: ReadonlyArray<[RegExp, string]> = [ +const knownPermalinks: ReadonlyArray<[RegExp, string]> = [ + // twitter 的 ** 新名字 + [/^(http|https):\/\/twitter.com\/(?.+)$/, 'https://x.com/$'], // pixiv 图片使用反代 [/^(http|https):\/\/i\.pximg\.net\/(?.+)$/, 'https://i.pixiv.cat/$'], // wikipedia 手机版使用桌面版