From b2714fa4a522cf36c899e6e00c3173d5e490217d Mon Sep 17 00:00:00 2001 From: Blackberry009 <765042894@qq.com> Date: Wed, 18 Jun 2025 11:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/db/getSiteData.js | 50 +++++------ themes/typography/components/Announcement.js | 13 --- themes/typography/components/BlogItem.js | 5 +- themes/typography/components/BlogListPage.js | 8 +- themes/typography/components/Header.js | 54 ------------ themes/typography/components/MenuList.js | 7 +- themes/typography/components/NavBar.js | 8 +- .../typography/components/RecommendPosts.js | 2 +- themes/typography/components/SearchInput.js | 86 ------------------- themes/typography/config.js | 23 ++--- themes/typography/index.js | 13 +-- 11 files changed, 50 insertions(+), 219 deletions(-) delete mode 100644 themes/typography/components/Announcement.js delete mode 100644 themes/typography/components/Header.js delete mode 100644 themes/typography/components/SearchInput.js diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index c9e3a9d4..cf26b291 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -19,7 +19,7 @@ export { getPost } from '../notion/getNotionPost' export { getPage as getPostBlocks } from '../notion/getPostBlocks' /** - * 获取博客数据; 基于Notion实现 + * 获取博客数据; 基于 Notion 实现 * @param {*} pageId * @param {*} from * @param {*} locale 语言 zh|en|jp 等等 @@ -31,7 +31,7 @@ export async function getGlobalData({ from, locale }) { - // 获取站点数据 , 如果pageId有逗号隔开则分次取数据 + // 获取站点数据,如果 pageId 有逗号隔开则分次取数据 const siteIds = pageId?.split(',') || [] let data = EmptyData(pageId) @@ -65,7 +65,7 @@ export async function getGlobalData({ * @returns {Promise} */ export async function getSiteDataByPageId({ pageId, from }) { - // 获取NOTION原始数据,此接支持mem缓存。 + // 获取 NOTION 原始数据,此接支持 mem 缓存。 return await getOrSetDataWithCache( `site_data_${pageId}`, async (pageId, from) => { @@ -101,7 +101,7 @@ const EmptyData = pageId => { allPages: [ { id: 1, - title: `无法获取Notion数据,请检查Notion_ID: \n 当前 ${pageId}`, + title: `无法获取 Notion 数据,请检查 Notion_ID: \n 当前 ${pageId}`, summary: '访问文档获取帮助 → https://docs.tangly1024.com/article/vercel-deploy-notion-next', status: 'Published', @@ -137,7 +137,7 @@ const EmptyData = pageId => { } /** - * 将Notion数据转站点数据 + * 将 Notion 数据转站点数据 * 这里统一对数据格式化 * @returns {Promise} */ @@ -149,7 +149,7 @@ async function convertNotionToSiteData(pageId, from, pageRecordMap) { pageId = idToUuid(pageId) let block = pageRecordMap.block || {} const rawMetadata = block[pageId]?.value - // Check Type Page-Database和Inline-Database + // Check Type Page-Database 和 Inline-Database if ( rawMetadata?.type !== 'collection_view_page' && rawMetadata?.type !== 'collection_view' @@ -175,7 +175,7 @@ async function convertNotionToSiteData(pageId, from, pageRecordMap) { if (pageIds?.length === 0) { console.error( - '获取到的文章列表为空,请检查notion模板', + '获取到的文章列表为空,请检查 notion 模板', collectionQuery, collection, collectionView, @@ -183,10 +183,10 @@ async function convertNotionToSiteData(pageId, from, pageRecordMap) { pageRecordMap ) } else { - // console.log('有效Page数量', pageIds?.length) + // console.log('有效 Page 数量', pageIds?.length) } - // 抓取主数据库最多抓取1000个blocks,溢出的数block这里统一抓取一遍 + // 抓取主数据库最多抓取 1000 个 blocks,溢出的数 block 这里统一抓取一遍 const blockIdsNeedFetch = [] for (let i = 0; i < pageIds.length; i++) { const id = pageIds[i] @@ -369,21 +369,21 @@ function handleDataBeforeReturn(db) { p.date.time_zone ) console.log( - '[定时发布] 隐藏--> 文章:', + '[定时发布] 隐藏--> 文章:', p.title, - '当前时间戳:', + '当前时间戳:', currentTimestamp, - '目标时间戳:', + '目标时间戳:', startTimestamp, '-', endTimestamp ) console.log( - '[定时发布] 隐藏--> 文章:', + '[定时发布] 隐藏--> 文章:', p.title, - '当前时间:', + '当前时间:', new Date(), - '目标时间:', + '目标时间:', p.date ) // 隐藏 @@ -431,7 +431,7 @@ function cleanPages(allPages, tagOptions) { } /** - * 清理一组数据的id + * 清理一组数据的 id * @param {*} items * @returns */ @@ -449,7 +449,7 @@ function shortenIds(items) { } /** - * 清理一组数据的id + * 清理一组数据的 id * @param {*} items * @returns */ @@ -466,7 +466,7 @@ function cleanIds(items) { } /** - * 清理和过滤tagOptions + * 清理和过滤 tagOptions * @param {*} tagOptions * @returns */ @@ -482,7 +482,7 @@ function cleanTagOptions(tagOptions) { } /** - * 清理block数据 + * 清理 block 数据 */ function cleanBlock(item) { const post = deepClone(item) @@ -537,7 +537,7 @@ function getLatestPosts({ allPages, from, latestPostCount }) { /** * 获取用户自定义单页菜单 - * 旧版本,不读取Menu菜单,而是读取type=Page生成菜单 + * 旧版本,不读取 Menu 菜单,而是读取 type=Page 生成菜单 * @param notionPageData * @returns {Promise<[]|*[]>} */ @@ -625,7 +625,7 @@ function getCategoryOptions(schema) { function getSiteInfo({ collection, block, NOTION_CONFIG }) { const defaultTitle = NOTION_CONFIG?.TITLE || 'NotionNext BLOG' const defaultDescription = - NOTION_CONFIG?.DESCRIPTION || '这是一个由NotionNext生成的站点' + NOTION_CONFIG?.DESCRIPTION || '这是一个由 NotionNext 生成的站点' const defaultPageCover = NOTION_CONFIG?.HOME_BANNER_IMAGE || '/bg_image.jpg' const defaultIcon = NOTION_CONFIG?.AVATAR || '/avatar.svg' const defaultLink = NOTION_CONFIG?.LINK || BLOG.LINK @@ -658,7 +658,7 @@ function getSiteInfo({ collection, block, NOTION_CONFIG }) { // 站点网址 const link = NOTION_CONFIG?.LINK || defaultLink - // 站点图标不能是emoji + // 站点图标不能是 emoji const emojiPattern = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g if (!icon || emojiPattern.test(icon)) { icon = defaultIcon @@ -674,7 +674,7 @@ function getSiteInfo({ collection, block, NOTION_CONFIG }) { * @param {string} date.start_time - 开始时间(可选,格式:HH:mm) * @param {string} date.end_date - 结束日期(格式:YYYY-MM-DD) * @param {string} date.end_time - 结束时间(可选,格式:HH:mm) - * @param {string} date.time_zone - 时区(IANA格式,如 "Asia/Shanghai") + * @param {string} date.time_zone - 时区(IANA 格式,如 "Asia/Shanghai") * @returns {boolean} 是否在范围内 */ function isInRange(title, date = {}) { @@ -812,8 +812,8 @@ function getTimestamp(date, time = '00:00', time_zone) { /** * 获取导航用的精减文章列表 - * gitbook主题用到,只保留文章的标题分类标签分类信息,精减掉摘要密码日期等数据 - * 导航页面的条件,必须是Posts + * gitbook 主题用到,只保留文章的标题分类标签分类信息,精减掉摘要密码日期等数据 + * 导航页面的条件,必须是 Posts * @param {*} param0 */ export function getNavPages({ allPages }) { diff --git a/themes/typography/components/Announcement.js b/themes/typography/components/Announcement.js deleted file mode 100644 index 13d069d8..00000000 --- a/themes/typography/components/Announcement.js +++ /dev/null @@ -1,13 +0,0 @@ -import dynamic from 'next/dynamic' - -const NotionPage = dynamic(() => import('@/components/NotionPage')) - -const Announcement = ({ post, className }) => { - if (!post) { - return <> - } - return <>{post && (
- -
)} -} -export default Announcement diff --git a/themes/typography/components/BlogItem.js b/themes/typography/components/BlogItem.js index 4ce78a9a..ccbcac51 100644 --- a/themes/typography/components/BlogItem.js +++ b/themes/typography/components/BlogItem.js @@ -11,7 +11,7 @@ import CONFIG from '../config' export const BlogItem = props => { const { post } = props const { NOTION_CONFIG } = useGlobal() - const showPageCover = siteConfig('SIMPLE_POST_COVER_ENABLE', false, CONFIG) + const showPageCover = siteConfig('TYPOGRAPHY_POST_COVER_ENABLE', false, CONFIG) const showPreview = siteConfig('POST_LIST_PREVIEW', false, NOTION_CONFIG) && post.blockMap return ( @@ -81,11 +81,10 @@ export const BlogItem = props => { -
+
{!showPreview && ( <> {post.summary} - {post.summary && ...} )} {showPreview && post?.blockMap && ( diff --git a/themes/typography/components/BlogListPage.js b/themes/typography/components/BlogListPage.js index e1172adb..d7def141 100644 --- a/themes/typography/components/BlogListPage.js +++ b/themes/typography/components/BlogListPage.js @@ -20,8 +20,8 @@ export default function BlogListPage(props) { const currentPage = +page // 博客列表嵌入广告 - const SIMPLE_POST_AD_ENABLE = siteConfig( - 'SIMPLE_POST_AD_ENABLE', + const TYPOGRAPHY_POST_AD_ENABLE = siteConfig( + 'TYPOGRAPHY_POST_AD_ENABLE', false, CONFIG ) @@ -39,10 +39,10 @@ export default function BlogListPage(props) {
{posts?.map((p, index) => (
- {SIMPLE_POST_AD_ENABLE && (index + 1) % 3 === 0 && ( + {TYPOGRAPHY_POST_AD_ENABLE && (index + 1) % 3 === 0 && ( )} - {SIMPLE_POST_AD_ENABLE && index + 1 === 4 && } + {TYPOGRAPHY_POST_AD_ENABLE && index + 1 === 4 && }
))} diff --git a/themes/typography/components/Header.js b/themes/typography/components/Header.js deleted file mode 100644 index e5d71756..00000000 --- a/themes/typography/components/Header.js +++ /dev/null @@ -1,54 +0,0 @@ -import LazyImage from '@/components/LazyImage' -import { siteConfig } from '@/lib/config' -import Link from 'next/link' -import CONFIG from '../config' -import SocialButton from './SocialButton' - -/** - * 网站顶部 - * @returns - */ -export default function Header(props) { - const { siteInfo } = props - - return ( -
-
- - {/* 可使用一张单图作为logo */} -
-
- -
- -
-
- {siteConfig('AUTHOR')} -
-
-
-
- - -
- -
-
- {siteConfig('DESCRIPTION')} -
-
-
- ) -} diff --git a/themes/typography/components/MenuList.js b/themes/typography/components/MenuList.js index 06f2bdf8..8eb458d7 100644 --- a/themes/typography/components/MenuList.js +++ b/themes/typography/components/MenuList.js @@ -29,24 +29,23 @@ export const MenuList = ({ customNav, customMenu }) => { }) let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, href: '/archive', - show: siteConfig('SIMPLE_MENU_ARCHIVE', null, CONFIG) + show: siteConfig('TYPOGRAPHY_MENU_ARCHIVE', null, CONFIG) }, { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, href: '/category', - show: siteConfig('SIMPLE_MENU_CATEGORY', null, CONFIG) + show: siteConfig('TYPOGRAPHY_MENU_CATEGORY', null, CONFIG) }, { icon: 'fas fa-tag', name: locale.COMMON.TAGS, href: '/tag', - show: siteConfig('SIMPLE_MENU_TAG', null, CONFIG) + show: siteConfig('TYPOGRAPHY_MENU_TAG', null, CONFIG) } ] diff --git a/themes/typography/components/NavBar.js b/themes/typography/components/NavBar.js index 215e427b..53ab0b8c 100644 --- a/themes/typography/components/NavBar.js +++ b/themes/typography/components/NavBar.js @@ -18,11 +18,11 @@ export default function NavBar(props) {
- 山野 + {siteConfig('TYPOGRAPHY_BLOG_NAME')} +
+
+ {siteConfig('TYPOGRAPHY_BLOG_NAME_EN')}
- {/*
- Blog -
*/}
diff --git a/themes/typography/components/RecommendPosts.js b/themes/typography/components/RecommendPosts.js index fd214fa0..6d86f0b4 100644 --- a/themes/typography/components/RecommendPosts.js +++ b/themes/typography/components/RecommendPosts.js @@ -8,7 +8,7 @@ import { siteConfig } from '@/lib/config' */ const RecommendPosts = ({ recommendPosts }) => { const { locale } = useGlobal() - if (!siteConfig('SIMPLE_ARTICLE_RECOMMEND_POSTS', null, CONFIG) || !recommendPosts || recommendPosts.length < 1) { + if (!siteConfig('TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS', null, CONFIG) || !recommendPosts || recommendPosts.length < 1) { return <> } diff --git a/themes/typography/components/SearchInput.js b/themes/typography/components/SearchInput.js deleted file mode 100644 index f0b43a39..00000000 --- a/themes/typography/components/SearchInput.js +++ /dev/null @@ -1,86 +0,0 @@ -import { useRouter } from 'next/router' -import { useImperativeHandle, useRef, useState } from 'react' -let lock = false - -const SearchInput = ({ keyword, cRef, className }) => { - const [onLoading, setLoadingState] = useState(false) - const router = useRouter() - const searchInputRef = useRef() - useImperativeHandle(cRef, () => { - return { - focus: () => { - searchInputRef?.current?.focus() - } - } - }) - - const handleSearch = () => { - const key = searchInputRef.current.value - - if (key && key !== '') { - setLoadingState(true) - location.href = '/search/' + key - } else { - router.push({ pathname: '/' }).then(r => { - }) - } - } - const handleKeyUp = (e) => { - if (e.keyCode === 13) { // 回车 - handleSearch(searchInputRef.current.value) - } else if (e.keyCode === 27) { // ESC - cleanSearch() - } - } - const cleanSearch = () => { - searchInputRef.current.value = '' - } - - const [showClean, setShowClean] = useState(false) - const updateSearchKey = (val) => { - if (lock) { - return - } - searchInputRef.current.value = val - - if (val) { - setShowClean(true) - } else { - setShowClean(false) - } - } - function lockSearchInput() { - lock = true - } - - function unLockSearchInput() { - lock = false - } - - return
- updateSearchKey(e.target.value)} - defaultValue={keyword} - /> - -
- -
- - {(showClean && -
- -
- )} -
-} - -export default SearchInput diff --git a/themes/typography/config.js b/themes/typography/config.js index bc0b8fc4..6ee89153 100644 --- a/themes/typography/config.js +++ b/themes/typography/config.js @@ -1,22 +1,15 @@ const CONFIG = { - SIMPLE_LOGO_IMG: '/Logo.webp', - SIMPLE_TOP_BAR: true, // 显示顶栏 - SIMPLE_TOP_BAR_CONTENT: process.env.NEXT_PUBLIC_THEME_SIMPLE_TOP_TIPS || '', - SIMPLE_LOGO_DESCRIPTION: process.env.NEXT_PUBLIC_THEME_SIMPLE_LOGO_DESCRIPTION || '
编程爱好者
/互联网从业者
/知识分享博主
', + TYPOGRAPHY_POST_AD_ENABLE: process.env.NEXT_PUBLIC_TYPOGRAPHY_POST_AD_ENABLE || false, // 文章列表是否插入广告 - SIMPLE_AUTHOR_LINK: process.env.NEXT_PUBLIC_AUTHOR_LINK || '#', - - SIMPLE_POST_AD_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_AD_ENABLE || false, // 文章列表是否插入广告 - - SIMPLE_POST_COVER_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_COVER_ENABLE || false, // 是否展示博客封面 - - SIMPLE_ARTICLE_RECOMMEND_POSTS: process.env.NEXT_PUBLIC_SIMPLE_ARTICLE_RECOMMEND_POSTS || true, // 文章详情底部显示推荐 + TYPOGRAPHY_POST_COVER_ENABLE: process.env.NEXT_PUBLIC_TYPOGRAPHY_POST_COVER_ENABLE || false, // 是否展示博客封面 + TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS: process.env.NEXT_PUBLIC_TYPOGRAPHY_ARTICLE_RECOMMEND_POSTS || true, // 文章详情底部显示推荐 + TYPOGRAPHY_BLOG_NAME: process.env.NEXT_PUBLIC_TYPOGRAPHY_BLOG_NAME || '活字印刷', + TYPOGRAPHY_BLOG_NAME_EN: process.env.NEXT_PUBLIC_TYPOGRAPHY_BLOG_NAME || 'Typography', // 菜单配置 - SIMPLE_MENU_CATEGORY: true, // 显示分类 - SIMPLE_MENU_TAG: true, // 显示标签 - SIMPLE_MENU_ARCHIVE: true, // 显示归档 - SIMPLE_MENU_SEARCH: true // 显示搜索 + TYPOGRAPHY_MENU_CATEGORY: true, // 显示分类 + TYPOGRAPHY_MENU_TAG: true, // 显示标签 + TYPOGRAPHY_MENU_ARCHIVE: true, // 显示归档 } export default CONFIG diff --git a/themes/typography/index.js b/themes/typography/index.js index 80cdc71c..45f80f14 100644 --- a/themes/typography/index.js +++ b/themes/typography/index.js @@ -4,7 +4,6 @@ import NotionPage from '@/components/NotionPage' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import { isBrowser } from '@/lib/utils' -import { Transition } from '@headlessui/react' import dynamic from 'next/dynamic' import Link from 'next/link' import { useRouter } from 'next/router' @@ -40,9 +39,6 @@ const JumpToTopButton = dynamic(() => import('./components/JumpToTopButton'), { ssr: false }) const Footer = dynamic(() => import('./components/Footer'), { ssr: false }) -const SearchInput = dynamic(() => import('./components/SearchInput'), { - ssr: false -}) const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false }) const BlogListPage = dynamic(() => import('./components/BlogListPage'), { ssr: false @@ -96,7 +92,7 @@ const LayoutBase = props => { {onLoading ? ( // loading 时显示 spinner
-
+
) : ( <> @@ -106,7 +102,7 @@ const LayoutBase = props => { )} {/* 移动端页脚 - 显示在底部 */} -
+
@@ -175,9 +171,6 @@ const LayoutSearch = props => { } }, []) - const slotTop = siteConfig('ALGOLIA_APP_ID') ? null : ( - - ) return } @@ -219,7 +212,7 @@ const LayoutSlug = props => { {!lock && post && (
+ className={`px-5 pt-3 ${fullWidth ? '' : 'xl:max-w-4xl 2xl:max-w-6xl'}`}> {/* 文章信息 */}