From 1c9526f4b5da5cbe87df47eb5663922f16fbfc12 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 8 Apr 2024 16:01:41 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=88=9D=E7=89=88=EF=BC=8C=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?static=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 202 +++++++++++++++++--------- lib/db/getSiteData.js | 88 +++++++---- lib/lang.js | 26 ++-- lib/notion/mapImage.js | 36 +++-- lib/utils/pageId.js | 33 +++++ next.config.js | 82 +++++++++-- pages/404.js | 17 ++- pages/[prefix]/[slug]/[...suffix].js | 34 ++++- pages/[prefix]/[slug]/index.js | 29 +++- pages/[prefix]/index.js | 34 ++++- pages/archive/index.js | 23 +-- pages/category/[category]/index.js | 17 ++- pages/category/index.js | 16 +- pages/index.js | 5 +- pages/page/[page].js | 24 ++- pages/search/[keyword]/index.js | 24 ++- pages/search/[keyword]/page/[page].js | 30 +++- pages/search/index.js | 21 ++- pages/signin.js | 17 ++- pages/signup.js | 17 ++- pages/tag/[tag]/index.js | 9 +- pages/tag/[tag]/page/[page].js | 14 +- pages/tag/index.js | 17 ++- 23 files changed, 585 insertions(+), 230 deletions(-) create mode 100644 lib/utils/pageId.js diff --git a/blog.config.js b/blog.config.js index df30298b..abfc4cd2 100644 --- a/blog.config.js +++ b/blog.config.js @@ -1,7 +1,9 @@ // 注: process.env.XX是Vercel的环境变量,配置方式见:https://docs.tangly1024.com/article/how-to-config-notion-next#c4768010ae7d44609b744e79e2f9959a const BLOG = { // Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5 - NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', + NOTION_PAGE_ID: + process.env.NOTION_PAGE_ID || + '02ab3b8678004aa69e9e415905ef32a5,en:7c1d570661754c8fbc568e00a01fd70e', PSEUDO_STATIC: process.env.NEXT_PUBLIC_PSEUDO_STATIC || false, // 伪静态路径,开启后所有文章URL都以 .html 结尾。 NEXT_REVALIDATE_SECOND: process.env.NEXT_PUBLIC_REVALIDATE_SECOND || 5, // 更新内容缓存间隔 单位(秒);即每个页面有5秒的纯静态期、此期间无论多少次访问都不会抓取notion数据;调大该值有助于节省Vercel资源、同时提升访问速率,但也会使文章更新有延迟。 THEME: process.env.NEXT_PUBLIC_THEME || 'simple', // 当前主题,在themes文件夹下可找到所有支持的主题;主题名称就是文件夹名,例如 example,fukasawa,gitbook,heo,hexo,landing,matery,medium,next,nobelium,plog,simple @@ -11,7 +13,8 @@ const BLOG = { APPEARANCE: process.env.NEXT_PUBLIC_APPEARANCE || 'light', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式 APPEARANCE_DARK_TIME: process.env.NEXT_PUBLIC_APPEARANCE_DARK_TIME || [18, 6], // 夜间模式起至时间,false时关闭根据时间自动切换夜间模式 - IS_TAG_COLOR_DISTINGUISHED: process.env.NEXT_PUBLIC_IS_TAG_COLOR_DISTINGUISHED === 'true' || true, // 对于名称相同的tag是否区分tag的颜色 + IS_TAG_COLOR_DISTINGUISHED: + process.env.NEXT_PUBLIC_IS_TAG_COLOR_DISTINGUISHED === 'true' || true, // 对于名称相同的tag是否区分tag的颜色 // 3.14.1版本后,欢迎语在此配置,英文逗号隔开 , 即可支持多个欢迎语打字效果。 GREETING_WORDS: @@ -43,7 +46,9 @@ const BLOG = { IMAGE_COMPRESS_WIDTH: process.env.NEXT_PUBLIC_IMAGE_COMPRESS_WIDTH || 800, // 图片压缩宽度默认值,作用于博客封面和文章内容 越小加载图片越快 IMAGE_ZOOM_IN_WIDTH: process.env.NEXT_PUBLIC_IMAGE_ZOOM_IN_WIDTH || 1200, // 文章图片点击放大后的画质宽度,不代表在网页中的实际展示宽度 RANDOM_IMAGE_URL: process.env.NEXT_PUBLIC_RANDOM_IMAGE_URL || '', // 随机图片API,如果未配置下面的关键字,主页封面,头像,文章封面图都会被替换为随机图片 - RANDOM_IMAGE_REPLACE_TEXT: process.env.NEXT_PUBLIC_RANDOM_IMAGE_NOT_REPLACE_TEXT || 'images.unsplash.com', // 触发替换图片的 url 关键字(多个支持用英文逗号分开),只有图片地址中包含此关键字才会替换为上方随机图片url + RANDOM_IMAGE_REPLACE_TEXT: + process.env.NEXT_PUBLIC_RANDOM_IMAGE_NOT_REPLACE_TEXT || + 'images.unsplash.com', // 触发替换图片的 url 关键字(多个支持用英文逗号分开),只有图片地址中包含此关键字才会替换为上方随机图片url // eg: images.unsplash.com(notion图床的所有图片都会替换),如果你在 notion 里已经添加了一个随机图片 url,恰巧那个服务跑路或者挂掉,想一键切换所有配图可以将该 url 配置在这里 // 默认下会将你上传到 notion的主页封面图和头像也给替换,建议将主页封面图和头像放在其他图床,在 notion 里配置 link 即可。 @@ -122,23 +127,29 @@ const BLOG = { CAN_COPY: process.env.NEXT_PUBLIC_CAN_COPY || true, // 是否允许复制页面内容 默认允许,如果设置为false、则全栈禁止复制内容。 // 自定义右键菜单 - CUSTOM_RIGHT_CLICK_CONTEXT_MENU: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU || true, // 自定义右键菜单,覆盖系统菜单 + CUSTOM_RIGHT_CLICK_CONTEXT_MENU: + process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU || true, // 自定义右键菜单,覆盖系统菜单 CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH: - process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH || true, // 是否显示切换主题 - CUSTOM_RIGHT_CLICK_CONTEXT_MENU_DARK_MODE: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_DARK_MODE || true, // 是否显示深色模式 + process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH || + true, // 是否显示切换主题 + CUSTOM_RIGHT_CLICK_CONTEXT_MENU_DARK_MODE: + process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_DARK_MODE || true, // 是否显示深色模式 CUSTOM_RIGHT_CLICK_CONTEXT_MENU_SHARE_LINK: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_SHARE_LINK || true, // 是否显示分享链接 CUSTOM_RIGHT_CLICK_CONTEXT_MENU_RANDOM_POST: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_RANDOM_POST || true, // 是否显示随机博客 - CUSTOM_RIGHT_CLICK_CONTEXT_MENU_CATEGORY: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_CATEGORY || true, // 是否显示分类 - CUSTOM_RIGHT_CLICK_CONTEXT_MENU_TAG: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_TAG || true, // 是否显示标签 + CUSTOM_RIGHT_CLICK_CONTEXT_MENU_CATEGORY: + process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_CATEGORY || true, // 是否显示分类 + CUSTOM_RIGHT_CLICK_CONTEXT_MENU_TAG: + process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_TAG || true, // 是否显示标签 // 自定义外部脚本,外部样式 CUSTOM_EXTERNAL_JS: [''], // e.g. ['http://xx.com/script.js','http://xx.com/script.js'] CUSTOM_EXTERNAL_CSS: [''], // e.g. ['http://xx.com/style.css','http://xx.com/style.css'] // 侧栏布局 是否反转(左变右,右变左) 已支持主题: hexo next medium fukasawa example - LAYOUT_SIDEBAR_REVERSE: process.env.NEXT_PUBLIC_LAYOUT_SIDEBAR_REVERSE || false, + LAYOUT_SIDEBAR_REVERSE: + process.env.NEXT_PUBLIC_LAYOUT_SIDEBAR_REVERSE || false, // 一个小插件展示你的facebook fan page~ @see https://tw.andys.pro/article/add-facebook-fanpage-notionnext FACEBOOK_PAGE_TITLE: process.env.NEXT_PUBLIC_FACEBOOK_PAGE_TITLE || null, // 邊欄 Facebook Page widget 的標題欄,填''則無標題欄 e.g FACEBOOK 粉絲團' @@ -151,7 +162,8 @@ const BLOG = { // START********代码相关******** // PrismJs 代码相关 PRISM_JS_PATH: 'https://npm.elemecdn.com/prismjs@1.29.0/components/', - PRISM_JS_AUTO_LOADER: 'https://npm.elemecdn.com/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js', + PRISM_JS_AUTO_LOADER: + 'https://npm.elemecdn.com/prismjs@1.29.0/plugins/autoloader/prism-autoloader.min.js', // 代码主题 @see https://github.com/PrismJS/prism-themes PRISM_THEME_PREFIX_PATH: @@ -168,16 +180,19 @@ const BLOG = { CODE_MAC_BAR: process.env.NEXT_PUBLIC_CODE_MAC_BAR || true, // 代码左上角显示mac的红黄绿图标 CODE_LINE_NUMBERS: process.env.NEXT_PUBLIC_CODE_LINE_NUMBERS || false, // 是否显示行号 CODE_COLLAPSE: process.env.NEXT_PUBLIC_CODE_COLLAPSE || true, // 是否支持折叠代码框 - CODE_COLLAPSE_EXPAND_DEFAULT: process.env.NEXT_PUBLIC_CODE_COLLAPSE_EXPAND_DEFAULT || true, // 折叠代码默认是展开状态 + CODE_COLLAPSE_EXPAND_DEFAULT: + process.env.NEXT_PUBLIC_CODE_COLLAPSE_EXPAND_DEFAULT || true, // 折叠代码默认是展开状态 // END********代码相关******** // Mermaid 图表CDN MERMAID_CDN: - process.env.NEXT_PUBLIC_MERMAID_CDN || 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.2.4/mermaid.min.js', // CDN + process.env.NEXT_PUBLIC_MERMAID_CDN || + 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.2.4/mermaid.min.js', // CDN // QRCodeCDN QR_CODE_CDN: - process.env.NEXT_PUBLIC_QR_CODE_CDN || 'https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js', + process.env.NEXT_PUBLIC_QR_CODE_CDN || + 'https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js', BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc BACKGROUND_DARK: '#000000', // use hex value, don't forget '#' @@ -202,24 +217,32 @@ const BLOG = { POSTS_PER_PAGE: process.env.NEXT_PUBLIC_POST_PER_PAGE || 12, // post counts per page POSTS_SORT_BY: process.env.NEXT_PUBLIC_POST_SORT_BY || 'notion', // 排序方式 'date'按时间,'notion'由notion控制 - POST_WAITING_TIME_FOR_404: process.env.NEXT_PUBLIC_POST_WAITING_TIME_FOR_404 || '8', // 文章加载超时时间,单位秒;超时后跳转到404页面 + POST_WAITING_TIME_FOR_404: + process.env.NEXT_PUBLIC_POST_WAITING_TIME_FOR_404 || '8', // 文章加载超时时间,单位秒;超时后跳转到404页面 ALGOLIA_APP_ID: process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || null, // 在这里查看 https://dashboard.algolia.com/account/api-keys/ ALGOLIA_ADMIN_APP_KEY: process.env.ALGOLIA_ADMIN_APP_KEY || null, // 管理后台的KEY,不要暴露在代码中,在这里查看 https://dashboard.algolia.com/account/api-keys/ - ALGOLIA_SEARCH_ONLY_APP_KEY: process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY || null, // 客户端搜索用的KEY + ALGOLIA_SEARCH_ONLY_APP_KEY: + process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY || null, // 客户端搜索用的KEY ALGOLIA_INDEX: process.env.NEXT_PUBLIC_ALGOLIA_INDEX || null, // 在Algolia中创建一个index用作数据库 // ALGOLIA_RECREATE_DATA: process.env.ALGOLIA_RECREATE_DATA || process.env.npm_lifecycle_event === 'build', // 为true时重新构建索引数据; 默认在build时会构建 PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制 PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制 - POST_DISABLE_GALLERY_CLICK: process.env.NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK || false, // 画册视图禁止点击,方便在友链页面的画册插入链接 + POST_DISABLE_GALLERY_CLICK: + process.env.NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK || false, // 画册视图禁止点击,方便在友链页面的画册插入链接 // ********动态特效相关******** // 鼠标点击烟花特效 FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关 // 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩 - FIREWORKS_COLOR: ['255, 20, 97', '24, 255, 146', '90, 135, 255', '251, 243, 140'], + FIREWORKS_COLOR: [ + '255, 20, 97', + '24, 255, 146', + '90, 135, 255', + '251, 243, 140' + ], // 樱花飘落特效 SAKURA: process.env.NEXT_PUBLIC_SAKURA || false, // 开关 @@ -238,14 +261,16 @@ const BLOG = { process.env.NEXT_PUBLIC_TIANLI_GPT_CSS || 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.15.2/tianli_gpt.css', TianliGPT_JS: - process.env.NEXT_PUBLIC_TIANLI_GPT_JS || 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.15.2/tianli_gpt.js', + process.env.NEXT_PUBLIC_TIANLI_GPT_JS || + 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.15.2/tianli_gpt.js', TianliGPT_KEY: process.env.NEXT_PUBLIC_TIANLI_GPT_KEY || '', // Chatbase 是否显示chatbase机器人 https://www.chatbase.co/ CHATBASE_ID: process.env.NEXT_PUBLIC_CHATBASE_ID || null, // WebwhizAI 机器人 @see https://github.com/webwhiz-ai/webwhiz WEB_WHIZ_ENABLED: process.env.NEXT_PUBLIC_WEB_WHIZ_ENABLED || false, // 是否显示 - WEB_WHIZ_BASE_URL: process.env.NEXT_PUBLIC_WEB_WHIZ_BASE_URL || 'https://api.webwhiz.ai', // 可以自建服务器 + WEB_WHIZ_BASE_URL: + process.env.NEXT_PUBLIC_WEB_WHIZ_BASE_URL || 'https://api.webwhiz.ai', // 可以自建服务器 WEB_WHIZ_CHAT_BOT_ID: process.env.NEXT_PUBLIC_WEB_WHIZ_CHAT_BOT_ID || null, // 在后台获取ID DIFY_CHATBOT_ENABLED: process.env.NEXT_PUBLIC_DIFY_CHATBOT_ENABLED || false, DIFY_CHATBOT_BASE_URL: process.env.NEXT_PUBLIC_DIFY_CHATBOT_BASE_URL || '', @@ -255,12 +280,14 @@ const BLOG = { WIDGET_PET_LINK: process.env.NEXT_PUBLIC_WIDGET_PET_LINK || 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models - WIDGET_PET_SWITCH_THEME: process.env.NEXT_PUBLIC_WIDGET_PET_SWITCH_THEME || true, // 点击宠物挂件切换博客主题 + WIDGET_PET_SWITCH_THEME: + process.env.NEXT_PUBLIC_WIDGET_PET_SWITCH_THEME || true, // 点击宠物挂件切换博客主题 // 音乐播放插件 MUSIC_PLAYER: process.env.NEXT_PUBLIC_MUSIC_PLAYER || false, // 是否使用音乐播放插件 MUSIC_PLAYER_VISIBLE: process.env.NEXT_PUBLIC_MUSIC_PLAYER_VISIBLE || true, // 是否在左下角显示播放和切换,如果使用播放器,打开自动播放再隐藏,就会以类似背景音乐的方式播放,无法取消和暂停 - MUSIC_PLAYER_AUTO_PLAY: process.env.NEXT_PUBLIC_MUSIC_PLAYER_AUTO_PLAY || true, // 是否自动播放,不过自动播放时常不生效(移动设备不支持自动播放) + MUSIC_PLAYER_AUTO_PLAY: + process.env.NEXT_PUBLIC_MUSIC_PLAYER_AUTO_PLAY || true, // 是否自动播放,不过自动播放时常不生效(移动设备不支持自动播放) MUSIC_PLAYER_LRC_TYPE: process.env.NEXT_PUBLIC_MUSIC_PLAYER_LRC_TYPE || '0', // 歌词显示类型,可选值: 3 | 1 | 0(0:禁用 lrc 歌词,1:lrc 格式的字符串,3:lrc 文件 url)(前提是有配置歌词路径,对 meting 无效) MUSIC_PLAYER_CDN_URL: process.env.NEXT_PUBLIC_MUSIC_PLAYER_CDN_URL || @@ -272,78 +299,105 @@ const BLOG = { name: '风を共に舞う気持ち', artist: 'Falcom Sound Team jdk', url: 'https://music.163.com/song/media/outer/url?id=731419.mp3', - cover: 'https://p2.music.126.net/kn6ugISTonvqJh3LHLaPtQ==/599233837187278.jpg' + cover: + 'https://p2.music.126.net/kn6ugISTonvqJh3LHLaPtQ==/599233837187278.jpg' }, { name: '王都グランセル', artist: 'Falcom Sound Team jdk', url: 'https://music.163.com/song/media/outer/url?id=731355.mp3', - cover: 'https://p1.music.126.net/kn6ugISTonvqJh3LHLaPtQ==/599233837187278.jpg' + cover: + 'https://p1.music.126.net/kn6ugISTonvqJh3LHLaPtQ==/599233837187278.jpg' } ], MUSIC_PLAYER_METING: process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING || false, // 是否要开启 MetingJS,从平台获取歌单。会覆盖自定义的 MUSIC_PLAYER_AUDIO_LIST,更多配置信息:https://github.com/metowolf/MetingJS - MUSIC_PLAYER_METING_SERVER: process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_SERVER || 'netease', // 音乐平台,[netease, tencent, kugou, xiami, baidu] - MUSIC_PLAYER_METING_ID: process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_ID || '60198', // 对应歌单的 id - MUSIC_PLAYER_METING_LRC_TYPE: process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_LRC_TYPE || '1', // 可选值: 3 | 1 | 0(0:禁用 lrc 歌词,1:lrc 格式的字符串,3:lrc 文件 url) + MUSIC_PLAYER_METING_SERVER: + process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_SERVER || 'netease', // 音乐平台,[netease, tencent, kugou, xiami, baidu] + MUSIC_PLAYER_METING_ID: + process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_ID || '60198', // 对应歌单的 id + MUSIC_PLAYER_METING_LRC_TYPE: + process.env.NEXT_PUBLIC_MUSIC_PLAYER_METING_LRC_TYPE || '1', // 可选值: 3 | 1 | 0(0:禁用 lrc 歌词,1:lrc 格式的字符串,3:lrc 文件 url) // ********挂件组件相关******** // ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK - COMMENT_HIDE_SINGLE_TAB: process.env.NEXT_PUBLIC_COMMENT_HIDE_SINGLE_TAB || false, // Whether hide the tab when there's no tabs. 只有一个评论组件时是否隐藏切换组件的标签页 + COMMENT_HIDE_SINGLE_TAB: + process.env.NEXT_PUBLIC_COMMENT_HIDE_SINGLE_TAB || false, // Whether hide the tab when there's no tabs. 只有一个评论组件时是否隐藏切换组件的标签页 // artalk 评论插件 COMMENT_ARTALK_SERVER: process.env.NEXT_PUBLIC_COMMENT_ARTALK_SERVER || '', // ArtalkServert后端地址 https://artalk.js.org/guide/deploy.html COMMENT_ARTALK_JS: - process.env.NEXT_PUBLIC_COMMENT_ARTALK_JS || 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.js', // ArtalkServert js cdn + process.env.NEXT_PUBLIC_COMMENT_ARTALK_JS || + 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.js', // ArtalkServert js cdn COMMENT_ARTALK_CSS: - process.env.NEXT_PUBLIC_COMMENT_ARTALK_CSS || 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.css', // ArtalkServert css cdn + process.env.NEXT_PUBLIC_COMMENT_ARTALK_CSS || + 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.css', // ArtalkServert css cdn // twikoo COMMENT_TWIKOO_ENV_ID: process.env.NEXT_PUBLIC_COMMENT_ENV_ID || '', // TWIKOO后端地址 腾讯云环境填envId;Vercel环境填域名,教程:https://tangly1024.com/article/notionnext-twikoo - COMMENT_TWIKOO_COUNT_ENABLE: process.env.NEXT_PUBLIC_COMMENT_TWIKOO_COUNT_ENABLE || false, // 博客列表是否显示评论数 + COMMENT_TWIKOO_COUNT_ENABLE: + process.env.NEXT_PUBLIC_COMMENT_TWIKOO_COUNT_ENABLE || false, // 博客列表是否显示评论数 COMMENT_TWIKOO_CDN_URL: - process.env.NEXT_PUBLIC_COMMENT_TWIKOO_CDN_URL || 'https://cdn.staticfile.org/twikoo/1.6.17/twikoo.min.js', // twikoo客户端cdn + process.env.NEXT_PUBLIC_COMMENT_TWIKOO_CDN_URL || + 'https://cdn.staticfile.org/twikoo/1.6.17/twikoo.min.js', // twikoo客户端cdn // utterance - COMMENT_UTTERRANCES_REPO: process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext'; 更多文档参考 https://utteranc.es/ + COMMENT_UTTERRANCES_REPO: + process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext'; 更多文档参考 https://utteranc.es/ // giscus @see https://giscus.app/ COMMENT_GISCUS_REPO: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO || '', // 你的Github仓库名 e.g 'tangly1024/NotionNext' COMMENT_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO_ID || '', // 你的Github Repo ID e.g ( 設定完 giscus 即可看到 ) - COMMENT_GISCUS_CATEGORY_ID: process.env.NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID || '', // 你的Github Discussions 內的 Category ID ( 設定完 giscus 即可看到 ) - COMMENT_GISCUS_MAPPING: process.env.NEXT_PUBLIC_COMMENT_GISCUS_MAPPING || 'pathname', // 你的Github Discussions 使用哪種方式來標定文章, 預設 'pathname' - COMMENT_GISCUS_REACTIONS_ENABLED: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED || '1', // 你的 Giscus 是否開啟文章表情符號 '1' 開啟 "0" 關閉 預設開啟 - COMMENT_GISCUS_EMIT_METADATA: process.env.NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA || '0', // 你的 Giscus 是否提取 Metadata '1' 開啟 '0' 關閉 預設關閉 - COMMENT_GISCUS_INPUT_POSITION: process.env.NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION || 'bottom', // 你的 Giscus 發表留言位置 'bottom' 尾部 'top' 頂部, 預設 'bottom' + COMMENT_GISCUS_CATEGORY_ID: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID || '', // 你的Github Discussions 內的 Category ID ( 設定完 giscus 即可看到 ) + COMMENT_GISCUS_MAPPING: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_MAPPING || 'pathname', // 你的Github Discussions 使用哪種方式來標定文章, 預設 'pathname' + COMMENT_GISCUS_REACTIONS_ENABLED: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED || '1', // 你的 Giscus 是否開啟文章表情符號 '1' 開啟 "0" 關閉 預設開啟 + COMMENT_GISCUS_EMIT_METADATA: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA || '0', // 你的 Giscus 是否提取 Metadata '1' 開啟 '0' 關閉 預設關閉 + COMMENT_GISCUS_INPUT_POSITION: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION || 'bottom', // 你的 Giscus 發表留言位置 'bottom' 尾部 'top' 頂部, 預設 'bottom' COMMENT_GISCUS_LANG: process.env.NEXT_PUBLIC_COMMENT_GISCUS_LANG || 'zh-CN', // 你的 Giscus 語言 e.g 'en', 'zh-TW', 'zh-CN', 預設 'en' - COMMENT_GISCUS_LOADING: process.env.NEXT_PUBLIC_COMMENT_GISCUS_LOADING || 'lazy', // 你的 Giscus 載入是否漸進式載入, 預設 'lazy' - COMMENT_GISCUS_CROSSORIGIN: process.env.NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN || 'anonymous', // 你的 Giscus 可以跨網域, 預設 'anonymous' + COMMENT_GISCUS_LOADING: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_LOADING || 'lazy', // 你的 Giscus 載入是否漸進式載入, 預設 'lazy' + COMMENT_GISCUS_CROSSORIGIN: + process.env.NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN || 'anonymous', // 你的 Giscus 可以跨網域, 預設 'anonymous' COMMENT_CUSDIS_APP_ID: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID || '', // data-app-id 36位 see https://cusdis.com/ - COMMENT_CUSDIS_HOST: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_HOST || 'https://cusdis.com', // data-host, change this if you're using self-hosted version - COMMENT_CUSDIS_SCRIPT_SRC: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC || '/js/cusdis.es.js', // change this if you're using self-hosted version + COMMENT_CUSDIS_HOST: + process.env.NEXT_PUBLIC_COMMENT_CUSDIS_HOST || 'https://cusdis.com', // data-host, change this if you're using self-hosted version + COMMENT_CUSDIS_SCRIPT_SRC: + process.env.NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC || '/js/cusdis.es.js', // change this if you're using self-hosted version // gitalk评论插件 更多参考 https://gitalk.github.io/ COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名,例如 'NotionNext' COMMENT_GITALK_OWNER: process.env.NEXT_PUBLIC_COMMENT_GITALK_OWNER || '', // 你的用户名 e.g tangly1024 COMMENT_GITALK_ADMIN: process.env.NEXT_PUBLIC_COMMENT_GITALK_ADMIN || '', // 管理员用户名、一般是自己 e.g 'tangly1024' - COMMENT_GITALK_CLIENT_ID: process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID || '', // e.g 20位ID , 在gitalk后台获取 - COMMENT_GITALK_CLIENT_SECRET: process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET || '', // e.g 40位ID, 在gitalk后台获取 + COMMENT_GITALK_CLIENT_ID: + process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID || '', // e.g 20位ID , 在gitalk后台获取 + COMMENT_GITALK_CLIENT_SECRET: + process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET || '', // e.g 40位ID, 在gitalk后台获取 COMMENT_GITALK_DISTRACTION_FREE_MODE: false, // 类似facebook的无干扰模式 COMMENT_GITALK_JS_CDN_URL: - process.env.NEXT_PUBLIC_COMMENT_GITALK_JS_CDN_URL || 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', // gitalk客户端 js cdn + process.env.NEXT_PUBLIC_COMMENT_GITALK_JS_CDN_URL || + 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', // gitalk客户端 js cdn COMMENT_GITALK_CSS_CDN_URL: - process.env.NEXT_PUBLIC_COMMENT_GITALK_CSS_CDN_URL || 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css', // gitalk客户端 css cdn + process.env.NEXT_PUBLIC_COMMENT_GITALK_CSS_CDN_URL || + 'https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css', // gitalk客户端 css cdn COMMENT_GITTER_ROOM: process.env.NEXT_PUBLIC_COMMENT_GITTER_ROOM || '', // gitter聊天室 see https://gitter.im/ 不需要则留空 COMMENT_DAO_VOICE_ID: process.env.NEXT_PUBLIC_COMMENT_DAO_VOICE_ID || '', // DaoVoice http://dashboard.daovoice.io/get-started COMMENT_TIDIO_ID: process.env.NEXT_PUBLIC_COMMENT_TIDIO_ID || '', // [tidio_id] -> //code.tidio.co/[tidio_id].js - COMMENT_VALINE_CDN: process.env.NEXT_PUBLIC_VALINE_CDN || 'https://unpkg.com/valine@1.5.1/dist/Valine.min.js', + COMMENT_VALINE_CDN: + process.env.NEXT_PUBLIC_VALINE_CDN || + 'https://unpkg.com/valine@1.5.1/dist/Valine.min.js', COMMENT_VALINE_APP_ID: process.env.NEXT_PUBLIC_VALINE_ID || '', // Valine @see https://valine.js.org/quickstart.html 或 https://github.com/stonehank/react-valine#%E8%8E%B7%E5%8F%96app-id-%E5%92%8C-app-key COMMENT_VALINE_APP_KEY: process.env.NEXT_PUBLIC_VALINE_KEY || '', COMMENT_VALINE_SERVER_URLS: process.env.NEXT_PUBLIC_VALINE_SERVER_URLS || '', // 该配置适用于国内自定义域名用户, 海外版本会自动检测(无需手动填写) @see https://valine.js.org/configuration.html#serverURLs - COMMENT_VALINE_PLACEHOLDER: process.env.NEXT_PUBLIC_VALINE_PLACEHOLDER || '抢个沙发吧~', // 可以搭配后台管理评论 https://github.com/DesertsP/Valine-Admin 便于查看评论,以及邮件通知,垃圾评论过滤等功能 + COMMENT_VALINE_PLACEHOLDER: + process.env.NEXT_PUBLIC_VALINE_PLACEHOLDER || '抢个沙发吧~', // 可以搭配后台管理评论 https://github.com/DesertsP/Valine-Admin 便于查看评论,以及邮件通知,垃圾评论过滤等功能 COMMENT_WALINE_SERVER_URL: process.env.NEXT_PUBLIC_WALINE_SERVER_URL || '', // 请配置完整的Waline评论地址 例如 hhttps://preview-waline.tangly1024.com @see https://waline.js.org/guide/get-started.html COMMENT_WALINE_RECENT: process.env.NEXT_PUBLIC_WALINE_RECENT || false, // 最新评论 @@ -357,15 +411,18 @@ const BLOG = { // TOKEN: Webmention的API token COMMENT_WEBMENTION_ENABLE: process.env.NEXT_PUBLIC_WEBMENTION_ENABLE || false, COMMENT_WEBMENTION_AUTH: process.env.NEXT_PUBLIC_WEBMENTION_AUTH || '', - COMMENT_WEBMENTION_HOSTNAME: process.env.NEXT_PUBLIC_WEBMENTION_HOSTNAME || '', - COMMENT_WEBMENTION_TWITTER_USERNAME: process.env.NEXT_PUBLIC_TWITTER_USERNAME || '', + COMMENT_WEBMENTION_HOSTNAME: + process.env.NEXT_PUBLIC_WEBMENTION_HOSTNAME || '', + COMMENT_WEBMENTION_TWITTER_USERNAME: + process.env.NEXT_PUBLIC_TWITTER_USERNAME || '', COMMENT_WEBMENTION_TOKEN: process.env.NEXT_PUBLIC_WEBMENTION_TOKEN || '', // <---- 评论插件 // ----> 站点统计 ANALYTICS_VERCEL: process.env.NEXT_PUBLIC_ANALYTICS_VERCEL || false, // vercel自带的统计 https://vercel.com/docs/concepts/analytics/quickstart https://github.com/tangly1024/NotionNext/issues/897 - ANALYTICS_BUSUANZI_ENABLE: process.env.NEXT_PUBLIC_ANALYTICS_BUSUANZI_ENABLE || true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ + ANALYTICS_BUSUANZI_ENABLE: + process.env.NEXT_PUBLIC_ANALYTICS_BUSUANZI_ENABLE || true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ ANALYTICS_BAIDU_ID: process.env.NEXT_PUBLIC_ANALYTICS_BAIDU_ID || '', // e.g 只需要填写百度统计的id,[baidu_id] -> https://hm.baidu.com/hm.js?[baidu_id] ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id] ANALYTICS_GOOGLE_ID: process.env.NEXT_PUBLIC_ANALYTICS_GOOGLE_ID || '', // 谷歌Analytics的id e.g: G-XXXXXXXXXX @@ -378,13 +435,18 @@ const BLOG = { MATOMO_HOST_URL: process.env.NEXT_PUBLIC_MATOMO_HOST_URL || '', // Matomo服务器地址,不带斜杠 MATOMO_SITE_ID: process.env.NEXT_PUBLIC_MATOMO_SITE_ID || '', // Matomo网站ID // ACKEE网站访客统计工具 - ANALYTICS_ACKEE_TRACKER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER || '', // e.g 'https://ackee.tangly1024.com/tracker.js' - ANALYTICS_ACKEE_DATA_SERVER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER || '', // e.g https://ackee.tangly1024.com , don't end with a slash - ANALYTICS_ACKEE_DOMAIN_ID: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID || '', // e.g '82e51db6-dec2-423a-b7c9-b4ff7ebb3302' + ANALYTICS_ACKEE_TRACKER: + process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER || '', // e.g 'https://ackee.tangly1024.com/tracker.js' + ANALYTICS_ACKEE_DATA_SERVER: + process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER || '', // e.g https://ackee.tangly1024.com , don't end with a slash + ANALYTICS_ACKEE_DOMAIN_ID: + process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID || '', // e.g '82e51db6-dec2-423a-b7c9-b4ff7ebb3302' - SEO_GOOGLE_SITE_VERIFICATION: process.env.NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code + SEO_GOOGLE_SITE_VERIFICATION: + process.env.NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code - SEO_BAIDU_SITE_VERIFICATION: process.env.NEXT_PUBLIC_SEO_BAIDU_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code + SEO_BAIDU_SITE_VERIFICATION: + process.env.NEXT_PUBLIC_SEO_BAIDU_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code // 微软 Clarity 站点分析 CLARITY_ID: process.env.NEXT_PUBLIC_CLARITY_ID || null, // 只需要复制Clarity脚本中的ID部分,ID是一个十位的英文数字组合 @@ -396,10 +458,14 @@ const BLOG = { // 谷歌广告 ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx ADSENSE_GOOGLE_TEST: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_TEST || false, // 谷歌广告ID测试模式,这种模式获取假的测试广告,用于开发 https://www.tangly1024.com/article/local-dev-google-adsense - ADSENSE_GOOGLE_SLOT_IN_ARTICLE: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_IN_ARTICLE || '3806269138', // Google AdScene>广告>按单元广告>新建文章内嵌广告 粘贴html代码中的data-ad-slot值 - ADSENSE_GOOGLE_SLOT_FLOW: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_FLOW || '1510444138', // Google AdScene>广告>按单元广告>新建信息流广告 - ADSENSE_GOOGLE_SLOT_NATIVE: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_NATIVE || '4980048999', // Google AdScene>广告>按单元广告>新建原生广告 - ADSENSE_GOOGLE_SLOT_AUTO: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_AUTO || '8807314373', // Google AdScene>广告>按单元广告>新建展示广告 (自动广告) + ADSENSE_GOOGLE_SLOT_IN_ARTICLE: + process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_IN_ARTICLE || '3806269138', // Google AdScene>广告>按单元广告>新建文章内嵌广告 粘贴html代码中的data-ad-slot值 + ADSENSE_GOOGLE_SLOT_FLOW: + process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_FLOW || '1510444138', // Google AdScene>广告>按单元广告>新建信息流广告 + ADSENSE_GOOGLE_SLOT_NATIVE: + process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_NATIVE || '4980048999', // Google AdScene>广告>按单元广告>新建原生广告 + ADSENSE_GOOGLE_SLOT_AUTO: + process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_AUTO || '8807314373', // Google AdScene>广告>按单元广告>新建展示广告 (自动广告) // 万维广告 AD_WWADS_ID: process.env.NEXT_PUBLIC_WWAD_ID || null, // https://wwads.cn/ 创建您的万维广告单元ID @@ -413,13 +479,17 @@ const BLOG = { type: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE || 'type', // 文章类型, type_post: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_POST || 'Post', // 当type文章类型与此值相同时,为博文。 type_page: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_PAGE || 'Page', // 当type文章类型与此值相同时,为单页。 - type_notice: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_NOTICE || 'Notice', // 当type文章类型与此值相同时,为公告。 + type_notice: + process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_NOTICE || 'Notice', // 当type文章类型与此值相同时,为公告。 type_menu: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_MENU || 'Menu', // 当type文章类型与此值相同时,为菜单。 - type_sub_menu: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_SUB_MENU || 'SubMenu', // 当type文章类型与此值相同时,为子菜单。 + type_sub_menu: + process.env.NEXT_PUBLIC_NOTION_PROPERTY_TYPE_SUB_MENU || 'SubMenu', // 当type文章类型与此值相同时,为子菜单。 title: process.env.NEXT_PUBLIC_NOTION_PROPERTY_TITLE || 'title', // 文章标题 status: process.env.NEXT_PUBLIC_NOTION_PROPERTY_STATUS || 'status', - status_publish: process.env.NEXT_PUBLIC_NOTION_PROPERTY_STATUS_PUBLISH || 'Published', // 当status状态值与此相同时为发布,可以为中文 - status_invisible: process.env.NEXT_PUBLIC_NOTION_PROPERTY_STATUS_INVISIBLE || 'Invisible', // 当status状态值与此相同时为隐藏发布,可以为中文 , 除此之外其他页面状态不会显示在博客上 + status_publish: + process.env.NEXT_PUBLIC_NOTION_PROPERTY_STATUS_PUBLISH || 'Published', // 当status状态值与此相同时为发布,可以为中文 + status_invisible: + process.env.NEXT_PUBLIC_NOTION_PROPERTY_STATUS_INVISIBLE || 'Invisible', // 当status状态值与此相同时为隐藏发布,可以为中文 , 除此之外其他页面状态不会显示在博客上 summary: process.env.NEXT_PUBLIC_NOTION_PROPERTY_SUMMARY || 'summary', slug: process.env.NEXT_PUBLIC_NOTION_PROPERTY_SLUG || 'slug', category: process.env.NEXT_PUBLIC_NOTION_PROPERTY_CATEGORY || 'category', @@ -450,8 +520,10 @@ const BLOG = { // 作废配置 AVATAR: process.env.NEXT_PUBLIC_AVATAR || '/avatar.svg', // 作者头像,被notion中的ICON覆盖。若无ICON则取public目录下的avatar.png TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 ,被notion中的页面标题覆盖;此处请勿留空白,否则服务器无法编译 - HOME_BANNER_IMAGE: process.env.NEXT_PUBLIC_HOME_BANNER_IMAGE || '/bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件 - DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖 + HOME_BANNER_IMAGE: + process.env.NEXT_PUBLIC_HOME_BANNER_IMAGE || '/bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件 + DESCRIPTION: + process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖 // 开发相关 NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index e7771025..c4d4931d 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -9,6 +9,7 @@ import { getPostBlocks, getSingleBlock } from '@/lib/notion/getPostBlocks' import { compressImage, mapImgUrl } from '@/lib/notion/mapImage' import { deepClone } from '@/lib/utils' import { idToUuid } from 'notion-utils' +import { extractLangId, extractLangPrefix } from '../utils/pageId' export { getAllTags } from '../notion/getAllTags' export { getPost } from '../notion/getNotionPost' @@ -18,18 +19,62 @@ export { getPostBlocks } from '../notion/getPostBlocks' * 获取博客数据; 基于Notion实现 * @param {*} pageId * @param {*} from - * @param latestPostCount 截取最新文章数量 - * @param categoryCount - * @param tagsCount 截取标签数量 - * @param pageType 过滤的文章类型,数组格式 ['Page','Post'] + * @param {*} locale 语言 zh|en|jp 等等 * @returns * */ -export async function getGlobalData({ pageId = BLOG.NOTION_PAGE_ID, from }) { - // 从notion获取 - const data = await getNotionPageData({ pageId, from }) +export async function getGlobalData({ + pageId = BLOG.NOTION_PAGE_ID, + from, + locale +}) { + // 获取站点数据 , 如果pageId有逗号隔开则分次取数据 + const siteIds = pageId.split(',') + let data = EmptyData(pageId) + + try { + for (let index = 0; index < siteIds.length; index++) { + const siteId = siteIds[index] + const id = extractLangId(siteId) + const prefix = extractLangPrefix(siteId) + // 第一个id站点默认语言 + if (index === 0 || locale === prefix) { + data = await getNotionPageData({ + pageId: id, + from + }) + } + } + } catch (error) { + console.error('异常', error) + } + return data +} + +/** + * 获取指定notion的collection数据 + * @param pageId + * @param from 请求来源 + * @returns {Promise} + */ +export async function getNotionPageData({ pageId, from }) { + // 尝试从缓存获取 + const cacheKey = 'page_block_' + pageId + let data = await getDataFromCache(cacheKey) + if (data && data.pageIds?.length > 0) { + // console.log('[API<<--缓存]', `from:${from}`, `root-page-id:${pageId}`) + // return data + } else { + // 从接口读取 + data = await getDataBaseInfoByNotionAPI({ pageId, from }) + // 存入缓存 + if (data) { + await setDataToCache(cacheKey, data) + } + } + + // 返回给前端的数据做处理 const db = deepClone(data) - // 减少返回给前端的数据,减少流量损耗 delete db.block delete db.schema delete db.rawMetadata @@ -47,10 +92,12 @@ export async function getGlobalData({ pageId = BLOG.NOTION_PAGE_ID, from }) { if (db?.post) { db.post = cleanBlock(db?.post) } - return db } +/** + * 清理block数据 + */ function cleanBlock(post) { const pageBlock = post?.blockMap?.block for (const i in pageBlock) { @@ -98,28 +145,6 @@ function getLatestPosts({ allPages, from, latestPostCount }) { return latestPosts.slice(0, latestPostCount) } -/** - * 获取指定notion的collection数据 - * @param pageId - * @param from 请求来源 - * @returns {Promise} - */ -export async function getNotionPageData({ pageId, from }) { - // 尝试从缓存获取 - const cacheKey = 'page_block_' + pageId - const data = await getDataFromCache(cacheKey) - if (data && data.pageIds?.length > 0) { - // console.log('[API<<--缓存]', `from:${from}`, `root-page-id:${pageId}`) - return data - } - const db = await getDataBaseInfoByNotionAPI({ pageId, from }) - // 存入缓存 - if (db) { - await setDataToCache(cacheKey, db) - } - return db -} - /** * 获取用户自定义单页菜单 * 旧版本,不读取Menu菜单,而是读取type=Page生成菜单 @@ -308,6 +333,7 @@ const EmptyData = pageId => { status: 'Published', type: 'Post', slug: '13a171332816461db29d50e9f575b00d', + pageCoverThumbnail: BLOG.HOME_BANNER_IMAGE, date: { start_date: '2023-04-24', lastEditedDay: '2023-04-24', diff --git a/lib/lang.js b/lib/lang.js index 60b80882..e05ac5e3 100644 --- a/lib/lang.js +++ b/lib/lang.js @@ -1,11 +1,11 @@ -import zhCN from './lang/zh-CN' +import { getQueryVariable, isBrowser, mergeDeep } from '@/lib/utils' import enUS from './lang/en-US' +import frFR from './lang/fr-FR' +import jaJP from './lang/ja-JP' +import trTR from './lang/tr-TR' +import zhCN from './lang/zh-CN' import zhHK from './lang/zh-HK' import zhTW from './lang/zh-TW' -import frFR from './lang/fr-FR' -import trTR from './lang/tr-TR' -import jaJP from './lang/ja-JP' -import { getQueryVariable, isBrowser, mergeDeep } from '@/lib/utils' /** * 在这里配置所有支持的语言 @@ -43,7 +43,9 @@ export function generateLocaleDict(langString) { // 然后尝试匹配只有语言匹配的情况 if (!userLocale) { - const languageOnlyLocales = supportedLocales.filter(locale => locale.startsWith(language)) + const languageOnlyLocales = supportedLocales.filter(locale => + locale.startsWith(language) + ) if (languageOnlyLocales.length > 0) { userLocale = LANGS[languageOnlyLocales[0]] } @@ -51,7 +53,9 @@ export function generateLocaleDict(langString) { // 如果还没匹配到,则返回最接近的语言包 if (!userLocale) { - const fallbackLocale = supportedLocales.find(locale => locale.startsWith('en')) + const fallbackLocale = supportedLocales.find(locale => + locale.startsWith('en') + ) userLocale = LANGS[fallbackLocale] } @@ -64,7 +68,11 @@ export function generateLocaleDict(langString) { */ export function initLocale(lang, locale, changeLang, changeLocale) { if (isBrowser) { - const queryLang = getQueryVariable('lang') || loadLangFromLocalStorage() + // 用户请求的预研 + const queryLang = + getQueryVariable('locale') || + getQueryVariable('lang') || + loadLangFromLocalStorage() let currentLang = lang if (queryLang && queryLang !== 'undefined' && queryLang !== lang) { currentLang = queryLang @@ -91,6 +99,6 @@ export const loadLangFromLocalStorage = () => { * 保存语言 * @param newTheme */ -export const saveLangToLocalStorage = (lang) => { +export const saveLangToLocalStorage = lang => { localStorage.setItem('lang', lang) } diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 615ed5c9..e0d92f83 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -22,17 +22,27 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // Notion 图床转换为永久地址 - const isNotionSignImg = ret.indexOf('https://www.notion.so/image') !== 0 && (ret.indexOf('secure.notion-static.com') > 0 || ret.indexOf('prod-files-secure') > 0) + const isNotionSignImg = + ret.indexOf('https://www.notion.so/image') !== 0 && + (ret.indexOf('secure.notion-static.com') > 0 || + ret.indexOf('prod-files-secure') > 0) const isImgBlock = BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block' if (isNotionSignImg && isImgBlock) { - ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id + ret = + BLOG.NOTION_HOST + + '/image/' + + encodeURIComponent(ret) + + '?table=' + + type + + '&id=' + + block.id } if (!isEmoji(ret) && ret.indexOf('notion.so/images/page-cover') < 0) { if (BLOG.RANDOM_IMAGE_URL) { // 只有配置了随机图片接口,才会替换图片 const texts = BLOG.RANDOM_IMAGE_REPLACE_TEXT - let isReplace = false; + let isReplace = false if (texts) { const textArr = texts.split(',') // 判断是否包含替换的文本 @@ -58,7 +68,11 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // 统一压缩图片 - if (from === 'pageCoverThumbnail' || block.type === 'image' || block.type === 'page') { + if ( + from === 'pageCoverThumbnail' || + block?.type === 'image' || + block?.type === 'page' + ) { const width = block?.format?.block_width ret = compressImage(ret, width) } @@ -72,8 +86,9 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { * @returns */ function isEmoji(str) { - const emojiRegex = /[\u{1F300}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}\u{238C}\u{2B06}\u{2B07}\u{2B05}\u{27A1}\u{2194}-\u{2199}\u{2194}\u{21A9}\u{21AA}\u{2934}\u{2935}\u{25AA}\u{25AB}\u{25FE}\u{25FD}\u{25FB}\u{25FC}\u{25B6}\u{25C0}\u{1F200}-\u{1F251}]/u; - return emojiRegex.test(str); + const emojiRegex = + /[\u{1F300}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}\u{238C}\u{2B06}\u{2B07}\u{2B05}\u{27A1}\u{2194}-\u{2199}\u{2194}\u{21A9}\u{21AA}\u{2934}\u{2935}\u{25AA}\u{25AB}\u{25FE}\u{25FD}\u{25FB}\u{25FC}\u{25B6}\u{25C0}\u{1F200}-\u{1F251}]/u + return emojiRegex.test(str) } /** @@ -97,7 +112,10 @@ const compressImage = (image, width, quality = 50, fmt = 'webp') => { const params = new URLSearchParams(urlObj.search) // Notion图床 - if (image.indexOf(BLOG.NOTION_HOST) === 0 && image.indexOf('amazonaws.com') > 0) { + if ( + image.indexOf(BLOG.NOTION_HOST) === 0 && + image.indexOf('amazonaws.com') > 0 + ) { params.set('width', width) params.set('cache', 'v2') // 生成新的URL @@ -117,11 +135,11 @@ const compressImage = (image, width, quality = 50, fmt = 'webp') => { return urlObj.toString() } else if (image.indexOf('https://your_picture_bed') === 0) { // 此处还可以添加您的自定义图传的封面图压缩参数。 - // .e.g + // .e.g return 'do_somethin_here' } return image } -export { mapImgUrl, compressImage } +export { compressImage, mapImgUrl } diff --git a/lib/utils/pageId.js b/lib/utils/pageId.js new file mode 100644 index 00000000..e3c648e1 --- /dev/null +++ b/lib/utils/pageId.js @@ -0,0 +1,33 @@ +/** + * 截取page-id的语言前缀 + * notionPageId的格式可以是 en:xxxxx + * @param {*} str + * @returns en|zh|xx + */ +function extractLangPrefix(str) { + const match = str.match(/^(.+?):/) + if (match && match[1]) { + return match[1] + } else { + return '' + } +} + +/** + * 截取page-id的id + * notionPageId的格式可以是 en:xxxxx * @param {*} str + * @returns xxxxx + */ +function extractLangId(str) { + // 使用正则表达式匹配字符串 + const match = str.match(/:\s*(.+)/) + // 如果匹配成功,则返回匹配到的内容 + if (match && match[1]) { + return match[1] + } else { + // 如果没有匹配到,则返回空字符串或者其他你想要返回的值 + return str + } +} + +module.exports = { extractLangPrefix, extractLangId } diff --git a/next.config.js b/next.config.js index c4e9d8e4..cf4fa85f 100644 --- a/next.config.js +++ b/next.config.js @@ -2,11 +2,36 @@ const { THEME } = require('./blog.config') const fs = require('fs') const path = require('path') const BLOG = require('./blog.config') +const { extractLangPrefix } = require('./lib/utils/pageId') +// 打包时是否分析代码 const withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: BLOG.BUNDLE_ANALYZER }) +// 扫描项目 /themes下的目录名 +const themes = scanSubdirectories(path.resolve(__dirname, 'themes')) +// 检测用户开启的多语言 +const locales = (function () { + // 根据BLOG_NOTION_PAGE_ID 检查支持多少种语言数据. + // 支持如下格式配置多个语言的页面id xxx,zh:xxx,en:xxx + const langs = ['zh', 'en'] + if (BLOG.NOTION_PAGE_ID.indexOf(',') > 0) { + const siteIds = BLOG.NOTION_PAGE_ID.split(',') + for (let index = 0; index < siteIds.length; index++) { + const siteId = siteIds[index] + const prefix = extractLangPrefix(siteId) + // 如果包含前缀 例如 zh , en 等 + if (prefix) { + if (!langs.includes(prefix)) { + langs.push(prefix) + } + } + } + } + return langs +})() + /** * 扫描指定目录下的文件夹名,用于获取所有主题 * @param {*} directory @@ -27,8 +52,7 @@ function scanSubdirectories(directory) { return subdirectories } -// 扫描项目 /themes下的目录名 -const themes = scanSubdirectories(path.resolve(__dirname, 'themes')) + module.exports = withBundleAnalyzer({ images: { // 图片压缩 @@ -55,8 +79,52 @@ module.exports = withBundleAnalyzer({ } ] }, + // 多语言 + i18n: { + defaultLocale: BLOG.LANG.slice(0, 2), + // 支持的所有多语言,按需填写即可 + locales + }, + // 重写url async rewrites() { + // 处理多语言重定向 + const langsRewrites = [] + if (BLOG.NOTION_PAGE_ID.indexOf(',') > 0) { + const siteIds = BLOG.NOTION_PAGE_ID.split(',') + const langs = [] + for (let index = 0; index < siteIds.length; index++) { + const siteId = siteIds[index] + const prefix = extractLangPrefix(siteId) + // 如果包含前缀 例如 zh , en 等 + if (prefix) { + langs.push(prefix) + } + console.log('[Locales]', siteId) + } + + // 映射多语言 + // 示例: source: '/:locale(zh|en)/:path*' ; :locale() 会将语言放入重写后的 `?locale=` 中。 + langsRewrites.push( + { + source: `/:locale(${langs.join('|')})/:path*`, + destination: '/:path*' + }, + // 匹配没有路径的情况,例如 [domain]/zh 或 [domain]/en + { + source: `/:locale(${langs.join('|')})`, + destination: '/' + }, + // 匹配没有路径的情况,例如 [domain]/zh/ 或 [domain]/en/ + { + source: `/:locale(${langs.join('|')})/`, + destination: '/' + } + ) + } + return [ + ...langsRewrites, + // 伪静态重写 { source: '/:path*.html', destination: '/:path*' @@ -84,17 +152,9 @@ module.exports = withBundleAnalyzer({ ] }, webpack: (config, { dev, isServer }) => { - // Replace React with Preact only in client production build - // if (!dev && !isServer) { - // Object.assign(config.resolve.alias, { - // react: 'preact/compat', - // 'react-dom/test-utils': 'preact/test-utils', - // 'react-dom': 'preact/compat' - // }) - // } // 动态主题:添加 resolve.alias 配置,将动态路径映射到实际路径 if (!isServer) { - console.log('[加载主题]', path.resolve(__dirname, 'themes', THEME)) + console.log('[默认主题]', path.resolve(__dirname, 'themes', THEME)) } config.resolve.alias['@theme-components'] = path.resolve( __dirname, diff --git a/pages/404.js b/pages/404.js index a4746405..78278918 100644 --- a/pages/404.js +++ b/pages/404.js @@ -1,7 +1,7 @@ -import { getGlobalData } from '@/lib/db/getSiteData' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 404 @@ -10,12 +10,17 @@ import { siteConfig } from '@/lib/config' */ const NoFound = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps () { - const props = (await getGlobalData({ from: '404' })) || {} +export async function getStaticProps(req) { + const { locale } = req + + const props = (await getGlobalData({ from: '404', locale })) || {} return { props } } diff --git a/pages/[prefix]/[slug]/[...suffix].js b/pages/[prefix]/[slug]/[...suffix].js index 3ce0b105..84591ca5 100644 --- a/pages/[prefix]/[slug]/[...suffix].js +++ b/pages/[prefix]/[slug]/[...suffix].js @@ -35,7 +35,11 @@ export async function getStaticPaths() { paths: allPages ?.filter(row => checkSlug(row)) .map(row => ({ - params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1], suffix: row.slug.split('/').slice(1) } + params: { + prefix: row.slug.split('/')[0], + slug: row.slug.split('/')[1], + suffix: row.slug.split('/').slice(1) + } })), fallback: true } @@ -46,7 +50,10 @@ export async function getStaticPaths() { * @param {*} param0 * @returns */ -export async function getStaticProps({ params: { prefix, slug, suffix } }) { +export async function getStaticProps({ + params: { prefix, slug, suffix }, + locale +}) { let fullSlug = prefix + '/' + slug + '/' + suffix.join('/') if (JSON.parse(BLOG.PSEUDO_STATIC)) { if (!fullSlug.endsWith('.html')) { @@ -54,10 +61,13 @@ export async function getStaticProps({ params: { prefix, slug, suffix } }) { } } const from = `slug-props-${fullSlug}` - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) // 在列表内查找文章 props.post = props?.allPages?.find(p => { - return p.type.indexOf('Menu') < 0 && (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + return ( + p.type.indexOf('Menu') < 0 && + (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + ) }) // 处理非列表内文章的内信息 @@ -85,12 +95,18 @@ export async function getStaticProps({ params: { prefix, slug, suffix } }) { } // 推荐关联文章处理 - const allPosts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = props.allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) if (allPosts && allPosts.length > 0) { const index = allPosts.indexOf(props.post) props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0] props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0] - props.recommendPosts = getRecommendPost(props.post, allPosts, siteConfig('POST_RECOMMEND_COUNT')) + props.recommendPosts = getRecommendPost( + props.post, + allPosts, + siteConfig('POST_RECOMMEND_COUNT') + ) } else { props.prev = null props.next = null @@ -109,7 +125,11 @@ function checkSlug(row) { if (slug.startsWith('/')) { slug = slug.substring(1) } - return (slug.match(/\//g) || []).length >= 2 && row.type.indexOf('Menu') < 0 && !checkContainHttp(slug) + return ( + (slug.match(/\//g) || []).length >= 2 && + row.type.indexOf('Menu') < 0 && + !checkContainHttp(slug) + ) } export default PrefixSlug diff --git a/pages/[prefix]/[slug]/index.js b/pages/[prefix]/[slug]/index.js index 147d9ecb..0af41678 100644 --- a/pages/[prefix]/[slug]/index.js +++ b/pages/[prefix]/[slug]/index.js @@ -28,14 +28,16 @@ export async function getStaticPaths() { const { allPages } = await getGlobalData({ from }) const paths = allPages ?.filter(row => checkSlug(row)) - .map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1] } })) + .map(row => ({ + params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1] } + })) return { paths: paths, fallback: true } } -export async function getStaticProps({ params: { prefix, slug } }) { +export async function getStaticProps({ params: { prefix, slug }, locale }) { let fullSlug = prefix + '/' + slug if (JSON.parse(BLOG.PSEUDO_STATIC)) { if (!fullSlug.endsWith('.html')) { @@ -43,10 +45,13 @@ export async function getStaticProps({ params: { prefix, slug } }) { } } const from = `slug-props-${fullSlug}` - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) // 在列表内查找文章 props.post = props?.allPages?.find(p => { - return p.type.indexOf('Menu') < 0 && (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + return ( + p.type.indexOf('Menu') < 0 && + (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + ) }) // 处理非列表内文章的内信息 @@ -74,12 +79,18 @@ export async function getStaticProps({ params: { prefix, slug } }) { } // 推荐关联文章处理 - const allPosts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = props.allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) if (allPosts && allPosts.length > 0) { const index = allPosts.indexOf(props.post) props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0] props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0] - props.recommendPosts = getRecommendPost(props.post, allPosts, siteConfig('POST_RECOMMEND_COUNT')) + props.recommendPosts = getRecommendPost( + props.post, + allPosts, + siteConfig('POST_RECOMMEND_COUNT') + ) } else { props.prev = null props.next = null @@ -97,6 +108,10 @@ function checkSlug(row) { if (slug.startsWith('/')) { slug = slug.substring(1) } - return (slug.match(/\//g) || []).length === 1 && !checkContainHttp(slug) && row.type.indexOf('Menu') < 0 + return ( + (slug.match(/\//g) || []).length === 1 && + !checkContainHttp(slug) && + row.type.indexOf('Menu') < 0 + ) } export default PrefixSlug diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js index 567f0244..a0de57bd 100644 --- a/pages/[prefix]/index.js +++ b/pages/[prefix]/index.js @@ -53,7 +53,10 @@ const Slug = props => { props = { ...props, lock, setLock, validPassword } // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } @@ -67,14 +70,16 @@ export async function getStaticPaths() { const from = 'slug-paths' const { allPages } = await getGlobalData({ from }) - const paths = allPages?.filter(row => checkSlug(row)).map(row => ({ params: { prefix: row.slug } })) + const paths = allPages + ?.filter(row => checkSlug(row)) + .map(row => ({ params: { prefix: row.slug } })) return { paths: paths, fallback: true } } -export async function getStaticProps({ params: { prefix } }) { +export async function getStaticProps({ params: { prefix }, locale }) { let fullSlug = prefix if (JSON.parse(BLOG.PSEUDO_STATIC)) { if (!fullSlug.endsWith('.html')) { @@ -82,10 +87,13 @@ export async function getStaticProps({ params: { prefix } }) { } } const from = `slug-props-${fullSlug}` - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) // 在列表内查找文章 props.post = props?.allPages?.find(p => { - return p.type.indexOf('Menu') < 0 && (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + return ( + p.type.indexOf('Menu') < 0 && + (p.slug === fullSlug || p.id === idToUuid(fullSlug)) + ) }) // 处理非列表内文章的内信息 @@ -113,12 +121,18 @@ export async function getStaticProps({ params: { prefix } }) { } // 推荐关联文章处理 - const allPosts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = props.allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) if (allPosts && allPosts.length > 0) { const index = allPosts.indexOf(props.post) props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0] props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0] - props.recommendPosts = getRecommendPost(props.post, allPosts, siteConfig('POST_RECOMMEND_COUNT')) + props.recommendPosts = getRecommendPost( + props.post, + allPosts, + siteConfig('POST_RECOMMEND_COUNT') + ) } else { props.prev = null props.next = null @@ -172,7 +186,11 @@ function checkSlug(row) { if (slug.startsWith('/')) { slug = slug.substring(1) } - return (slug.match(/\//g) || []).length === 0 && !checkContainHttp(slug) && row.type.indexOf('Menu') < 0 + return ( + (slug.match(/\//g) || []).length === 0 && + !checkContainHttp(slug) && + row.type.indexOf('Menu') < 0 + ) } export default Slug diff --git a/pages/archive/index.js b/pages/archive/index.js index 13bc905b..43eb7d27 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -1,15 +1,18 @@ -import { getGlobalData } from '@/lib/db/getSiteData' -import { useEffect } from 'react' import BLOG from '@/blog.config' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' import { isBrowser } from '@/lib/utils' import { formatDateFmt } from '@/lib/utils/formatDate' -import { siteConfig } from '@/lib/config' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' +import { useEffect } from 'react' const ArchiveIndex = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) useEffect(() => { if (isBrowser) { @@ -28,10 +31,12 @@ const ArchiveIndex = props => { return } -export async function getStaticProps() { - const props = await getGlobalData({ from: 'archive-index' }) +export async function getStaticProps({ locale }) { + const props = await getGlobalData({ from: 'archive-index', locale }) // 处理分页 - props.posts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + props.posts = props.allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) delete props.allPages const postsSortByDate = Object.create(props.posts) diff --git a/pages/category/[category]/index.js b/pages/category/[category]/index.js index 718d2b42..3c7caf62 100644 --- a/pages/category/[category]/index.js +++ b/pages/category/[category]/index.js @@ -11,19 +11,26 @@ import { useRouter } from 'next/router' */ export default function Category(props) { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps({ params: { category } }) { +export async function getStaticProps({ params: { category }, locale }) { const from = 'category-props' - let props = await getGlobalData({ from }) + let props = await getGlobalData({ from, locale }) // 过滤状态 - props.posts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + props.posts = props.allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) // 处理过滤 - props.posts = props.posts.filter(post => post && post.category && post.category.includes(category)) + props.posts = props.posts.filter( + post => post && post.category && post.category.includes(category) + ) // 处理文章页数 props.postCount = props.posts.length // 处理分页 diff --git a/pages/category/index.js b/pages/category/index.js index e4532cbc..e3af2bda 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -1,9 +1,8 @@ -import { getGlobalData } from '@/lib/db/getSiteData' -import React from 'react' import BLOG from '@/blog.config' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 分类首页 @@ -12,13 +11,16 @@ import { siteConfig } from '@/lib/config' */ export default function Category(props) { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps() { - const props = await getGlobalData({ from: 'category-index-props' }) +export async function getStaticProps({ locale }) { + const props = await getGlobalData({ from: 'category-index-props', locale }) delete props.allPages return { props, diff --git a/pages/index.js b/pages/index.js index 9f2dfb91..b6cb5014 100644 --- a/pages/index.js +++ b/pages/index.js @@ -24,9 +24,10 @@ const Index = props => { * SSG 获取数据 * @returns */ -export async function getStaticProps() { +export async function getStaticProps(req) { + const { locale } = req const from = 'index' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) props.posts = props.allPages?.filter( page => page.type === 'Post' && page.status === 'Published' diff --git a/pages/page/[page].js b/pages/page/[page].js index 9b1278b6..34ce91c7 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -11,14 +11,17 @@ import { useRouter } from 'next/router' */ const Page = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticPaths() { +export async function getStaticPaths({ locale }) { const from = 'page-paths' - const { postCount } = await getGlobalData({ from }) + const { postCount } = await getGlobalData({ from, locale }) const totalPages = Math.ceil(postCount / siteConfig('POSTS_PER_PAGE')) return { // remove first page, we 're not gonna handle that. @@ -33,9 +36,14 @@ export async function getStaticProps({ params: { page } }) { const from = `page-${page}` const props = await getGlobalData({ from }) const { allPages } = props - const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) // 处理分页 - props.posts = allPosts.slice(siteConfig('POSTS_PER_PAGE') * (page - 1), siteConfig('POSTS_PER_PAGE') * page) + props.posts = allPosts.slice( + siteConfig('POSTS_PER_PAGE') * (page - 1), + siteConfig('POSTS_PER_PAGE') * page + ) props.page = page // 处理预览 @@ -45,7 +53,11 @@ export async function getStaticProps({ params: { page } }) { if (post.password && post.password !== '') { continue } - post.blockMap = await getPostBlocks(post.id, 'slug', siteConfig('POST_PREVIEW_LINES')) + post.blockMap = await getPostBlocks( + post.id, + 'slug', + siteConfig('POST_PREVIEW_LINES') + ) } } diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index 0038c9f8..b1d8f6c2 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -7,7 +7,10 @@ import { useRouter } from 'next/router' const Index = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } @@ -17,13 +20,15 @@ const Index = props => { * @param {*} param0 * @returns */ -export async function getStaticProps({ params: { keyword } }) { +export async function getStaticProps({ params: { keyword }, locale }) { const props = await getGlobalData({ from: 'search-props', - pageType: ['Post'] + locale }) const { allPages } = props - const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) props.posts = await filterByMemCache(allPosts, keyword) props.postCount = props.posts.length // 处理分页 @@ -87,7 +92,8 @@ function getTextContent(textArray) { * @param {*} obj * @returns */ -const isIterable = obj => obj != null && typeof obj[Symbol.iterator] === 'function' +const isIterable = obj => + obj != null && typeof obj[Symbol.iterator] === 'function' /** * 在内存缓存中进行全文索引 @@ -103,8 +109,12 @@ async function filterByMemCache(allPosts, keyword) { for (const post of allPosts) { const cacheKey = 'page_block_' + post.id const page = await getDataFromCache(cacheKey, true) - const tagContent = post?.tags && Array.isArray(post?.tags) ? post?.tags.join(' ') : '' - const categoryContent = post.category && Array.isArray(post.category) ? post.category.join(' ') : '' + const tagContent = + post?.tags && Array.isArray(post?.tags) ? post?.tags.join(' ') : '' + const categoryContent = + post.category && Array.isArray(post.category) + ? post.category.join(' ') + : '' const articleInfo = post.title + post.summary + tagContent + categoryContent let hit = articleInfo.toLowerCase().indexOf(keyword) > -1 const indexContent = getPageContentText(post, page) diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 43291b0b..2f01ec24 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -8,7 +8,10 @@ import { useRouter } from 'next/router' const Index = props => { const { keyword } = props // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) props = { ...props, currentSearch: keyword } return @@ -19,17 +22,23 @@ const Index = props => { * @param {*} param0 * @returns */ -export async function getStaticProps({ params: { keyword, page } }) { +export async function getStaticProps({ params: { keyword, page }, locale }) { const props = await getGlobalData({ from: 'search-props', - pageType: ['Post'] + pageType: ['Post'], + locale }) const { allPages } = props - const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + const allPosts = allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) props.posts = await filterByMemCache(allPosts, keyword) props.postCount = props.posts.length // 处理分页 - props.posts = props.posts.slice(siteConfig('POSTS_PER_PAGE') * (page - 1), siteConfig('POSTS_PER_PAGE') * page) + props.posts = props.posts.slice( + siteConfig('POSTS_PER_PAGE') * (page - 1), + siteConfig('POSTS_PER_PAGE') * page + ) props.keyword = keyword props.page = page delete props.allPages @@ -87,7 +96,8 @@ function getTextContent(textArray) { * @param {*} obj * @returns */ -const isIterable = obj => obj != null && typeof obj[Symbol.iterator] === 'function' +const isIterable = obj => + obj != null && typeof obj[Symbol.iterator] === 'function' /** * 在内存缓存中进行全文索引 @@ -103,8 +113,12 @@ async function filterByMemCache(allPosts, keyword) { for (const post of allPosts) { const cacheKey = 'page_block_' + post.id const page = await getDataFromCache(cacheKey, true) - const tagContent = post?.tags && Array.isArray(post?.tags) ? post?.tags.join(' ') : '' - const categoryContent = post.category && Array.isArray(post.category) ? post.category.join(' ') : '' + const tagContent = + post?.tags && Array.isArray(post?.tags) ? post?.tags.join(' ') : '' + const categoryContent = + post.category && Array.isArray(post.category) + ? post.category.join(' ') + : '' const articleInfo = post.title + post.summary + tagContent + categoryContent let hit = articleInfo.indexOf(keyword) > -1 let indexContent = [post.summary] diff --git a/pages/search/index.js b/pages/search/index.js index e41da00b..3b637cd1 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -1,8 +1,8 @@ -import { getGlobalData } from '@/lib/db/getSiteData' -import { useRouter } from 'next/router' import BLOG from '@/blog.config' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 搜索路由 @@ -13,7 +13,10 @@ const Search = props => { const { posts } = props // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) const router = useRouter() const keyword = router?.query?.s @@ -25,7 +28,7 @@ const Search = props => { const tagContent = post?.tags ? post?.tags.join(' ') : '' const categoryContent = post.category ? post.category.join(' ') : '' const searchContent = - post.title + post.summary + tagContent + categoryContent + post.title + post.summary + tagContent + categoryContent return searchContent.toLowerCase().includes(keyword.toLowerCase()) }) } else { @@ -40,13 +43,15 @@ const Search = props => { /** * 浏览器前端搜索 */ -export async function getStaticProps() { +export async function getStaticProps({ locale }) { const props = await getGlobalData({ from: 'search-props', - pageType: ['Post'] + locale }) const { allPages } = props - props.posts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published') + props.posts = allPages?.filter( + page => page.type === 'Post' && page.status === 'Published' + ) return { props, revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND) diff --git a/pages/signin.js b/pages/signin.js index 0fc037bc..42977ffe 100644 --- a/pages/signin.js +++ b/pages/signin.js @@ -1,8 +1,8 @@ import BLOG from '@/blog.config' -import { getGlobalData } from '@/lib/db/getSiteData' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 登录 @@ -11,13 +11,18 @@ import { siteConfig } from '@/lib/config' */ const SignIn = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps() { +export async function getStaticProps(req) { + const { locale } = req + const from = 'SignIn' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) delete props.allPages return { diff --git a/pages/signup.js b/pages/signup.js index 1fccbe8b..033b7796 100644 --- a/pages/signup.js +++ b/pages/signup.js @@ -1,8 +1,8 @@ import BLOG from '@/blog.config' -import { getGlobalData } from '@/lib/db/getSiteData' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 注册 @@ -11,13 +11,18 @@ import { siteConfig } from '@/lib/config' */ const SignUp = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps() { +export async function getStaticProps(req) { + const { locale } = req + const from = 'SignIn' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) delete props.allPages return { diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index ea4ffe6a..153cf415 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -11,14 +11,17 @@ import { useRouter } from 'next/router' */ const Tag = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps({ params: { tag } }) { +export async function getStaticProps({ params: { tag }, locale }) { const from = 'tag-props' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) // 过滤状态 props.posts = props.allPages diff --git a/pages/tag/[tag]/page/[page].js b/pages/tag/[tag]/page/[page].js index 4566b059..519f9146 100644 --- a/pages/tag/[tag]/page/[page].js +++ b/pages/tag/[tag]/page/[page].js @@ -6,13 +6,16 @@ import { useRouter } from 'next/router' const Tag = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps({ params: { tag, page } }) { +export async function getStaticProps({ params: { tag, page }, locale }) { const from = 'tag-page-props' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) // 过滤状态、标签 props.posts = props.allPages ?.filter(page => page.type === 'Post' && page.status === 'Published') @@ -20,7 +23,10 @@ export async function getStaticProps({ params: { tag, page } }) { // 处理文章数 props.postCount = props.posts.length // 处理分页 - props.posts = props.posts.slice(siteConfig('POSTS_PER_PAGE') * (page - 1), siteConfig('POSTS_PER_PAGE') * page) + props.posts = props.posts.slice( + siteConfig('POSTS_PER_PAGE') * (page - 1), + siteConfig('POSTS_PER_PAGE') * page + ) props.tag = tag props.page = page diff --git a/pages/tag/index.js b/pages/tag/index.js index 2141242d..24b3b148 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -1,8 +1,8 @@ -import { getGlobalData } from '@/lib/db/getSiteData' import BLOG from '@/blog.config' -import { useRouter } from 'next/router' -import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' +import { getGlobalData } from '@/lib/db/getSiteData' +import { getLayoutByTheme } from '@/themes/theme' +import { useRouter } from 'next/router' /** * 标签首页 @@ -11,13 +11,18 @@ import { siteConfig } from '@/lib/config' */ const TagIndex = props => { // 根据页面路径加载不同Layout文件 - const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) + const Layout = getLayoutByTheme({ + theme: siteConfig('THEME'), + router: useRouter() + }) return } -export async function getStaticProps() { +export async function getStaticProps(req) { + const { locale } = req + const from = 'tag-index-props' - const props = await getGlobalData({ from }) + const props = await getGlobalData({ from, locale }) delete props.allPages return { props, From 43f03a41e82198fb90904420ad13e8769dae31a6 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 9 Apr 2024 18:18:48 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E5=87=8F=E5=B0=91=E6=97=A0=E7=94=A8packa?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ShareButtons.js | 674 +++++++++++++++++++------------------ package.json | 4 - yarn.lock | 10 - 3 files changed, 341 insertions(+), 347 deletions(-) diff --git a/components/ShareButtons.js b/components/ShareButtons.js index e3714b79..853aa3a4 100644 --- a/components/ShareButtons.js +++ b/components/ShareButtons.js @@ -1,53 +1,52 @@ import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' -import copy from 'copy-to-clipboard' import dynamic from 'next/dynamic' import { useRouter } from 'next/router' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { - FacebookShareButton, - FacebookIcon, - FacebookMessengerShareButton, - FacebookMessengerIcon, - RedditShareButton, - RedditIcon, - LineShareButton, - LineIcon, - EmailShareButton, EmailIcon, - TwitterShareButton, - TwitterIcon, - TelegramShareButton, - TelegramIcon, - WhatsappShareButton, - WhatsappIcon, - LinkedinShareButton, + EmailShareButton, + FacebookIcon, + FacebookMessengerIcon, + FacebookMessengerShareButton, + FacebookShareButton, + HatenaIcon, + HatenaShareButton, + InstapaperIcon, + InstapaperShareButton, + LineIcon, + LineShareButton, LinkedinIcon, - PinterestShareButton, - PinterestIcon, - VKIcon, - VKShareButton, - OKShareButton, - OKIcon, - TumblrShareButton, - TumblrIcon, + LinkedinShareButton, LivejournalIcon, LivejournalShareButton, - MailruShareButton, MailruIcon, + MailruShareButton, + OKIcon, + OKShareButton, + PinterestIcon, + PinterestShareButton, + PocketIcon, + PocketShareButton, + RedditIcon, + RedditShareButton, + TelegramIcon, + TelegramShareButton, + TumblrIcon, + TumblrShareButton, + TwitterIcon, + TwitterShareButton, + VKIcon, + VKShareButton, ViberIcon, ViberShareButton, - WorkplaceShareButton, - WorkplaceIcon, - WeiboShareButton, WeiboIcon, - PocketShareButton, - PocketIcon, - InstapaperShareButton, - InstapaperIcon, - HatenaShareButton, - HatenaIcon + WeiboShareButton, + WhatsappIcon, + WhatsappShareButton, + WorkplaceIcon, + WorkplaceShareButton } from 'react-share' const QrCode = dynamic(() => import('@/components/QrCode'), { ssr: false }) @@ -59,10 +58,11 @@ const QrCode = dynamic(() => import('@/components/QrCode'), { ssr: false }) */ const ShareButtons = ({ post }) => { const router = useRouter() - const shareUrl = siteConfig('LINK') + router.asPath + const [shareUrl, setShareUrl] = useState(siteConfig('LINK') + router.asPath) const title = post.title || siteConfig('TITLE') const image = post.pageCover - const body = post?.title + ' | ' + title + ' ' + shareUrl + ' ' + post?.summary + const body = + post?.title + ' | ' + title + ' ' + shareUrl + ' ' + post?.summary const services = siteConfig('POSTS_SHARE_SERVICES').split(',') const titleWithSiteInfo = title + ' | ' + siteConfig('TITLE') @@ -70,8 +70,8 @@ const ShareButtons = ({ post }) => { const [qrCodeShow, setQrCodeShow] = useState(false) const copyUrl = () => { - copy(shareUrl) - alert(locale.COMMON.URL_COPIED) + navigator?.clipboard?.writeText(shareUrl) + alert(locale.COMMON.URL_COPIED + ' \n' + shareUrl) } const openPopover = () => { @@ -81,300 +81,308 @@ const ShareButtons = ({ post }) => { setQrCodeShow(false) } + useEffect(() => { + setShareUrl(window.location.href) + }, []) + return ( - <> - {services.map(singleService => { - if (singleService === 'facebook') { - return ( - - - - ) - } - if (singleService === 'messenger') { - return ( - - - - ) - } - if (singleService === 'line') { - return ( - - - - ) - } - if (singleService === 'reddit') { - return ( - - - - ) - } - if (singleService === 'email') { - return ( - - - - ) - } - if (singleService === 'twitter') { - return ( - - - - ) - } - if (singleService === 'telegram') { - return ( - - - - ) - } - if (singleService === 'whatsapp') { - return ( - - - - ) - } - if (singleService === 'linkedin') { - return ( - - - - ) - } - if (singleService === 'pinterest') { - return ( - - - - ) - } - if (singleService === 'vkshare') { - return ( - - - - ) - } - if (singleService === 'okshare') { - return ( - - - - ) - } - if (singleService === 'tumblr') { - return ( - - - - ) - } - if (singleService === 'livejournal') { - return ( - - - - ) - } - if (singleService === 'mailru') { - return ( - - - - ) - } - if (singleService === 'viber') { - return ( - - - - ) - } - if (singleService === 'workplace') { - return ( - - - - ) - } - if (singleService === 'weibo') { - return ( - - - - ) - } - if (singleService === 'pocket') { - return ( - - - - ) - } - if (singleService === 'instapaper') { - return ( - - - - ) - } - if (singleService === 'hatena') { - return ( - - - - ) - } - if (singleService === 'qq') { - return - } - if (singleService === 'wechat') { - return - } - if (singleService === 'link') { - return - } - return <> - })} - + <> + {services.map(singleService => { + if (singleService === 'facebook') { + return ( + + + + ) + } + if (singleService === 'messenger') { + return ( + + + + ) + } + if (singleService === 'line') { + return ( + + + + ) + } + if (singleService === 'reddit') { + return ( + + + + ) + } + if (singleService === 'email') { + return ( + + + + ) + } + if (singleService === 'twitter') { + return ( + + + + ) + } + if (singleService === 'telegram') { + return ( + + + + ) + } + if (singleService === 'whatsapp') { + return ( + + + + ) + } + if (singleService === 'linkedin') { + return ( + + + + ) + } + if (singleService === 'pinterest') { + return ( + + + + ) + } + if (singleService === 'vkshare') { + return ( + + + + ) + } + if (singleService === 'okshare') { + return ( + + + + ) + } + if (singleService === 'tumblr') { + return ( + + + + ) + } + if (singleService === 'livejournal') { + return ( + + + + ) + } + if (singleService === 'mailru') { + return ( + + + + ) + } + if (singleService === 'viber') { + return ( + + + + ) + } + if (singleService === 'workplace') { + return ( + + + + ) + } + if (singleService === 'weibo') { + return ( + + + + ) + } + if (singleService === 'pocket') { + return ( + + + + ) + } + if (singleService === 'instapaper') { + return ( + + + + ) + } + if (singleService === 'hatena') { + return ( + + + + ) + } + if (singleService === 'qq') { + return ( + + ) + } + if (singleService === 'wechat') { + return ( + + ) + } + if (singleService === 'link') { + return ( + + ) + } + return <> + })} + ) } diff --git a/package.json b/package.json index 5a4a8cce..c17bd829 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,6 @@ "algoliasearch": "^4.18.0", "animejs": "^3.2.1", "aos": "^2.3.4", - "axios": ">=0.21.1", - "copy-to-clipboard": "^3.3.1", "feed": "^4.2.2", "js-md5": "^0.7.3", "localStorage": "^1.0.4", @@ -40,8 +38,6 @@ "notion-client": "6.15.6", "notion-utils": "6.15.6", "nprogress": "^0.2.0", - "preact": "^10.5.15", - "prism-themes": "1.9.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-facebook": "^8.1.4", diff --git a/yarn.lock b/yarn.lock index 8e4cfd52..c5711de7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4146,11 +4146,6 @@ postcss@^8.4.23, postcss@^8.4.31, postcss@^8.4.33: picocolors "^1.0.0" source-map-js "^1.0.2" -preact@^10.5.15: - version "10.19.3" - resolved "https://registry.yarnpkg.com/preact/-/preact-10.19.3.tgz#7a7107ed2598a60676c943709ea3efb8aaafa899" - integrity sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ== - prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" @@ -4168,11 +4163,6 @@ prettier@3.2.5: resolved "https://r.cnpmjs.org/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== -prism-themes@1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/prism-themes/-/prism-themes-1.9.0.tgz#19c034f3205f1e28d75d89728e54ccd745f7e3dd" - integrity sha512-tX2AYsehKDw1EORwBps+WhBFKc2kxfoFpQAjxBndbZKr4fRmMkv47XN0BghC/K1qwodB1otbe4oF23vUTFDokw== - prismjs@^1.27.0: version "1.29.0" resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12" From 295d29787e5bf8adfb686e8eaf75382fe9fe2201 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 9 Apr 2024 18:21:04 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E7=A7=BB=E9=99=A4mongodb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cache/cache_manager.js | 9 +- lib/cache/mongo_db_cache.js | 49 -- package.json | 1 - yarn.lock | 1026 +---------------------------------- 4 files changed, 5 insertions(+), 1080 deletions(-) delete mode 100644 lib/cache/mongo_db_cache.js diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 9103b4b1..6070958c 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -1,7 +1,6 @@ -import MemoryCache from './memory_cache' -import FileCache from './local_file_cache' -import MongoCache from './mongo_db_cache' import BLOG from '@/blog.config' +import FileCache from './local_file_cache' +import MemoryCache from './memory_cache' /** * 为减少频繁接口请求,notion数据将被缓存 @@ -39,9 +38,7 @@ export async function delCacheData(key) { * @returns */ function getApi() { - if (process.env.MONGO_DB_URL && process.env.MONGO_DB_NAME) { - return MongoCache - } else if (process.env.ENABLE_FILE_CACHE) { + if (process.env.ENABLE_FILE_CACHE) { return FileCache } else { return MemoryCache diff --git a/lib/cache/mongo_db_cache.js b/lib/cache/mongo_db_cache.js deleted file mode 100644 index b3996470..00000000 --- a/lib/cache/mongo_db_cache.js +++ /dev/null @@ -1,49 +0,0 @@ -const MongoClient = require('mongodb').MongoClient - -const DB_URL = process.env.MONGO_DB_URL // e.g. mongodb+srv://mongo_user:[password]@xxx.mongodb.net//?retryWrites=true&w=majority -const DB_NAME = process.env.MONGO_DB_NAME // e.g. tangly1024 -const DB_COLLECTION = 'posts' - -export async function getCache (key) { - const client = await MongoClient.connect(DB_URL).catch(err => { console.error(err) }) - const dbo = client.db(DB_NAME) - const query = { block_id: key } - const res = await dbo.collection('posts').findOne(query).catch(err => { console.error(err) }) - await client.close() - return res -} - -/** - * 并发请求写文件异常; Vercel生产环境不支持写文件。 - * @param key - * @param data - * @returns {Promise} - */ -export async function setCache (key, data) { - const client = await MongoClient.connect(DB_URL).catch(err => { console.error(err) }) - const dbo = client.db(DB_NAME) - data.block_id = key - const query = { block_id: key } - const jsonObj = JSON.parse(JSON.stringify(data)) - - const updRes = await dbo.collection(DB_COLLECTION).updateOne(query, { $set: jsonObj }).catch(err => { console.error(err) }) - console.log('更新结果', key, updRes) - if (updRes.matchedCount === 0) { - const insertRes = await dbo.collection(DB_COLLECTION).insertOne(jsonObj).catch(err => { console.error(err) }) - console.log('插入结果', key, insertRes) - } - await client.close() - return data -} - -export async function delCache (key, data) { - const client = await MongoClient.connect(DB_URL).catch(err => { console.error(err) }) - const dbo = client.db(DB_NAME) - const query = { block_id: key } - const res = await dbo.collection('posts').deleteOne(query).catch(err => { console.error(err) }) - console.log('删除结果', key, res) - await client.close() - return null -} - -export default { getCache, setCache, delCache } diff --git a/package.json b/package.json index c17bd829..9b130656 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "localStorage": "^1.0.4", "lodash.throttle": "^4.1.1", "memory-cache": "^0.2.0", - "mongodb": "^4.6.0", "next": "13.3.1", "notion-client": "6.15.6", "notion-utils": "6.15.6", diff --git a/yarn.lock b/yarn.lock index c5711de7..ced20b9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -116,509 +116,6 @@ resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw== -"@aws-crypto/crc32@3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/crc32/-/crc32-3.0.0.tgz#07300eca214409c33e3ff769cd5697b57fdd38fa" - integrity sha512-IzSgsrxUcsrejQbPVilIKy16kAT52EwB6zSaI+M3xxIhKh5+aldEyvI+z6erM7TCLB2BJsFrtHjp6/4/sr+3dA== - dependencies: - "@aws-crypto/util" "^3.0.0" - "@aws-sdk/types" "^3.222.0" - tslib "^1.11.1" - -"@aws-crypto/ie11-detection@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/ie11-detection/-/ie11-detection-3.0.0.tgz#640ae66b4ec3395cee6a8e94ebcd9f80c24cd688" - integrity sha512-341lBBkiY1DfDNKai/wXM3aujNBkXR7tq1URPQDL9wi3AUbI80NR74uF1TXHMm7po1AcnFk8iu2S2IeU/+/A+Q== - dependencies: - tslib "^1.11.1" - -"@aws-crypto/sha256-browser@3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-browser/-/sha256-browser-3.0.0.tgz#05f160138ab893f1c6ba5be57cfd108f05827766" - integrity sha512-8VLmW2B+gjFbU5uMeqtQM6Nj0/F1bro80xQXCW6CQBWgosFWXTx77aeOF5CAIAmbOK64SdMBJdNr6J41yP5mvQ== - dependencies: - "@aws-crypto/ie11-detection" "^3.0.0" - "@aws-crypto/sha256-js" "^3.0.0" - "@aws-crypto/supports-web-crypto" "^3.0.0" - "@aws-crypto/util" "^3.0.0" - "@aws-sdk/types" "^3.222.0" - "@aws-sdk/util-locate-window" "^3.0.0" - "@aws-sdk/util-utf8-browser" "^3.0.0" - tslib "^1.11.1" - -"@aws-crypto/sha256-js@3.0.0", "@aws-crypto/sha256-js@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-js/-/sha256-js-3.0.0.tgz#f06b84d550d25521e60d2a0e2a90139341e007c2" - integrity sha512-PnNN7os0+yd1XvXAy23CFOmTbMaDxgxXtTKHybrJ39Y8kGzBATgBFibWJKH6BhytLI/Zyszs87xCOBNyBig6vQ== - dependencies: - "@aws-crypto/util" "^3.0.0" - "@aws-sdk/types" "^3.222.0" - tslib "^1.11.1" - -"@aws-crypto/supports-web-crypto@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/supports-web-crypto/-/supports-web-crypto-3.0.0.tgz#5d1bf825afa8072af2717c3e455f35cda0103ec2" - integrity sha512-06hBdMwUAb2WFTuGG73LSC0wfPu93xWwo5vL2et9eymgmu3Id5vFAHBbajVWiGhPO37qcsdCap/FqXvJGJWPIg== - dependencies: - tslib "^1.11.1" - -"@aws-crypto/util@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@aws-crypto/util/-/util-3.0.0.tgz#1c7ca90c29293f0883468ad48117937f0fe5bfb0" - integrity sha512-2OJlpeJpCR48CC8r+uKVChzs9Iungj9wkZrl8Z041DWEWvyIHILYKCPNzJghKsivj+S3mLo6BVc7mBNzdxA46w== - dependencies: - "@aws-sdk/types" "^3.222.0" - "@aws-sdk/util-utf8-browser" "^3.0.0" - tslib "^1.11.1" - -"@aws-sdk/client-cognito-identity@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.504.0.tgz#d0be72f2f88d1fc6f1bd66729c41a78cb191e72c" - integrity sha512-WsQY6CRDC9Y1rKjpsk187EHKES6nLmM9sD6iHAKZFLhi/DiYsy8SIafPFPEvluubYlheeLzgUB8Oxpj6Z69hlA== - dependencies: - "@aws-crypto/sha256-browser" "3.0.0" - "@aws-crypto/sha256-js" "3.0.0" - "@aws-sdk/client-sts" "3.504.0" - "@aws-sdk/core" "3.496.0" - "@aws-sdk/credential-provider-node" "3.504.0" - "@aws-sdk/middleware-host-header" "3.502.0" - "@aws-sdk/middleware-logger" "3.502.0" - "@aws-sdk/middleware-recursion-detection" "3.502.0" - "@aws-sdk/middleware-signing" "3.502.0" - "@aws-sdk/middleware-user-agent" "3.502.0" - "@aws-sdk/region-config-resolver" "3.502.0" - "@aws-sdk/types" "3.502.0" - "@aws-sdk/util-endpoints" "3.502.0" - "@aws-sdk/util-user-agent-browser" "3.502.0" - "@aws-sdk/util-user-agent-node" "3.502.0" - "@smithy/config-resolver" "^2.1.1" - "@smithy/core" "^1.3.1" - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/hash-node" "^2.1.1" - "@smithy/invalid-dependency" "^2.1.1" - "@smithy/middleware-content-length" "^2.1.1" - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-retry" "^2.1.1" - "@smithy/middleware-serde" "^2.1.1" - "@smithy/middleware-stack" "^2.1.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - "@smithy/util-base64" "^2.1.1" - "@smithy/util-body-length-browser" "^2.1.1" - "@smithy/util-body-length-node" "^2.2.1" - "@smithy/util-defaults-mode-browser" "^2.1.1" - "@smithy/util-defaults-mode-node" "^2.1.1" - "@smithy/util-endpoints" "^1.1.1" - "@smithy/util-retry" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/client-sso-oidc@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.504.0.tgz#78ed1e921fcda039e8525a92bf5760e8bd0091a8" - integrity sha512-ODA33/nm2srhV08EW0KZAP577UgV0qjyr7Xp2yEo8MXWL4ZqQZprk1c+QKBhjr4Djesrm0VPmSD/np0mtYP68A== - dependencies: - "@aws-crypto/sha256-browser" "3.0.0" - "@aws-crypto/sha256-js" "3.0.0" - "@aws-sdk/client-sts" "3.504.0" - "@aws-sdk/core" "3.496.0" - "@aws-sdk/middleware-host-header" "3.502.0" - "@aws-sdk/middleware-logger" "3.502.0" - "@aws-sdk/middleware-recursion-detection" "3.502.0" - "@aws-sdk/middleware-signing" "3.502.0" - "@aws-sdk/middleware-user-agent" "3.502.0" - "@aws-sdk/region-config-resolver" "3.502.0" - "@aws-sdk/types" "3.502.0" - "@aws-sdk/util-endpoints" "3.502.0" - "@aws-sdk/util-user-agent-browser" "3.502.0" - "@aws-sdk/util-user-agent-node" "3.502.0" - "@smithy/config-resolver" "^2.1.1" - "@smithy/core" "^1.3.1" - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/hash-node" "^2.1.1" - "@smithy/invalid-dependency" "^2.1.1" - "@smithy/middleware-content-length" "^2.1.1" - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-retry" "^2.1.1" - "@smithy/middleware-serde" "^2.1.1" - "@smithy/middleware-stack" "^2.1.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - "@smithy/util-base64" "^2.1.1" - "@smithy/util-body-length-browser" "^2.1.1" - "@smithy/util-body-length-node" "^2.2.1" - "@smithy/util-defaults-mode-browser" "^2.1.1" - "@smithy/util-defaults-mode-node" "^2.1.1" - "@smithy/util-endpoints" "^1.1.1" - "@smithy/util-retry" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/client-sso@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/client-sso/-/client-sso-3.502.0.tgz#8cf21d8f52a5bef65bf7b458051b3f61f7db822c" - integrity sha512-OZAYal1+PQgUUtWiHhRayDtX0OD+XpXHKAhjYgEIPbyhQaCMp3/Bq1xDX151piWXvXqXLJHFKb8DUEqzwGO9QA== - dependencies: - "@aws-crypto/sha256-browser" "3.0.0" - "@aws-crypto/sha256-js" "3.0.0" - "@aws-sdk/core" "3.496.0" - "@aws-sdk/middleware-host-header" "3.502.0" - "@aws-sdk/middleware-logger" "3.502.0" - "@aws-sdk/middleware-recursion-detection" "3.502.0" - "@aws-sdk/middleware-user-agent" "3.502.0" - "@aws-sdk/region-config-resolver" "3.502.0" - "@aws-sdk/types" "3.502.0" - "@aws-sdk/util-endpoints" "3.502.0" - "@aws-sdk/util-user-agent-browser" "3.502.0" - "@aws-sdk/util-user-agent-node" "3.502.0" - "@smithy/config-resolver" "^2.1.1" - "@smithy/core" "^1.3.1" - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/hash-node" "^2.1.1" - "@smithy/invalid-dependency" "^2.1.1" - "@smithy/middleware-content-length" "^2.1.1" - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-retry" "^2.1.1" - "@smithy/middleware-serde" "^2.1.1" - "@smithy/middleware-stack" "^2.1.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - "@smithy/util-base64" "^2.1.1" - "@smithy/util-body-length-browser" "^2.1.1" - "@smithy/util-body-length-node" "^2.2.1" - "@smithy/util-defaults-mode-browser" "^2.1.1" - "@smithy/util-defaults-mode-node" "^2.1.1" - "@smithy/util-endpoints" "^1.1.1" - "@smithy/util-retry" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/client-sts@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/client-sts/-/client-sts-3.504.0.tgz#78a0beaf988ad2647d79c7157083dfd55953f41e" - integrity sha512-IESs8FkL7B/uY+ml4wgoRkrr6xYo4PizcNw6JX17eveq1gRBCPKeGMjE6HTDOcIYZZ8rqz/UeuH3JD4UhrMOnA== - dependencies: - "@aws-crypto/sha256-browser" "3.0.0" - "@aws-crypto/sha256-js" "3.0.0" - "@aws-sdk/core" "3.496.0" - "@aws-sdk/middleware-host-header" "3.502.0" - "@aws-sdk/middleware-logger" "3.502.0" - "@aws-sdk/middleware-recursion-detection" "3.502.0" - "@aws-sdk/middleware-user-agent" "3.502.0" - "@aws-sdk/region-config-resolver" "3.502.0" - "@aws-sdk/types" "3.502.0" - "@aws-sdk/util-endpoints" "3.502.0" - "@aws-sdk/util-user-agent-browser" "3.502.0" - "@aws-sdk/util-user-agent-node" "3.502.0" - "@smithy/config-resolver" "^2.1.1" - "@smithy/core" "^1.3.1" - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/hash-node" "^2.1.1" - "@smithy/invalid-dependency" "^2.1.1" - "@smithy/middleware-content-length" "^2.1.1" - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-retry" "^2.1.1" - "@smithy/middleware-serde" "^2.1.1" - "@smithy/middleware-stack" "^2.1.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - "@smithy/util-base64" "^2.1.1" - "@smithy/util-body-length-browser" "^2.1.1" - "@smithy/util-body-length-node" "^2.2.1" - "@smithy/util-defaults-mode-browser" "^2.1.1" - "@smithy/util-defaults-mode-node" "^2.1.1" - "@smithy/util-endpoints" "^1.1.1" - "@smithy/util-middleware" "^2.1.1" - "@smithy/util-retry" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - fast-xml-parser "4.2.5" - tslib "^2.5.0" - -"@aws-sdk/core@3.496.0": - version "3.496.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/core/-/core-3.496.0.tgz#ec1394753b6b2f6e38aea593e30b2db5c7390969" - integrity sha512-yT+ug7Cw/3eJi7x2es0+46x12+cIJm5Xv+GPWsrTFD1TKgqO/VPEgfDtHFagDNbFmjNQA65Ygc/kEdIX9ICX/A== - dependencies: - "@smithy/core" "^1.3.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/signature-v4" "^2.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-cognito-identity@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.504.0.tgz#adc60ad74f67c54a3f3120f231f89f1d2324b35e" - integrity sha512-QRmKLl4wM7Yd1HBzUdHIA+QhQxLROXptQjwMNL+KNfl5vMFYOUt0FMXwg80DRHl7qEScvZZEDovcswuuw5Uo2w== - dependencies: - "@aws-sdk/client-cognito-identity" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-env@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-env/-/credential-provider-env-3.502.0.tgz#800e63b2b9d90b078a120d474d5a3b1ec5b48514" - integrity sha512-KIB8Ae1Z7domMU/jU4KiIgK4tmYgvuXlhR54ehwlVHxnEoFPoPuGHFZU7oFn79jhhSLUFQ1lRYMxP0cEwb7XeQ== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-http@3.503.1": - version "3.503.1" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-http/-/credential-provider-http-3.503.1.tgz#e882a4b740c9193650053033b3001b03ca4b12c8" - integrity sha512-rTdlFFGoPPFMF2YjtlfRuSgKI+XsF49u7d98255hySwhsbwd3Xp+utTTPquxP+CwDxMHbDlI7NxDzFiFdsoZug== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/util-stream" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-ini@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.504.0.tgz#d463dae3a309c1e9181811f27c484fd9bfa6821f" - integrity sha512-ODICLXfr8xTUd3wweprH32Ge41yuBa+u3j0JUcLdTUO1N9ldczSMdo8zOPlP0z4doqD3xbnqMkjNQWgN/Q+5oQ== - dependencies: - "@aws-sdk/client-sts" "3.504.0" - "@aws-sdk/credential-provider-env" "3.502.0" - "@aws-sdk/credential-provider-process" "3.502.0" - "@aws-sdk/credential-provider-sso" "3.504.0" - "@aws-sdk/credential-provider-web-identity" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/credential-provider-imds" "^2.2.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-node@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-node/-/credential-provider-node-3.504.0.tgz#c6014f56dd59be295114290164e00375d33f2952" - integrity sha512-6+V5hIh+tILmUjf2ZQWQINR3atxQVgH/bFrGdSR/sHSp/tEgw3m0xWL3IRslWU1e4/GtXrfg1iYnMknXy68Ikw== - dependencies: - "@aws-sdk/credential-provider-env" "3.502.0" - "@aws-sdk/credential-provider-http" "3.503.1" - "@aws-sdk/credential-provider-ini" "3.504.0" - "@aws-sdk/credential-provider-process" "3.502.0" - "@aws-sdk/credential-provider-sso" "3.504.0" - "@aws-sdk/credential-provider-web-identity" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/credential-provider-imds" "^2.2.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-process@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-process/-/credential-provider-process-3.502.0.tgz#6c41d8845a1c7073491a064c158363de04640381" - integrity sha512-fJJowOjQ4infYQX0E1J3xFVlmuwEYJAFk0Mo1qwafWmEthsBJs+6BR2RiWDELHKrSK35u4Pf3fu3RkYuCtmQFw== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-sso@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.504.0.tgz#ad036805e8677f6a53b24aa82991596aa11ac605" - integrity sha512-4MgH2or2SjPzaxM08DCW+BjaX4DSsEGJlicHKmz6fh+w9JmLh750oXcTnbvgUeVz075jcs6qTKjvUcsdGM/t8Q== - dependencies: - "@aws-sdk/client-sso" "3.502.0" - "@aws-sdk/token-providers" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-provider-web-identity@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.504.0.tgz#53de7dee538ecaeec534e369bca76c546b8f4cc5" - integrity sha512-L1ljCvGpIEFdJk087ijf2ohg7HBclOeB1UgBxUBBzf4iPRZTQzd2chGaKj0hm2VVaXz7nglswJeURH5PFcS5oA== - dependencies: - "@aws-sdk/client-sts" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/credential-providers@^3.186.0": - version "3.504.1" - resolved "https://registry.yarnpkg.com/@aws-sdk/credential-providers/-/credential-providers-3.504.1.tgz#cdca40b79f1b8d1e7476e6fde3196015f4f16596" - integrity sha512-D/ef7ZVxJVXC1qe6ZMS0dOWM92LNHJRHn9Biz5eRqRvRhNL+Rq68ZULlc0TQTVY71Fcc5TJ8OwFhaboPUiqWXA== - dependencies: - "@aws-sdk/client-cognito-identity" "3.504.0" - "@aws-sdk/client-sso" "3.502.0" - "@aws-sdk/client-sts" "3.504.0" - "@aws-sdk/credential-provider-cognito-identity" "3.504.0" - "@aws-sdk/credential-provider-env" "3.502.0" - "@aws-sdk/credential-provider-http" "3.503.1" - "@aws-sdk/credential-provider-ini" "3.504.0" - "@aws-sdk/credential-provider-node" "3.504.0" - "@aws-sdk/credential-provider-process" "3.502.0" - "@aws-sdk/credential-provider-sso" "3.504.0" - "@aws-sdk/credential-provider-web-identity" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/credential-provider-imds" "^2.2.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/middleware-host-header@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-host-header/-/middleware-host-header-3.502.0.tgz#2651fb3509990271c89eb50133fb17cb8ae435f6" - integrity sha512-EjnG0GTYXT/wJBmm5/mTjDcAkzU8L7wQjOzd3FTXuTCNNyvAvwrszbOj5FlarEw5XJBbQiZtBs+I5u9+zy560w== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/protocol-http" "^3.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/middleware-logger@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-logger/-/middleware-logger-3.502.0.tgz#558cefdd233779f15687957f9f07497199b22d72" - integrity sha512-FDyv6K4nCoHxbjLGS2H8ex8I0KDIiu4FJgVRPs140ZJy6gE5Pwxzv6YTzZGLMrnqcIs9gh065Lf6DjwMelZqaw== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/middleware-recursion-detection@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-recursion-detection/-/middleware-recursion-detection-3.502.0.tgz#c22e2c0c1d551e58c788264687324bb7186af2cc" - integrity sha512-hvbyGJbxeuezxOu8VfFmcV4ql1hKXLxHTe5FNYfEBat2KaZXVhc1Hg+4TvB06/53p+E8J99Afmumkqbxs2esUA== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/protocol-http" "^3.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/middleware-signing@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-signing/-/middleware-signing-3.502.0.tgz#48b3503147eecb1a53a63633462de353668f635a" - integrity sha512-4hF08vSzJ7L6sB+393gOFj3s2N6nLusYS0XrMW6wYNFU10IDdbf8Z3TZ7gysDJJHEGQPmTAesPEDBsasGWcMxg== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/signature-v4" "^2.1.1" - "@smithy/types" "^2.9.1" - "@smithy/util-middleware" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/middleware-user-agent@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/middleware-user-agent/-/middleware-user-agent-3.502.0.tgz#dd740f150d6f3110cf5b08fedf361d202f899c93" - integrity sha512-TxbBZbRiXPH0AUxegqiNd9aM9zNSbfjtBs5MEfcBsweeT/B2O7K1EjP9+CkB8Xmk/5FLKhAKLr19b1TNoE27rw== - dependencies: - "@aws-sdk/types" "3.502.0" - "@aws-sdk/util-endpoints" "3.502.0" - "@smithy/protocol-http" "^3.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/region-config-resolver@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/region-config-resolver/-/region-config-resolver-3.502.0.tgz#c18a04060879eb03c47c05b05fc296119ee073ba" - integrity sha512-mxmsX2AGgnSM+Sah7mcQCIneOsJQNiLX0COwEttuf8eO+6cLMAZvVudH3BnWTfea4/A9nuri9DLCqBvEmPrilg== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/types" "^2.9.1" - "@smithy/util-config-provider" "^2.2.1" - "@smithy/util-middleware" "^2.1.1" - tslib "^2.5.0" - -"@aws-sdk/token-providers@3.504.0": - version "3.504.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/token-providers/-/token-providers-3.504.0.tgz#f7f60b1152458e7094529ea3f3ced6ce92eece9f" - integrity sha512-YIJWWsZi2ClUiILS1uh5L6VjmCUSTI6KKMuL9DkGjYqJ0aI6M8bd8fT9Wm7QmXCyjcArTgr/Atkhia4T7oKvzQ== - dependencies: - "@aws-sdk/client-sso-oidc" "3.504.0" - "@aws-sdk/types" "3.502.0" - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/types@3.502.0", "@aws-sdk/types@^3.222.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.502.0.tgz#c23dda4df7fdbe32642d4f5ab23516f455fb6aba" - integrity sha512-M0DSPYe/gXhwD2QHgoukaZv5oDxhW3FfvYIrJptyqUq3OnPJBcDbihHjrE0PBtfh/9kgMZT60/fQ2NVFANfa2g== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/util-endpoints@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/util-endpoints/-/util-endpoints-3.502.0.tgz#aee818c0c53dfedfd49599fc260cd880faea5e82" - integrity sha512-6LKFlJPp2J24r1Kpfoz5ESQn+1v5fEjDB3mtUKRdpwarhm3syu7HbKlHCF3KbcCOyahobvLvhoedT78rJFEeeg== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/types" "^2.9.1" - "@smithy/util-endpoints" "^1.1.1" - tslib "^2.5.0" - -"@aws-sdk/util-locate-window@^3.0.0": - version "3.495.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/util-locate-window/-/util-locate-window-3.495.0.tgz#9034fd8db77991b28ed20e067acdd53e8b8f824b" - integrity sha512-MfaPXT0kLX2tQaR90saBT9fWQq2DHqSSJRzW+MZWsmF+y5LGCOhO22ac/2o6TKSQm7h0HRc2GaADqYYYor62yg== - dependencies: - tslib "^2.5.0" - -"@aws-sdk/util-user-agent-browser@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/util-user-agent-browser/-/util-user-agent-browser-3.502.0.tgz#87b42abff6944052c78a84981637ac21859dd016" - integrity sha512-v8gKyCs2obXoIkLETAeEQ3AM+QmhHhst9xbM1cJtKUGsRlVIak/XyyD+kVE6kmMm1cjfudHpHKABWk9apQcIZQ== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/types" "^2.9.1" - bowser "^2.11.0" - tslib "^2.5.0" - -"@aws-sdk/util-user-agent-node@3.502.0": - version "3.502.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/util-user-agent-node/-/util-user-agent-node-3.502.0.tgz#04ac4d0371d4f243f12ddc23b42ca8ceb27dfad9" - integrity sha512-9RjxpkGZKbTdl96tIJvAo+vZoz4P/cQh36SBUt9xfRfW0BtsaLyvSrvlR5wyUYhvRcC12Axqh/8JtnAPq//+Vw== - dependencies: - "@aws-sdk/types" "3.502.0" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@aws-sdk/util-utf8-browser@^3.0.0": - version "3.259.0" - resolved "https://registry.yarnpkg.com/@aws-sdk/util-utf8-browser/-/util-utf8-browser-3.259.0.tgz#3275a6f5eb334f96ca76635b961d3c50259fd9ff" - integrity sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw== - dependencies: - tslib "^2.3.1" - "@babel/code-frame@7.12.11": version "7.12.11" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" @@ -772,13 +269,6 @@ resolved "https://registry.yarnpkg.com/@matejmazur/react-katex/-/react-katex-3.1.3.tgz#f07404c848b93bfef9ed9653a4bb080dc8bf2bf0" integrity sha512-rBp7mJ9An7ktNoU653BWOYdO4FoR4YNwofHZi+vaytX/nWbIlmHVIF+X8VFOn6c3WYmrLT5FFBjKqCZ1sjR5uQ== -"@mongodb-js/saslprep@^1.1.0": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz#24ec1c4915a65f5c506bb88c081731450d91bb1c" - integrity sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw== - dependencies: - sparse-bitfield "^3.0.3" - "@next/bundle-analyzer@^12.1.1": version "12.3.4" resolved "https://registry.yarnpkg.com/@next/bundle-analyzer/-/bundle-analyzer-12.3.4.tgz#37c587525288a3dea64213c991590532246e8bb8" @@ -889,383 +379,6 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== -"@smithy/abort-controller@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/abort-controller/-/abort-controller-2.1.1.tgz#bb68596a7c8213c2ef259bc7fb0f0c118c67ea9d" - integrity sha512-1+qdrUqLhaALYL0iOcN43EP6yAXXQ2wWZ6taf4S2pNGowmOc5gx+iMQv+E42JizNJjB0+gEadOXeV1Bf7JWL1Q== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/config-resolver@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/config-resolver/-/config-resolver-2.1.1.tgz#fc6b036084b98fd26a8ff01a5d7eb676e41749c7" - integrity sha512-lxfLDpZm+AWAHPFZps5JfDoO9Ux1764fOgvRUBpHIO8HWHcSN1dkgsago1qLRVgm1BZ8RCm8cgv99QvtaOWIhw== - dependencies: - "@smithy/node-config-provider" "^2.2.1" - "@smithy/types" "^2.9.1" - "@smithy/util-config-provider" "^2.2.1" - "@smithy/util-middleware" "^2.1.1" - tslib "^2.5.0" - -"@smithy/core@^1.3.1": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@smithy/core/-/core-1.3.1.tgz#ecedc564e68453b02c20db9e8435d59005c066d8" - integrity sha512-tf+NIu9FkOh312b6M9G4D68is4Xr7qptzaZGZUREELF8ysE1yLKphqt7nsomjKZVwW7WE5pDDex9idowNGRQ/Q== - dependencies: - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-retry" "^2.1.1" - "@smithy/middleware-serde" "^2.1.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/util-middleware" "^2.1.1" - tslib "^2.5.0" - -"@smithy/credential-provider-imds@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@smithy/credential-provider-imds/-/credential-provider-imds-2.2.1.tgz#4805bf5e104718b959cf8699113fa9de6ddeeafa" - integrity sha512-7XHjZUxmZYnONheVQL7j5zvZXga+EWNgwEAP6OPZTi7l8J4JTeNh9aIOfE5fKHZ/ee2IeNOh54ZrSna+Vc6TFA== - dependencies: - "@smithy/node-config-provider" "^2.2.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - tslib "^2.5.0" - -"@smithy/eventstream-codec@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/eventstream-codec/-/eventstream-codec-2.1.1.tgz#4405ab0f9c77d439c575560c4886e59ee17d6d38" - integrity sha512-E8KYBxBIuU4c+zrpR22VsVrOPoEDzk35bQR3E+xm4k6Pa6JqzkDOdMyf9Atac5GPNKHJBdVaQ4JtjdWX2rl/nw== - dependencies: - "@aws-crypto/crc32" "3.0.0" - "@smithy/types" "^2.9.1" - "@smithy/util-hex-encoding" "^2.1.1" - tslib "^2.5.0" - -"@smithy/fetch-http-handler@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@smithy/fetch-http-handler/-/fetch-http-handler-2.4.1.tgz#b4d73bbc1449f61234077d58c705b843a8587bf0" - integrity sha512-VYGLinPsFqH68lxfRhjQaSkjXM7JysUOJDTNjHBuN/ykyRb2f1gyavN9+VhhPTWCy32L4yZ2fdhpCs/nStEicg== - dependencies: - "@smithy/protocol-http" "^3.1.1" - "@smithy/querystring-builder" "^2.1.1" - "@smithy/types" "^2.9.1" - "@smithy/util-base64" "^2.1.1" - tslib "^2.5.0" - -"@smithy/hash-node@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/hash-node/-/hash-node-2.1.1.tgz#0f8a22d97565ca948724f72267e4d3a2f33740a8" - integrity sha512-Qhoq0N8f2OtCnvUpCf+g1vSyhYQrZjhSwvJ9qvR8BUGOtTXiyv2x1OD2e6jVGmlpC4E4ax1USHoyGfV9JFsACg== - dependencies: - "@smithy/types" "^2.9.1" - "@smithy/util-buffer-from" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@smithy/invalid-dependency@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/invalid-dependency/-/invalid-dependency-2.1.1.tgz#bd69fa24dd35e9bc65a160bd86becdf1399e4463" - integrity sha512-7WTgnKw+VPg8fxu2v9AlNOQ5yaz6RA54zOVB4f6vQuR0xFKd+RzlCpt0WidYTsye7F+FYDIaS/RnJW4pxjNInw== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/is-array-buffer@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/is-array-buffer/-/is-array-buffer-2.1.1.tgz#07b4c77ae67ed58a84400c76edd482271f9f957b" - integrity sha512-xozSQrcUinPpNPNPds4S7z/FakDTh1MZWtRP/2vQtYB/u3HYrX2UXuZs+VhaKBd6Vc7g2XPr2ZtwGBNDN6fNKQ== - dependencies: - tslib "^2.5.0" - -"@smithy/middleware-content-length@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/middleware-content-length/-/middleware-content-length-2.1.1.tgz#df767de12d594bc5622009fb0fc8343522697d8c" - integrity sha512-rSr9ezUl9qMgiJR0UVtVOGEZElMdGFyl8FzWEF5iEKTlcWxGr2wTqGfDwtH3LAB7h+FPkxqv4ZU4cpuCN9Kf/g== - dependencies: - "@smithy/protocol-http" "^3.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/middleware-endpoint@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@smithy/middleware-endpoint/-/middleware-endpoint-2.4.1.tgz#9e500df4d944741808e92018ccd2e948b598a49f" - integrity sha512-XPZTb1E2Oav60Ven3n2PFx+rX9EDsU/jSTA8VDamt7FXks67ekjPY/XrmmPDQaFJOTUHJNKjd8+kZxVO5Ael4Q== - dependencies: - "@smithy/middleware-serde" "^2.1.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/url-parser" "^2.1.1" - "@smithy/util-middleware" "^2.1.1" - tslib "^2.5.0" - -"@smithy/middleware-retry@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/middleware-retry/-/middleware-retry-2.1.1.tgz#ddc749dd927f136714f76ca5a52dcfb0993ee162" - integrity sha512-eMIHOBTXro6JZ+WWzZWd/8fS8ht5nS5KDQjzhNMHNRcG5FkNTqcKpYhw7TETMYzbLfhO5FYghHy1vqDWM4FLDA== - dependencies: - "@smithy/node-config-provider" "^2.2.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/service-error-classification" "^2.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/util-middleware" "^2.1.1" - "@smithy/util-retry" "^2.1.1" - tslib "^2.5.0" - uuid "^8.3.2" - -"@smithy/middleware-serde@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/middleware-serde/-/middleware-serde-2.1.1.tgz#2c5750f76e276a5249720f6c3c24fac29abbee16" - integrity sha512-D8Gq0aQBeE1pxf3cjWVkRr2W54t+cdM2zx78tNrVhqrDykRA7asq8yVJij1u5NDtKzKqzBSPYh7iW0svUKg76g== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/middleware-stack@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/middleware-stack/-/middleware-stack-2.1.1.tgz#67f992dc36e8a6861f881f80a81c1c30956a0396" - integrity sha512-KPJhRlhsl8CjgGXK/DoDcrFGfAqoqvuwlbxy+uOO4g2Azn1dhH+GVfC3RAp+6PoL5PWPb+vt6Z23FP+Mr6qeCw== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/node-config-provider@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@smithy/node-config-provider/-/node-config-provider-2.2.1.tgz#c440c7948d58d72f0e212aa1967aa12f0729defd" - integrity sha512-epzK3x1xNxA9oJgHQ5nz+2j6DsJKdHfieb+YgJ7ATWxzNcB7Hc+Uya2TUck5MicOPhDV8HZImND7ZOecVr+OWg== - dependencies: - "@smithy/property-provider" "^2.1.1" - "@smithy/shared-ini-file-loader" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/node-http-handler@^2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@smithy/node-http-handler/-/node-http-handler-2.3.1.tgz#77d23279ff0a12cbe7cde93c5e7c0e86ad56dd20" - integrity sha512-gLA8qK2nL9J0Rk/WEZSvgin4AppvuCYRYg61dcUo/uKxvMZsMInL5I5ZdJTogOvdfVug3N2dgI5ffcUfS4S9PA== - dependencies: - "@smithy/abort-controller" "^2.1.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/querystring-builder" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/property-provider@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/property-provider/-/property-provider-2.1.1.tgz#0f7ffc5e43829eaca5b2b5aae8554807a52b30f3" - integrity sha512-FX7JhhD/o5HwSwg6GLK9zxrMUrGnb3PzNBrcthqHKBc3dH0UfgEAU24xnJ8F0uow5mj17UeBEOI6o3CF2k7Mhw== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/protocol-http@^3.1.1": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@smithy/protocol-http/-/protocol-http-3.1.1.tgz#eee522d0ed964a72b735d64925e07bcfb7a7806f" - integrity sha512-6ZRTSsaXuSL9++qEwH851hJjUA0OgXdQFCs+VDw4tGH256jQ3TjYY/i34N4vd24RV3nrjNsgd1yhb57uMoKbzQ== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/querystring-builder@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/querystring-builder/-/querystring-builder-2.1.1.tgz#b9693448ad3f8e0767d84cf5cae29f35514591fb" - integrity sha512-C/ko/CeEa8jdYE4gt6nHO5XDrlSJ3vdCG0ZAc6nD5ZIE7LBp0jCx4qoqp7eoutBu7VrGMXERSRoPqwi1WjCPbg== - dependencies: - "@smithy/types" "^2.9.1" - "@smithy/util-uri-escape" "^2.1.1" - tslib "^2.5.0" - -"@smithy/querystring-parser@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/querystring-parser/-/querystring-parser-2.1.1.tgz#a4282a66cc56844317dbff824e573f469bbfc032" - integrity sha512-H4+6jKGVhG1W4CIxfBaSsbm98lOO88tpDWmZLgkJpt8Zkk/+uG0FmmqMuCAc3HNM2ZDV+JbErxr0l5BcuIf/XQ== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/service-error-classification@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/service-error-classification/-/service-error-classification-2.1.1.tgz#dd24e1ec529ae9ec8e87d8b15f0fc8f7e17f3d02" - integrity sha512-txEdZxPUgM1PwGvDvHzqhXisrc5LlRWYCf2yyHfvITWioAKat7srQvpjMAvgzf0t6t7j8yHrryXU9xt7RZqFpw== - dependencies: - "@smithy/types" "^2.9.1" - -"@smithy/shared-ini-file-loader@^2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@smithy/shared-ini-file-loader/-/shared-ini-file-loader-2.3.1.tgz#a2e28b4d85f8a8262a84403fa2b74a086b3a7703" - integrity sha512-2E2kh24igmIznHLB6H05Na4OgIEilRu0oQpYXo3LCNRrawHAcfDKq9004zJs+sAMt2X5AbY87CUCJ7IpqpSgdw== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/signature-v4@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/signature-v4/-/signature-v4-2.1.1.tgz#6080171e3d694f40d3f553bbc236c5c433efd4d2" - integrity sha512-Hb7xub0NHuvvQD3YwDSdanBmYukoEkhqBjqoxo+bSdC0ryV9cTfgmNjuAQhTPYB6yeU7hTR+sPRiFMlxqv6kmg== - dependencies: - "@smithy/eventstream-codec" "^2.1.1" - "@smithy/is-array-buffer" "^2.1.1" - "@smithy/types" "^2.9.1" - "@smithy/util-hex-encoding" "^2.1.1" - "@smithy/util-middleware" "^2.1.1" - "@smithy/util-uri-escape" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@smithy/smithy-client@^2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@smithy/smithy-client/-/smithy-client-2.3.1.tgz#0c3a4a0d3935c7ad2240cc23181f276705212b1f" - integrity sha512-YsTdU8xVD64r2pLEwmltrNvZV6XIAC50LN6ivDopdt+YiF/jGH6PY9zUOu0CXD/d8GMB8gbhnpPsdrjAXHS9QA== - dependencies: - "@smithy/middleware-endpoint" "^2.4.1" - "@smithy/middleware-stack" "^2.1.1" - "@smithy/protocol-http" "^3.1.1" - "@smithy/types" "^2.9.1" - "@smithy/util-stream" "^2.1.1" - tslib "^2.5.0" - -"@smithy/types@^2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@smithy/types/-/types-2.9.1.tgz#ed04d4144eed3b8bd26d20fc85aae8d6e357ebb9" - integrity sha512-vjXlKNXyprDYDuJ7UW5iobdmyDm6g8dDG+BFUncAg/3XJaN45Gy5RWWWUVgrzIK7S4R1KWgIX5LeJcfvSI24bw== - dependencies: - tslib "^2.5.0" - -"@smithy/url-parser@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/url-parser/-/url-parser-2.1.1.tgz#a30de227b6734650d740b6dff74d488b874e85e3" - integrity sha512-qC9Bv8f/vvFIEkHsiNrUKYNl8uKQnn4BdhXl7VzQRP774AwIjiSMMwkbT+L7Fk8W8rzYVifzJNYxv1HwvfBo3Q== - dependencies: - "@smithy/querystring-parser" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/util-base64@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-base64/-/util-base64-2.1.1.tgz#af729085cc9d92ebd54a5d2c5d0aa5a0c31f83bf" - integrity sha512-UfHVpY7qfF/MrgndI5PexSKVTxSZIdz9InghTFa49QOvuu9I52zLPLUHXvHpNuMb1iD2vmc6R+zbv/bdMipR/g== - dependencies: - "@smithy/util-buffer-from" "^2.1.1" - tslib "^2.5.0" - -"@smithy/util-body-length-browser@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-body-length-browser/-/util-body-length-browser-2.1.1.tgz#1fc77072768013ae646415eedb9833cd252d055d" - integrity sha512-ekOGBLvs1VS2d1zM2ER4JEeBWAvIOUKeaFch29UjjJsxmZ/f0L3K3x0dEETgh3Q9bkZNHgT+rkdl/J/VUqSRag== - dependencies: - tslib "^2.5.0" - -"@smithy/util-body-length-node@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@smithy/util-body-length-node/-/util-body-length-node-2.2.1.tgz#a6f5c9911f1c3e23efb340d5ce7a590b62f2056e" - integrity sha512-/ggJG+ta3IDtpNVq4ktmEUtOkH1LW64RHB5B0hcr5ZaWBmo96UX2cIOVbjCqqDickTXqBWZ4ZO0APuaPrD7Abg== - dependencies: - tslib "^2.5.0" - -"@smithy/util-buffer-from@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-buffer-from/-/util-buffer-from-2.1.1.tgz#f9346bf8b23c5ba6f6bdb61dd9db779441ba8d08" - integrity sha512-clhNjbyfqIv9Md2Mg6FffGVrJxw7bgK7s3Iax36xnfVj6cg0fUG7I4RH0XgXJF8bxi+saY5HR21g2UPKSxVCXg== - dependencies: - "@smithy/is-array-buffer" "^2.1.1" - tslib "^2.5.0" - -"@smithy/util-config-provider@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@smithy/util-config-provider/-/util-config-provider-2.2.1.tgz#aea0a80236d6cedaee60473802899cff4a8cc0ba" - integrity sha512-50VL/tx9oYYcjJn/qKqNy7sCtpD0+s8XEBamIFo4mFFTclKMNp+rsnymD796uybjiIquB7VCB/DeafduL0y2kw== - dependencies: - tslib "^2.5.0" - -"@smithy/util-defaults-mode-browser@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.1.1.tgz#be9ac82acee6ec4821b610e7187b0e147f0ba8ff" - integrity sha512-lqLz/9aWRO6mosnXkArtRuQqqZBhNpgI65YDpww4rVQBuUT7qzKbDLG5AmnQTCiU4rOquaZO/Kt0J7q9Uic7MA== - dependencies: - "@smithy/property-provider" "^2.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - bowser "^2.11.0" - tslib "^2.5.0" - -"@smithy/util-defaults-mode-node@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.1.1.tgz#0910ee00aac3e8a08aac3e6ae8794e52f3efef02" - integrity sha512-tYVrc+w+jSBfBd267KDnvSGOh4NMz+wVH7v4CClDbkdPfnjvImBZsOURncT5jsFwR9KCuDyPoSZq4Pa6+eCUrA== - dependencies: - "@smithy/config-resolver" "^2.1.1" - "@smithy/credential-provider-imds" "^2.2.1" - "@smithy/node-config-provider" "^2.2.1" - "@smithy/property-provider" "^2.1.1" - "@smithy/smithy-client" "^2.3.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/util-endpoints@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-endpoints/-/util-endpoints-1.1.1.tgz#45426dba6fb42282a0ad955600b2b3ba050d118f" - integrity sha512-sI4d9rjoaekSGEtq3xSb2nMjHMx8QXcz2cexnVyRWsy4yQ9z3kbDpX+7fN0jnbdOp0b3KSTZJZ2Yb92JWSanLw== - dependencies: - "@smithy/node-config-provider" "^2.2.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/util-hex-encoding@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-hex-encoding/-/util-hex-encoding-2.1.1.tgz#978252b9fb242e0a59bae4ead491210688e0d15f" - integrity sha512-3UNdP2pkYUUBGEXzQI9ODTDK+Tcu1BlCyDBaRHwyxhA+8xLP8agEKQq4MGmpjqb4VQAjq9TwlCQX0kP6XDKYLg== - dependencies: - tslib "^2.5.0" - -"@smithy/util-middleware@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-middleware/-/util-middleware-2.1.1.tgz#903ba19bb17704f4b476fb9ade9bf9eb0174bc3d" - integrity sha512-mKNrk8oz5zqkNcbcgAAepeJbmfUW6ogrT2Z2gDbIUzVzNAHKJQTYmH9jcy0jbWb+m7ubrvXKb6uMjkSgAqqsFA== - dependencies: - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/util-retry@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-retry/-/util-retry-2.1.1.tgz#f2d3566b6e5b841028c7240c852007d4037e49b2" - integrity sha512-Mg+xxWPTeSPrthpC5WAamJ6PW4Kbo01Fm7lWM1jmGRvmrRdsd3192Gz2fBXAMURyXpaNxyZf6Hr/nQ4q70oVEA== - dependencies: - "@smithy/service-error-classification" "^2.1.1" - "@smithy/types" "^2.9.1" - tslib "^2.5.0" - -"@smithy/util-stream@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-stream/-/util-stream-2.1.1.tgz#3ae0e88c3a1a45899e29c1655d2e5a3865b6c0a6" - integrity sha512-J7SMIpUYvU4DQN55KmBtvaMc7NM3CZ2iWICdcgaovtLzseVhAqFRYqloT3mh0esrFw+3VEK6nQFteFsTqZSECQ== - dependencies: - "@smithy/fetch-http-handler" "^2.4.1" - "@smithy/node-http-handler" "^2.3.1" - "@smithy/types" "^2.9.1" - "@smithy/util-base64" "^2.1.1" - "@smithy/util-buffer-from" "^2.1.1" - "@smithy/util-hex-encoding" "^2.1.1" - "@smithy/util-utf8" "^2.1.1" - tslib "^2.5.0" - -"@smithy/util-uri-escape@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-uri-escape/-/util-uri-escape-2.1.1.tgz#7eedc93b73ecda68f12fb9cf92e9fa0fbbed4d83" - integrity sha512-saVzI1h6iRBUVSqtnlOnc9ssU09ypo7n+shdQ8hBTZno/9rZ3AuRYvoHInV57VF7Qn7B+pFJG7qTzFiHxWlWBw== - dependencies: - tslib "^2.5.0" - -"@smithy/util-utf8@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@smithy/util-utf8/-/util-utf8-2.1.1.tgz#690018dd28f47f014114497735e51417ea5900a6" - integrity sha512-BqTpzYEcUMDwAKr7/mVRUtHDhs6ZoXDi9NypMvMfOr/+u1NW7JgqodPDECiiLboEm6bobcPcECxzjtQh865e9A== - dependencies: - "@smithy/util-buffer-from" "^2.1.1" - tslib "^2.5.0" - "@swc/helpers@0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.5.0.tgz#bf1d807b60f7290d0ec763feea7ccdeda06e85f1" @@ -1353,19 +466,6 @@ resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597" integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow== -"@types/webidl-conversions@*": - version "7.0.3" - resolved "https://registry.yarnpkg.com/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz#1306dbfa53768bcbcfc95a1c8cde367975581859" - integrity sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA== - -"@types/whatwg-url@^8.2.1": - version "8.2.2" - resolved "https://registry.yarnpkg.com/@types/whatwg-url/-/whatwg-url-8.2.2.tgz#749d5b3873e845897ada99be4448041d4cc39e63" - integrity sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA== - dependencies: - "@types/node" "*" - "@types/webidl-conversions" "*" - "@typescript-eslint/parser@^5.4.2 || ^6.0.0": version "6.20.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.20.0.tgz#17e314177304bdf498527e3c4b112e41287b7416" @@ -1837,11 +937,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -1852,11 +947,6 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -bowser@^2.11.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/bowser/-/bowser-2.11.0.tgz#5ca3c35757a7aa5771500c70a73a9f91ef420a8f" - integrity sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1889,21 +979,6 @@ browserslist@^4.22.2: node-releases "^2.0.14" update-browserslist-db "^1.0.13" -bson@^4.7.2: - version "4.7.2" - resolved "https://registry.yarnpkg.com/bson/-/bson-4.7.2.tgz#320f4ad0eaf5312dd9b45dc369cc48945e2a5f2e" - integrity sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ== - dependencies: - buffer "^5.6.0" - -buffer@^5.6.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - busboy@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" @@ -2739,13 +1814,6 @@ fast-shallow-equal@^1.0.0: resolved "https://registry.yarnpkg.com/fast-shallow-equal/-/fast-shallow-equal-1.0.0.tgz#d4dcaf6472440dcefa6f88b98e3251e27f25628b" integrity sha512-HPtaa38cPgWvaCFmRNhlc6NG7pv6NUHqjPgVAkWGoB9mQMwYB27/K0CvOM5Czy+qpT3e8XJ6Q4aPAnzpNpzNaw== -fast-xml-parser@4.2.5: - version "4.2.5" - resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz#a6747a09296a6cb34f2ae634019bf1738f3b421f" - integrity sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g== - dependencies: - strnum "^1.0.5" - fastest-stable-stringify@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/fastest-stable-stringify/-/fastest-stable-stringify-2.0.2.tgz#3757a6774f6ec8de40c4e86ec28ea02417214c76" @@ -3094,11 +2162,6 @@ hyphenate-style-name@^1.0.3: resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d" integrity sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ== -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - ignore@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" @@ -3164,11 +2227,6 @@ invariant@^2.2.4: dependencies: loose-envify "^1.0.0" -ip@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" - integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== - is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" @@ -3641,11 +2699,6 @@ memory-cache@^0.2.0: resolved "https://registry.yarnpkg.com/memory-cache/-/memory-cache-0.2.0.tgz#7890b01d52c00c8ebc9d533e1f8eb17e3034871a" integrity sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA== -memory-pager@^1.0.2: - version "1.5.0" - resolved "https://registry.yarnpkg.com/memory-pager/-/memory-pager-1.5.0.tgz#d8751655d22d384682741c972f2c3d6dfa3e66b5" - integrity sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg== - merge-class-names@^1.1.1: version "1.4.2" resolved "https://registry.yarnpkg.com/merge-class-names/-/merge-class-names-1.4.2.tgz#78d6d95ab259e7e647252a7988fd25a27d5a8835" @@ -3720,26 +2773,6 @@ minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== -mongodb-connection-string-url@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz#57901bf352372abdde812c81be47b75c6b2ec5cf" - integrity sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ== - dependencies: - "@types/whatwg-url" "^8.2.1" - whatwg-url "^11.0.0" - -mongodb@^4.6.0: - version "4.17.2" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-4.17.2.tgz#237c0534e36a3449bd74c6bf6d32f87a1ca7200c" - integrity sha512-mLV7SEiov2LHleRJPMPrK2PMyhXFZt2UQLC4VD4pnth3jMjYKHhtqfwwkkvS/NXuo/Fp3vbhaNcXrIDaLRb9Tg== - dependencies: - bson "^4.7.2" - mongodb-connection-string-url "^2.6.0" - socks "^2.7.1" - optionalDependencies: - "@aws-sdk/credential-providers" "^3.186.0" - "@mongodb-js/saslprep" "^1.1.0" - mrmime@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-1.0.1.tgz#5f90c825fad4bdd41dc914eff5d1a8cfdaf24f27" @@ -4195,7 +3228,7 @@ pump@^3.0.0: end-of-stream "^1.1.0" once "^1.3.1" -punycode@^2.1.0, punycode@^2.1.1: +punycode@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== @@ -4639,19 +3672,6 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" -smart-buffer@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" - integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== - -socks@^2.7.1: - version "2.7.1" - resolved "https://registry.yarnpkg.com/socks/-/socks-2.7.1.tgz#d8e651247178fde79c0663043e07240196857d55" - integrity sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ== - dependencies: - ip "^2.0.0" - smart-buffer "^4.2.0" - source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" @@ -4667,13 +3687,6 @@ source-map@^0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sparse-bitfield@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz#ff4ae6e68656056ba4b3e792ab3334d38273ca11" - integrity sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ== - dependencies: - memory-pager "^1.0.2" - spin.js@^2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/spin.js/-/spin.js-2.3.2.tgz#6caa56d520673450fd5cfbc6971e6d0772c37a1a" @@ -4802,11 +3815,6 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== -strnum@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db" - integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA== - styled-jsx@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f" @@ -4959,13 +3967,6 @@ totalist@^3.0.0: resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8" integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ== -tr46@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-3.0.0.tgz#555c4e297a950617e8eeddef633c87d4d9d6cbf9" - integrity sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA== - dependencies: - punycode "^2.1.1" - ts-api-utils@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" @@ -4991,12 +3992,7 @@ tsconfig-paths@^3.15.0: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@^1.11.1: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== - -tslib@^2.1.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.2: +tslib@^2.1.0, tslib@^2.4.0, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== @@ -5097,11 +4093,6 @@ util-deprecate@^1.0.2: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - v8-compile-cache@^2.0.3: version "2.4.0" resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz#cdada8bec61e15865f05d097c5f4fd30e94dc128" @@ -5130,11 +4121,6 @@ warning@^4.0.3: dependencies: loose-envify "^1.0.0" -webidl-conversions@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" - integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== - webpack-bundle-analyzer@4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.3.0.tgz#2f3c0ca9041d5ee47fa418693cf56b4a518b578b" @@ -5169,14 +4155,6 @@ webpack-bundle-analyzer@^4.5.0: sirv "^2.0.3" ws "^7.3.1" -whatwg-url@^11.0.0: - version "11.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-11.0.0.tgz#0a849eebb5faf2119b901bb76fd795c2848d4018" - integrity sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ== - dependencies: - tr46 "^3.0.0" - webidl-conversions "^7.0.0" - which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" From 2385ec802bb233f4f164c881bb411bb4a93b60e9 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 11:11:16 +0800 Subject: [PATCH 04/23] remove package typed.js --- themes/hexo/components/Hero.js | 96 +++++++++++++++++++------------- themes/matery/components/Hero.js | 90 ++++++++++++++++++------------ 2 files changed, 111 insertions(+), 75 deletions(-) diff --git a/themes/hexo/components/Hero.js b/themes/hexo/components/Hero.js index 6c7bb17a..67ae3468 100644 --- a/themes/hexo/components/Hero.js +++ b/themes/hexo/components/Hero.js @@ -1,11 +1,11 @@ // import Image from 'next/image' -import { useEffect, useState } from 'react' -import Typed from 'typed.js' -import CONFIG from '../config' -import NavButtonGroup from './NavButtonGroup' -import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import { loadExternalResource } from '@/lib/utils' +import { useEffect, useState } from 'react' +import CONFIG from '../config' +import NavButtonGroup from './NavButtonGroup' let wrapperTop = 0 @@ -20,21 +20,29 @@ const Hero = props => { const scrollToWrapper = () => { window.scrollTo({ top: wrapperTop, behavior: 'smooth' }) } + const GREETING_WORDS = siteConfig('GREETING_WORDS').split(',') useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { - changeType( - new Typed('#typed', { - strings: GREETING_WORDS, - typeSpeed: 200, - backSpeed: 100, - backDelay: 400, - showCursor: true, - smartBackspace: true - }) - ) + loadExternalResource( + 'https://cdn.jsdelivr.net/npm/typed.js@2.0.12', + 'js' + ).then(() => { + if (window.Typed) { + changeType( + new window.Typed('#typed', { + strings: GREETING_WORDS, + typeSpeed: 200, + backSpeed: 100, + backDelay: 400, + showCursor: true, + smartBackspace: true + }) + ) + } + }) } window.addEventListener('resize', updateHeaderHeight) @@ -51,33 +59,43 @@ const Hero = props => { } return ( - ) } diff --git a/themes/matery/components/Hero.js b/themes/matery/components/Hero.js index cd2f19ab..267ae006 100644 --- a/themes/matery/components/Hero.js +++ b/themes/matery/components/Hero.js @@ -1,10 +1,10 @@ // import Image from 'next/image' -import { useEffect, useState } from 'react' -import Typed from 'typed.js' -import CONFIG from '../config' -import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import { loadExternalResource } from '@/lib/utils' +import { useEffect, useState } from 'react' +import CONFIG from '../config' let wrapperTop = 0 @@ -21,16 +21,23 @@ const Hero = props => { useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { - changeType( - new Typed('#typed', { - strings: GREETING_WORDS, - typeSpeed: 200, - backSpeed: 100, - backDelay: 400, - showCursor: true, - smartBackspace: true - }) - ) + loadExternalResource( + 'https://cdn.jsdelivr.net/npm/typed.js@2.0.12', + 'js' + ).then(() => { + if (window.Typed) { + changeType( + new window.Typed('#typed', { + strings: GREETING_WORDS, + typeSpeed: 200, + backSpeed: 100, + backDelay: 400, + showCursor: true, + smartBackspace: true + }) + ) + } + }) } window.addEventListener('resize', updateHeaderHeight) @@ -47,29 +54,40 @@ const Hero = props => { } return ( - ) } From 1193618bba9955d183ef95a9849b627a19d05948 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 11:15:39 +0800 Subject: [PATCH 05/23] remove package typed.js --- package.json | 3 +- themes/hexo/components/Hero.js | 96 +++++++++++++++++++------------- themes/matery/components/Hero.js | 90 ++++++++++++++++++------------ yarn.lock | 5 -- 4 files changed, 112 insertions(+), 82 deletions(-) diff --git a/package.json b/package.json index 9b130656..314871fa 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,7 @@ "react-hotkeys-hook": "^4.5.0", "react-notion-x": "6.16.0", "react-share": "^4.4.1", - "react-tweet-embed": "~2.0.0", - "typed.js": "^2.0.12" + "react-tweet-embed": "~2.0.0" }, "devDependencies": { "@waline/client": "^2.5.1", diff --git a/themes/hexo/components/Hero.js b/themes/hexo/components/Hero.js index 6c7bb17a..67ae3468 100644 --- a/themes/hexo/components/Hero.js +++ b/themes/hexo/components/Hero.js @@ -1,11 +1,11 @@ // import Image from 'next/image' -import { useEffect, useState } from 'react' -import Typed from 'typed.js' -import CONFIG from '../config' -import NavButtonGroup from './NavButtonGroup' -import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import { loadExternalResource } from '@/lib/utils' +import { useEffect, useState } from 'react' +import CONFIG from '../config' +import NavButtonGroup from './NavButtonGroup' let wrapperTop = 0 @@ -20,21 +20,29 @@ const Hero = props => { const scrollToWrapper = () => { window.scrollTo({ top: wrapperTop, behavior: 'smooth' }) } + const GREETING_WORDS = siteConfig('GREETING_WORDS').split(',') useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { - changeType( - new Typed('#typed', { - strings: GREETING_WORDS, - typeSpeed: 200, - backSpeed: 100, - backDelay: 400, - showCursor: true, - smartBackspace: true - }) - ) + loadExternalResource( + 'https://cdn.jsdelivr.net/npm/typed.js@2.0.12', + 'js' + ).then(() => { + if (window.Typed) { + changeType( + new window.Typed('#typed', { + strings: GREETING_WORDS, + typeSpeed: 200, + backSpeed: 100, + backDelay: 400, + showCursor: true, + smartBackspace: true + }) + ) + } + }) } window.addEventListener('resize', updateHeaderHeight) @@ -51,33 +59,43 @@ const Hero = props => { } return ( - ) } diff --git a/themes/matery/components/Hero.js b/themes/matery/components/Hero.js index cd2f19ab..267ae006 100644 --- a/themes/matery/components/Hero.js +++ b/themes/matery/components/Hero.js @@ -1,10 +1,10 @@ // import Image from 'next/image' -import { useEffect, useState } from 'react' -import Typed from 'typed.js' -import CONFIG from '../config' -import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import { loadExternalResource } from '@/lib/utils' +import { useEffect, useState } from 'react' +import CONFIG from '../config' let wrapperTop = 0 @@ -21,16 +21,23 @@ const Hero = props => { useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { - changeType( - new Typed('#typed', { - strings: GREETING_WORDS, - typeSpeed: 200, - backSpeed: 100, - backDelay: 400, - showCursor: true, - smartBackspace: true - }) - ) + loadExternalResource( + 'https://cdn.jsdelivr.net/npm/typed.js@2.0.12', + 'js' + ).then(() => { + if (window.Typed) { + changeType( + new window.Typed('#typed', { + strings: GREETING_WORDS, + typeSpeed: 200, + backSpeed: 100, + backDelay: 400, + showCursor: true, + smartBackspace: true + }) + ) + } + }) } window.addEventListener('resize', updateHeaderHeight) @@ -47,29 +54,40 @@ const Hero = props => { } return ( - ) } diff --git a/yarn.lock b/yarn.lock index ced20b9f..ffe43bd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4048,11 +4048,6 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" -typed.js@^2.0.12: - version "2.1.0" - resolved "https://registry.yarnpkg.com/typed.js/-/typed.js-2.1.0.tgz#b97a06111a5f57d6a59acfdd36d4f9b891ee13b4" - integrity sha512-bDuXEf7YcaKN4g08NMTUM6G90XU25CK3bh6U0THC/Mod/QPKlEt9g/EjvbYB8x2Qwr2p6J6I3NrsoYaVnY6wsQ== - unbox-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" From 793f9f74d0794d693a6756f402e298a9a94d6410 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 11:35:23 +0800 Subject: [PATCH 06/23] remove package animejs --- components/Fireworks.js | 85 ++++++++++++++++++++++++++--------------- package.json | 1 - yarn.lock | 5 --- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/components/Fireworks.js b/components/Fireworks.js index 8d0c8cd3..b6f1860f 100644 --- a/components/Fireworks.js +++ b/components/Fireworks.js @@ -3,8 +3,9 @@ * custom by hexo-theme-yun @YunYouJun */ import { useEffect } from 'react' -import anime from 'animejs' +// import anime from 'animejs' import { siteConfig } from '@/lib/config' +import { loadExternalResource } from '@/lib/utils' /** * 鼠标点击烟花特效 @@ -14,17 +15,38 @@ const Fireworks = () => { const fireworksColor = siteConfig('FIREWORKS_COLOR') useEffect(() => { - createFireworks({ colors: fireworksColor }) + // 异步加载 + async function loadFireworks() { + console.log('加载烟花') + loadExternalResource( + 'https://cdn.bootcdn.net/ajax/libs/animejs/3.2.1/anime.min.js', + 'js' + ).then(() => { + if (window.anime) { + createFireworks({ + config: { colors: fireworksColor }, + anime: window.anime + }) + } + }) + } + + loadFireworks() + + return () => { + // 在组件卸载时清理资源(如果需要) + } }, []) + return } export default Fireworks /** - * 创建烟花 - * @param config - */ -function createFireworks(config) { + * 创建烟花 + * @param config + */ +function createFireworks({ config, anime }) { const defaultConfig = { colors: config?.colors, numberOfParticules: 20, @@ -57,8 +79,8 @@ function createFireworks(config) { const ctx = canvasEl.getContext('2d') /** - * 设置画布尺寸 - */ + * 设置画布尺寸 + */ function setCanvasSize(canvasEl) { canvasEl.width = window.innerWidth canvasEl.height = window.innerHeight @@ -67,16 +89,16 @@ function createFireworks(config) { } /** - * update pointer - * @param {TouchEvent} e - */ + * update pointer + * @param {TouchEvent} e + */ function updateCoords(e) { pointerX = - e.clientX || - (e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX) + e.clientX || + (e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX) pointerY = - e.clientY || - (e.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY) + e.clientY || + (e.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY) } function setParticuleDirection(p) { @@ -93,26 +115,25 @@ function createFireworks(config) { } /** - * 在指定位置创建粒子 - * @param {number} x - * @param {number} y - * @returns - */ + * 在指定位置创建粒子 + * @param {number} x + * @param {number} y + * @returns + */ function createParticule(x, y) { const p = { x, y, - color: `rgba(${ - colors[anime.random(0, colors.length - 1)] - },${ - anime.random(0.2, 0.8) - })`, + color: `rgba(${colors[anime.random(0, colors.length - 1)]},${anime.random( + 0.2, + 0.8 + )})`, radius: anime.random(config.circleRadius.min, config.circleRadius.max), endPos: null, draw() {} } p.endPos = setParticuleDirection(p) - p.draw = function() { + p.draw = function () { ctx.beginPath() ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true) ctx.fillStyle = p.color @@ -131,7 +152,7 @@ function createFireworks(config) { lineWidth: 6, draw() {} } - p.draw = function() { + p.draw = function () { ctx.globalAlpha = p.alpha ctx.beginPath() ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true) @@ -144,13 +165,17 @@ function createFireworks(config) { } function renderParticule(anim) { - for (let i = 0; i < anim.animatables.length; i++) { anim.animatables[i].target.draw() } + for (let i = 0; i < anim.animatables.length; i++) { + anim.animatables[i].target.draw() + } } function animateParticules(x, y) { const circle = createCircle(x, y) const particules = [] - for (let i = 0; i < config.numberOfParticules; i++) { particules.push(createParticule(x, y)) } + for (let i = 0; i < config.numberOfParticules; i++) { + particules.push(createParticule(x, y)) + } anime .timeline() @@ -197,7 +222,7 @@ function createFireworks(config) { document.addEventListener( 'mousedown', - (e) => { + e => { render.play() updateCoords(e) animateParticules(pointerX, pointerY) diff --git a/package.json b/package.json index 314871fa..b7aa769d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "@next/bundle-analyzer": "^12.1.1", "@vercel/analytics": "^1.0.0", "algoliasearch": "^4.18.0", - "animejs": "^3.2.1", "aos": "^2.3.4", "feed": "^4.2.2", "js-md5": "^0.7.3", diff --git a/yarn.lock b/yarn.lock index ffe43bd3..87c1b1f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -708,11 +708,6 @@ algoliasearch@^4.18.0: "@algolia/requester-node-http" "4.22.1" "@algolia/transporter" "4.22.1" -animejs@^3.2.1: - version "3.2.2" - resolved "https://registry.yarnpkg.com/animejs/-/animejs-3.2.2.tgz#59be98c58834339d5847f4a70ddba74ac75b6afc" - integrity sha512-Ao95qWLpDPXXM+WrmwcKbl6uNlC5tjnowlaRYtuVDHHoygjtIPfDUoK9NthrlZsQSKjZXlmji2TrBUAVbiH0LQ== - ansi-colors@^4.1.1: version "4.1.3" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" From 46f8cfdf3c52554e6099cbc14275412699dd2eeb Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 11:53:11 +0800 Subject: [PATCH 07/23] remove package nprogress --- components/AOSAnimation.js | 2 +- components/LoadingProgress.js | 26 ++++++++--- package.json | 1 - pages/_app.js | 17 ++++--- styles/nprogress.css | 84 ----------------------------------- yarn.lock | 5 --- 6 files changed, 32 insertions(+), 103 deletions(-) delete mode 100644 styles/nprogress.css diff --git a/components/AOSAnimation.js b/components/AOSAnimation.js index c5dd4d92..48e5829c 100644 --- a/components/AOSAnimation.js +++ b/components/AOSAnimation.js @@ -1,5 +1,5 @@ +import { isBrowser } from '@/lib/utils' import AOS from 'aos' -import { isBrowser } from 'react-notion-x' /** * 加载滚动动画 diff --git a/components/LoadingProgress.js b/components/LoadingProgress.js index d7f7b5f7..61ea172e 100644 --- a/components/LoadingProgress.js +++ b/components/LoadingProgress.js @@ -1,20 +1,36 @@ +import { loadExternalResource } from '@/lib/utils' import { useRouter } from 'next/router' -import NProgress from 'nprogress' -import { useEffect } from 'react' +import { useEffect, useState } from 'react' /** * 出现页面加载进度条 */ export default function LoadingProgress() { const router = useRouter() + const [NProgress, setNProgress] = useState(null) // 加载进度条 useEffect(() => { - const handleStart = (url) => { - NProgress.start() + loadExternalResource( + 'https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js', + 'js' + ).then(() => { + if (window.NProgress) { + setNProgress(window.NProgress) + // 调速 + window.NProgress.settings.minimun = 0.1 + loadExternalResource( + 'https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css', + 'css' + ) + } + }) + + const handleStart = url => { + NProgress?.start() } const handleStop = () => { - NProgress.done() + NProgress?.done() } router.events.on('routeChangeStart', handleStart) diff --git a/package.json b/package.json index b7aa769d..38c2e9cb 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "next": "13.3.1", "notion-client": "6.15.6", "notion-utils": "6.15.6", - "nprogress": "^0.2.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-facebook": "^8.1.4", diff --git a/pages/_app.js b/pages/_app.js index cf71fe18..4b7d9a38 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -1,24 +1,23 @@ // import '@/styles/animate.css' // @see https://animate.style/ import '@/styles/globals.css' -import '@/styles/nprogress.css' import '@/styles/utility-patterns.css' // core styles shared by all of react-notion-x (required) -import 'react-notion-x/src/styles.css' import '@/styles/notion.css' // 重写部分样式 import 'aos/dist/aos.css' // You can also use for styles +import 'react-notion-x/src/styles.css' +import useAdjustStyle from '@/hooks/useAdjustStyle' import { GlobalContextProvider } from '@/lib/global' import { getGlobalLayoutByTheme } from '@/themes/theme' import { useRouter } from 'next/router' import { useCallback, useMemo } from 'react' import { getQueryParam } from '../lib/utils' -import useAdjustStyle from '@/hooks/useAdjustStyle' // 各种扩展插件 这个要阻塞引入 +import BLOG from '@/blog.config' import ExternalPlugins from '@/components/ExternalPlugins' import GlobalHead from '@/components/GlobalHead' -import BLOG from '@/blog.config' /** * App挂载DOM 入口文件 @@ -27,11 +26,15 @@ import BLOG from '@/blog.config' */ const MyApp = ({ Component, pageProps }) => { // 一些可能出现 bug 的样式,可以统一放入该钩子进行调整 - useAdjustStyle(); + useAdjustStyle() const route = useRouter() const queryParam = useMemo(() => { - return getQueryParam(route.asPath, 'theme') || pageProps?.NOTION_CONFIG?.THEME || BLOG.THEME + return ( + getQueryParam(route.asPath, 'theme') || + pageProps?.NOTION_CONFIG?.THEME || + BLOG.THEME + ) }, [route]) // 整体布局 @@ -47,7 +50,7 @@ const MyApp = ({ Component, pageProps }) => { return ( - + diff --git a/styles/nprogress.css b/styles/nprogress.css deleted file mode 100644 index 2b405742..00000000 --- a/styles/nprogress.css +++ /dev/null @@ -1,84 +0,0 @@ -/* Make clicks pass-through */ -#nprogress { - pointer-events: none; -} - -#nprogress .bar { - background: #29d; - - position: fixed; - z-index: 1031; - top: 0; - left: 0; - - width: 100%; - height: 2px; -} - -/* Fancy blur effect */ -#nprogress .peg { - display: block; - position: absolute; - right: 0px; - width: 100px; - height: 100%; - box-shadow: 0 0 10px #29d, 0 0 5px #29d; - opacity: 1; - - -webkit-transform: rotate(3deg) translate(0px, -4px); - -ms-transform: rotate(3deg) translate(0px, -4px); - transform: rotate(3deg) translate(0px, -4px); -} - -/* Remove these to get rid of the spinner */ -#nprogress .spinner { - display: block; - position: fixed; - z-index: 1031; - top: 15px; - right: 15px; -} - -#nprogress .spinner-icon { - width: 18px; - height: 18px; - box-sizing: border-box; - - border: solid 2px transparent; - border-top-color: #29d; - border-left-color: #29d; - border-radius: 50%; - - -webkit-animation: nprogress-spinner 400ms linear infinite; - animation: nprogress-spinner 400ms linear infinite; -} - -.nprogress-custom-parent { - overflow: hidden; - position: relative; -} - -.nprogress-custom-parent #nprogress .spinner, -.nprogress-custom-parent #nprogress .bar { - position: absolute; -} - -@-webkit-keyframes nprogress-spinner { - 0% { - -webkit-transform: rotate(0deg); - } - - 100% { - -webkit-transform: rotate(360deg); - } -} - -@keyframes nprogress-spinner { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } -} diff --git a/yarn.lock b/yarn.lock index 87c1b1f9..1a6cc2a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2918,11 +2918,6 @@ notion-utils@^6.15.6, notion-utils@^6.16.0: notion-types "^6.16.0" p-queue "^7.2.0" -nprogress@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1" - integrity sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA== - object-assign@^4.0.1, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" From c43943b0bb492bd71ac09faed8996bba602ce36a Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 14:31:09 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E5=87=8F=E5=B0=91=E9=9D=9E=E5=BF=85?= =?UTF-8?q?=E8=A6=81package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Fireworks.js | 1 - components/Giscus.js | 43 ++++++--- package.json | 2 - public/js/giscus.js | 209 ++++++++++++++++++++++++++++++++++++++++ yarn.lock | 61 ------------ 5 files changed, 238 insertions(+), 78 deletions(-) create mode 100644 public/js/giscus.js diff --git a/components/Fireworks.js b/components/Fireworks.js index b6f1860f..c3d48429 100644 --- a/components/Fireworks.js +++ b/components/Fireworks.js @@ -17,7 +17,6 @@ const Fireworks = () => { useEffect(() => { // 异步加载 async function loadFireworks() { - console.log('加载烟花') loadExternalResource( 'https://cdn.bootcdn.net/ajax/libs/animejs/3.2.1/anime.min.js', 'js' diff --git a/components/Giscus.js b/components/Giscus.js index ed1564eb..a5bb2c50 100644 --- a/components/Giscus.js +++ b/components/Giscus.js @@ -1,6 +1,8 @@ import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' -import Giscus from '@giscus/react' +import { loadExternalResource } from '@/lib/utils' +import { useEffect } from 'react' +// import Giscus from '@giscus/react' /** * Giscus评论 @see https://giscus.app/zh-CN @@ -12,21 +14,34 @@ import Giscus from '@giscus/react' const GiscusComponent = () => { const { isDarkMode } = useGlobal() const theme = isDarkMode ? 'dark' : 'light' + useEffect(() => { + loadExternalResource('/js/giscus.js', 'js').then(() => { + if (window.Giscus) { + window.Giscus.init('#giscus') + } + }) + return () => { + window.Giscus.destroy() + } + }, [isDarkMode]) return ( - +
) } diff --git a/package.json b/package.json index 38c2e9cb..76826951 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "bundle-report": "cross-env ANALYZE=true yarn build" }, "dependencies": { - "@giscus/react": "^2.2.6", "@headlessui/react": "^1.7.15", "@next/bundle-analyzer": "^12.1.1", "@vercel/analytics": "^1.0.0", @@ -29,7 +28,6 @@ "aos": "^2.3.4", "feed": "^4.2.2", "js-md5": "^0.7.3", - "localStorage": "^1.0.4", "lodash.throttle": "^4.1.1", "memory-cache": "^0.2.0", "next": "13.3.1", diff --git a/public/js/giscus.js b/public/js/giscus.js new file mode 100644 index 00000000..373454c4 --- /dev/null +++ b/public/js/giscus.js @@ -0,0 +1,209 @@ +/* eslint-disable */ +;(function () { + var baseUrl = 'https://giscus.app' + var giscusIframe = null + + // 错误日志 + function handleError(a) { + return '[giscus] An error occurred. Error message: "'.concat(a, '".') + } + // 站点元信息 + function getMetaContent(name, includeProperty) { + void 0 === includeProperty && (includeProperty = !1) + includeProperty = includeProperty + ? "meta[property='og:".concat(name, "'],") + : '' + return (name = document.querySelector( + includeProperty + "meta[name='".concat(name, "']") + )) + ? name.content + : '' + } + + // 渲染 + function render(querySelector) { + // const giscusContainer = document.currentScript + const giscusContainer = document.querySelector(querySelector) + // var k = new URL(m.src).origin + let dataset = new URL(location.href) + let paramsSession = dataset.searchParams.get('giscus') || '' + const localStorageSession = localStorage.getItem('giscus-session') + dataset.searchParams.delete('giscus') + dataset.hash = '' + let url = dataset.toString() + if (paramsSession) + localStorage.setItem('giscus-session', JSON.stringify(paramsSession)), + history.replaceState(void 0, document.title, url) + else if (localStorageSession) { + try { + paramsSession = JSON.parse(localStorageSession) + } catch (a) { + localStorage.removeItem('giscus-session'), + console.warn( + ''.concat( + handleError(a === null || void 0 === a ? void 0 : a.message), + ' Session has been cleared.' + ) + ) + } + } + + dataset = giscusContainer.dataset + var params = {} + params.origin = url + params.session = paramsSession + params.theme = dataset.theme + params.reactionsEnabled = dataset.reactionsEnabled || '1' + params.emitMetadata = dataset.emitMetadata || '0' + params.inputPosition = dataset.inputPosition || 'bottom' + params.repo = dataset.repo + params.repoId = dataset.repoId + params.category = dataset.category || '' + params.categoryId = dataset.categoryId + params.strict = dataset.strict || '0' + params.description = getMetaContent('description', !0) + params.backLink = getMetaContent('giscus:backlink') || url + switch (dataset.mapping) { + case 'url': + params.term = url + break + case 'title': + params.term = document.title + break + case 'og:title': + params.term = getMetaContent('title', !0) + break + case 'specific': + params.term = dataset.term + break + case 'number': + params.number = dataset.term + break + default: + params.term = + location.pathname.length < 2 + ? 'index' + : location.pathname.substring(1).replace(/\.\w+$/, '') + } + const q = + (paramsSession = document.querySelector('.giscus')) && paramsSession.id + q && (params.origin = ''.concat(url, '#').concat(q)) + url = dataset.lang ? '/'.concat(dataset.lang) : '' + url = '' + .concat(baseUrl) + .concat(url, '/widget?') + .concat(new URLSearchParams(params)) + dataset = dataset.loading === 'lazy' ? 'lazy' : void 0 + + // 创建iframe + giscusIframe = document.createElement('iframe') + Object.entries({ + class: 'giscus-frame giscus-frame--loading', + title: 'Comments', + scrolling: 'no', + allow: 'clipboard-write', + src: url, + loading: dataset + }).forEach(function (a) { + const g = a[0] + return (a = a[1]) && giscusIframe.setAttribute(g, a) + }) + giscusIframe.style.opacity = '0' + giscusIframe.addEventListener('load', function () { + giscusIframe.style.removeProperty('opacity') + giscusIframe.classList.remove('giscus-frame--loading') + }) + dataset = + document.getElementById('giscus-css') || document.createElement('link') + dataset.id = 'giscus-css' + dataset.rel = 'stylesheet' + dataset.href = ''.concat(baseUrl, '/default.css') + document.head.prepend(dataset) + if (paramsSession) { + for (; paramsSession.firstChild; ) paramsSession.firstChild.remove() + paramsSession.appendChild(giscusIframe) + } else + (paramsSession = document.createElement('div')), + paramsSession.setAttribute('class', 'giscus'), + paramsSession.appendChild(giscusIframe), + giscusContainer.insertAdjacentElement('afterend', paramsSession) + } + + // 处理接收消息 + function handdleMessage(event) { + if (!giscusIframe) { + return + } + event.origin === baseUrl && + ((event = event.data), + typeof event === 'object' && + event.giscus && + (event.giscus.resizeHeight && + (giscusIframe.style.height = ''.concat( + event.giscus.resizeHeight, + 'px' + )), + event.giscus.signOut + ? (localStorage.removeItem('giscus-session'), + console.log( + '[giscus] User has logged out. Session has been cleared.' + ), + p()) + : event.giscus.error && + ((event = event.giscus.error), + event.includes('Bad credentials') || + event.includes('Invalid state value') || + event.includes('State has expired') + ? localStorage.getItem('giscus-session') !== null + ? (localStorage.removeItem('giscus-session'), + console.warn( + ''.concat(handleError(event), ' Session has been cleared.') + ), + p()) + : localStorageSession || + console.error( + '' + .concat( + handleError(event), + ' No session is stored initially. ' + ) + .concat( + 'Please consider reporting this error at https://github.com/giscus/giscus/issues/new.' + ) + ) + : event.includes('Discussion not found') + ? console.warn( + '[giscus] '.concat( + event, + '. A new discussion will be created if a comment/reaction is submitted.' + ) + ) + : event.includes('API rate limit exceeded') + ? console.warn(handleError(event)) + : console.error( + '' + .concat(handleError(event), ' ') + .concat( + 'Please consider reporting this error at https://github.com/giscus/giscus/issues/new.' + ) + )))) + } + + // 初始化 + function initializeGiscus(querySelector) { + render(querySelector) + window.addEventListener('message', handdleMessage) + } + + // 销毁 + function destroyGiscus() { + giscusIframe?.remove() + giscusIframe = null + } + + // 暴露接口 + window.Giscus = { + init: initializeGiscus, + destroy: destroyGiscus + } +})() diff --git a/yarn.lock b/yarn.lock index 1a6cc2a8..fd917710 100644 --- a/yarn.lock +++ b/yarn.lock @@ -179,13 +179,6 @@ resolved "https://registry.yarnpkg.com/@fisch0920/medium-zoom/-/medium-zoom-1.0.7.tgz#46b09b40a1be796f7ff13ea594973e1f1d3c66f6" integrity sha512-hPUrgVM/QvsZdZzDTPyL1C1mOtEw03RqTLmK7ZlJ8S/64u4O4O5BvPvjB/9kyLtE6iVaS9UDRAMSwmM9uh2JIw== -"@giscus/react@^2.2.6": - version "2.4.0" - resolved "https://registry.yarnpkg.com/@giscus/react/-/react-2.4.0.tgz#43fa5fbdcca9d44f532e6c61c46878da3476909c" - integrity sha512-y8d8qiZ2sBuaXRcgn/ZWfMlRs9bx26p62BU/HEKQQ+IfHo3B/kglgPjX/IqudwlX+DOlHUl1NvtFo9C8Eqo0eQ== - dependencies: - giscus "^1.4.0" - "@headlessui/react@^1.7.15": version "1.7.18" resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.18.tgz#30af4634d2215b2ca1aa29d07f33d02bea82d9d7" @@ -252,18 +245,6 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@lit-labs/ssr-dom-shim@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz#353ce4a76c83fadec272ea5674ede767650762fd" - integrity sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g== - -"@lit/reactive-element@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-2.0.4.tgz#8f2ed950a848016383894a26180ff06c56ae001b" - integrity sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ== - dependencies: - "@lit-labs/ssr-dom-shim" "^1.2.0" - "@matejmazur/react-katex@^3.1.3": version "3.1.3" resolved "https://registry.yarnpkg.com/@matejmazur/react-katex/-/react-katex-3.1.3.tgz#f07404c848b93bfef9ed9653a4bb080dc8bf2bf0" @@ -456,11 +437,6 @@ dependencies: "@types/node" "*" -"@types/trusted-types@^2.0.2": - version "2.0.7" - resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.7.tgz#baccb07a970b91707df3a3e8ba6896c57ead2d11" - integrity sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw== - "@types/web-bluetooth@^0.0.20": version "0.0.20" resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597" @@ -1965,13 +1941,6 @@ get-tsconfig@^4.5.0: dependencies: resolve-pkg-maps "^1.0.0" -giscus@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.4.0.tgz#89a9c445776e91b59ab47249ae6acdfa01bb6941" - integrity sha512-Pll+pcclTx47NcFDw8nuka2Ja85Gc4XWpzSgL0rszOQaMQRQIV8UMR+zP4a+/N3tV2TXc1SZ537kWlsN6EsAaw== - dependencies: - lit "^3.1.0" - glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -2559,31 +2528,6 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -lit-element@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-4.0.4.tgz#e0b37ebbe2394bcb9578d611a409f49475dff361" - integrity sha512-98CvgulX6eCPs6TyAIQoJZBCQPo80rgXR+dVBs61cstJXqtI+USQZAbA4gFHh6L/mxBx9MrgPLHLsUgDUHAcCQ== - dependencies: - "@lit-labs/ssr-dom-shim" "^1.2.0" - "@lit/reactive-element" "^2.0.4" - lit-html "^3.1.2" - -lit-html@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-3.1.2.tgz#6655ce82367472de7680c62b1bcb0beb0e426fa1" - integrity sha512-3OBZSUrPnAHoKJ9AMjRL/m01YJxQMf+TMHanNtTHG68ubjnZxK0RFl102DPzsw4mWnHibfZIBJm3LWCZ/LmMvg== - dependencies: - "@types/trusted-types" "^2.0.2" - -lit@^3.1.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lit/-/lit-3.1.2.tgz#f276258e8a56593f1d834a5fd00a7eb5e891ae73" - integrity sha512-VZx5iAyMtX7CV4K8iTLdCkMaYZ7ipjJZ0JcSdJ0zIdGxxyurjIn7yuuSxNBD7QmjvcNJwr0JS4cAdAtsy7gZ6w== - dependencies: - "@lit/reactive-element" "^2.0.4" - lit-element "^4.0.4" - lit-html "^3.1.2" - loader-utils@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" @@ -2593,11 +2537,6 @@ loader-utils@^2.0.0: emojis-list "^3.0.0" json5 "^2.1.2" -localStorage@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/localStorage/-/localStorage-1.0.4.tgz#57dfa28084385f81431accb8ae24b196398223f7" - integrity sha512-r35zrihcDiX+dqWlJSeIwS9nrF95OQTgqMFm3FB2D/+XgdmZtcutZOb7t0xXkhOEM8a9kpuu7cc28g1g36I5DQ== - lodash.debounce@^4.0.6: version "4.0.8" resolved "https://r2.cnpmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" From b2b64c8f765652ef7e414d78e702c35790594378 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 16:47:57 +0800 Subject: [PATCH 09/23] aos to cdn --- components/AOSAnimation.js | 26 ++++++++++++++++++++++---- package.json | 1 - pages/_app.js | 1 - yarn.lock | 21 +-------------------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/components/AOSAnimation.js b/components/AOSAnimation.js index 48e5829c..076ab379 100644 --- a/components/AOSAnimation.js +++ b/components/AOSAnimation.js @@ -1,12 +1,30 @@ -import { isBrowser } from '@/lib/utils' -import AOS from 'aos' +import { loadExternalResource } from '@/lib/utils' +import { useEffect } from 'react' +// import AOS from 'aos' /** * 加载滚动动画 + * 改从外部CDN读取 * https://michalsnik.github.io/aos/ */ export default function AOSAnimation() { - if (isBrowser) { - AOS.init() + const initAOS = async () => { + Promise.all([ + loadExternalResource( + 'https://cdn.bootcdn.net/ajax/libs/aos/2.3.4/aos.js', + 'js' + ), + loadExternalResource( + 'https://cdn.bootcdn.net/ajax/libs/aos/2.3.4/aos.css', + 'css' + ) + ]).then(() => { + if (window.AOS) { + window.AOS.init() + } + }) } + useEffect(() => { + initAOS() + }, []) } diff --git a/package.json b/package.json index 76826951..9773900b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "@next/bundle-analyzer": "^12.1.1", "@vercel/analytics": "^1.0.0", "algoliasearch": "^4.18.0", - "aos": "^2.3.4", "feed": "^4.2.2", "js-md5": "^0.7.3", "lodash.throttle": "^4.1.1", diff --git a/pages/_app.js b/pages/_app.js index 4b7d9a38..406338ba 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -4,7 +4,6 @@ import '@/styles/utility-patterns.css' // core styles shared by all of react-notion-x (required) import '@/styles/notion.css' // 重写部分样式 -import 'aos/dist/aos.css' // You can also use for styles import 'react-notion-x/src/styles.css' import useAdjustStyle from '@/hooks/useAdjustStyle' diff --git a/yarn.lock b/yarn.lock index fd917710..66e14e9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -731,15 +731,6 @@ anymatch@~3.1.2: normalize-path "^3.0.0" picomatch "^2.0.4" -aos@^2.3.4: - version "2.3.4" - resolved "https://r2.cnpmjs.org/aos/-/aos-2.3.4.tgz#eb1c29f5c1806a197cf6323080747547edd3db8e" - integrity sha512-zh/ahtR2yME4I51z8IttIt4lC1Nw0ktsFtmeDzID1m9naJnWXhCoARaCgNOGXb5CLy3zm+wqmRAEgMYB5E2HUw== - dependencies: - classlist-polyfill "^1.0.3" - lodash.debounce "^4.0.6" - lodash.throttle "^4.0.1" - arg@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c" @@ -1036,11 +1027,6 @@ chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" -classlist-polyfill@^1.0.3: - version "1.2.0" - resolved "https://r2.cnpmjs.org/classlist-polyfill/-/classlist-polyfill-1.2.0.tgz#935bc2dfd9458a876b279617514638bcaa964a2e" - integrity sha512-GzIjNdcEtH4ieA2S8NmrSxv7DfEV5fmixQeyTmqmRmRJPGpRBaSnA2a0VrCjyT8iW8JjEdMbKzDotAJf+ajgaQ== - classnames@^2.3.2: version "2.5.1" resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.5.1.tgz#ba774c614be0f016da105c858e7159eae8e7687b" @@ -2537,17 +2523,12 @@ loader-utils@^2.0.0: emojis-list "^3.0.0" json5 "^2.1.2" -lodash.debounce@^4.0.6: - version "4.0.8" - resolved "https://r2.cnpmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" - integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow== - lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.throttle@^4.0.1, lodash.throttle@^4.1.1: +lodash.throttle@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ== From 4fa1f4cb9ef804e28f5d55e1684125caa2996f64 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 10 Apr 2024 16:48:35 +0800 Subject: [PATCH 10/23] hexo index jumpto comment --- themes/hexo/index.js | 454 ++++++++++++++++++++++++------------------- 1 file changed, 255 insertions(+), 199 deletions(-) diff --git a/themes/hexo/index.js b/themes/hexo/index.js index b36ff6e2..664b9698 100644 --- a/themes/hexo/index.js +++ b/themes/hexo/index.js @@ -1,39 +1,42 @@ -import CONFIG from './config' -import { createContext, useContext, useEffect, useRef } from 'react' -import Footer from './components/Footer' -import SideRight from './components/SideRight' -import TopNav from './components/TopNav' +import Comment from '@/components/Comment' +import replaceSearchResult from '@/components/Mark' +import NotionPage from '@/components/NotionPage' +import ShareBar from '@/components/ShareBar' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import { isBrowser } from '@/lib/utils' -import BlogPostListPage from './components/BlogPostListPage' -import BlogPostListScroll from './components/BlogPostListScroll' -import Hero from './components/Hero' +import { Transition } from '@headlessui/react' +import dynamic from 'next/dynamic' +import Link from 'next/link' import { useRouter } from 'next/router' -import Card from './components/Card' -import RightFloatArea from './components/RightFloatArea' -import SearchNav from './components/SearchNav' -import BlogPostArchive from './components/BlogPostArchive' -import { ArticleLock } from './components/ArticleLock' -import PostHeader from './components/PostHeader' -import JumpToCommentButton from './components/JumpToCommentButton' -import TocDrawer from './components/TocDrawer' -import TocDrawerButton from './components/TocDrawerButton' -import Comment from '@/components/Comment' -import NotionPage from '@/components/NotionPage' +import { createContext, useContext, useEffect, useRef } from 'react' import ArticleAdjacent from './components/ArticleAdjacent' import ArticleCopyright from './components/ArticleCopyright' +import { ArticleLock } from './components/ArticleLock' import ArticleRecommend from './components/ArticleRecommend' -import ShareBar from '@/components/ShareBar' -import TagItemMini from './components/TagItemMini' -import Link from 'next/link' +import BlogPostArchive from './components/BlogPostArchive' +import BlogPostListPage from './components/BlogPostListPage' +import BlogPostListScroll from './components/BlogPostListScroll' +import Card from './components/Card' +import Footer from './components/Footer' +import Hero from './components/Hero' +import JumpToCommentButton from './components/JumpToCommentButton' +import PostHeader from './components/PostHeader' +import RightFloatArea from './components/RightFloatArea' +import SearchNav from './components/SearchNav' +import SideRight from './components/SideRight' import SlotBar from './components/SlotBar' -import { Transition } from '@headlessui/react' +import TagItemMini from './components/TagItemMini' +import TocDrawer from './components/TocDrawer' +import TocDrawerButton from './components/TocDrawerButton' +import TopNav from './components/TopNav' +import CONFIG from './config' import { Style } from './style' -import replaceSearchResult from '@/components/Mark' -import { siteConfig } from '@/lib/config' -import dynamic from 'next/dynamic' -const AlgoliaSearchModal = dynamic(() => import('@/components/AlgoliaSearchModal'), { ssr: false }) +const AlgoliaSearchModal = dynamic( + () => import('@/components/AlgoliaSearchModal'), + { ssr: false } +) // 主题全局状态 const ThemeGlobalHexo = createContext() @@ -50,93 +53,110 @@ const LayoutBase = props => { const { onLoading, fullWidth } = useGlobal() const router = useRouter() - const headerSlot = post - ? - : (router.route === '/' && siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) - ? - : null) + const headerSlot = post ? ( + + ) : router.route === '/' && + siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) ? ( + + ) : null const drawerRight = useRef(null) const tocRef = isBrowser ? document.getElementById('article-wrapper') : null - const floatSlot = <> - {post?.toc?.length > 1 &&
- { - drawerRight?.current?.handleSwitchVisible() - }} - /> -
} - + const floatSlot = ( + <> + {post?.toc?.length > 1 && ( +
+ { + drawerRight?.current?.handleSwitchVisible() + }} + /> +
+ )} + {post && } + ) // Algolia搜索框 const searchModal = useRef(null) return ( -
-