+
diff --git a/.env.local b/.env.local index 3cf57133..c2daaaed 100644 --- a/.env.local +++ b/.env.local @@ -1,5 +1,5 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=4.2.3 +NEXT_PUBLIC_VERSION=4.2.4 # 可在此添加环境变量,去掉最左边的(# )注释即可 diff --git a/blog.config.js b/blog.config.js index f038e23f..4677c555 100644 --- a/blog.config.js +++ b/blog.config.js @@ -45,8 +45,9 @@ const BLOG = { // 默认下会将你上传到 notion的主页封面图和头像也给替换,建议将主页封面图和头像放在其他图床,在 notion 里配置 link 即可。 // START ************网站字体***************** - - FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115 + // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115 + // 后面空格隔开的font-light的字体粗细,留空是默认粗细;参考 https://www.tailwindcss.cn/docs/font-weight + FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans font-light', // 字体CSS 例如 https://npm.elemecdn.com/lxgw-wenkai-webfont@1.6.0/style.css FONT_URL: [ // 'https://npm.elemecdn.com/lxgw-wenkai-webfont@1.6.0/style.css', diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 32089e30..9a1dff7c 100755 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -119,6 +119,7 @@ export async function getNotionPageData({ pageId, from }) { /** * 获取用户自定义单页菜单 + * 旧版本,不读取Menu菜单,而是读取type=Page生成菜单 * @param notionPageData * @returns {Promise<[]|*[]>} */ @@ -126,11 +127,16 @@ function getCustomNav({ allPages }) { const customNav = [] if (allPages && allPages.length > 0) { allPages.forEach(p => { + p.to = p.slug if (p?.slug?.indexOf('http') === 0) { - customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, target: '_blank', show: true }) + p.target = '_blank' } else { - customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, target: '_self', show: true }) + p.target = '_self' + if (p?.slug?.indexOf('/') !== 0) { + p.to = '/' + p.slug + } } + customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, target: '_blank', show: true }) }) } return customNav @@ -142,13 +148,19 @@ function getCustomNav({ allPages }) { * @returns */ function getCustomMenu({ collectionData }) { - const menuPages = collectionData.filter(post => (post?.type === BLOG.NOTION_PROPERTY_NAME.type_menu || post?.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) && post.status === 'Published') + const menuPages = collectionData.filter(post => post.status === 'Published' && (post?.type === BLOG.NOTION_PROPERTY_NAME.type_menu || post?.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu)) const menus = [] if (menuPages && menuPages.length > 0) { menuPages.forEach(e => { e.show = true if (e?.slug?.indexOf('http') === 0) { e.target = '_blank' + e.to = e.slug + } else { + e.target = '_self' + if (e?.slug?.indexOf('/') !== 0) { + e.to = '/' + e.slug + } } if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) { menus.push(e) diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 7c085993..69888b5d 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -18,10 +18,7 @@ export async function getPostBlocks(id, from, slice) { return filterPostBlocks(id, pageBlock, slice) } - const start = new Date().getTime() pageBlock = await getPageWithRetry(id, from) - const end = new Date().getTime() - console.log('[API耗时]', `${end - start}ms`) if (pageBlock) { await setDataToCache(cacheKey, pageBlock) @@ -38,10 +35,7 @@ export async function getSingleBlock(id, from) { return pageBlock } - const start = new Date().getTime() pageBlock = await getPageWithRetry(id, from) - const end = new Date().getTime() - console.log('[API耗时]', `${end - start}ms`) if (pageBlock) { await setDataToCache(cacheKey, pageBlock) @@ -56,16 +50,17 @@ export async function getSingleBlock(id, from) { */ export async function getPageWithRetry(id, from, retryAttempts = 3) { if (retryAttempts && retryAttempts > 0) { - console.log('[请求API]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '') + console.log('[API-->>请求]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '') try { const authToken = BLOG.NOTION_ACCESS_TOKEN || null const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) + const start = new Date().getTime() const pageData = await api.getPage(id) - // console.log('stringfy', JSON.stringify(pageData)) - console.info('[响应成功]:', `from:${from}`) + const end = new Date().getTime() + console.log('[API<<--响应]', `耗时:${end - start}ms - from:${from}`) return pageData } catch (e) { - console.warn('[响应异常]:', e) + console.warn('[API<<--异常]:', e) await delay(1000) const cacheKey = 'page_block_' + id const pageBlock = await getDataFromCache(cacheKey) diff --git a/next.config.js b/next.config.js index f6dc572b..732303bf 100644 --- a/next.config.js +++ b/next.config.js @@ -16,13 +16,16 @@ function scanSubdirectories(directory) { const subdirectories = [] fs.readdirSync(directory).forEach(file => { - const fullPath = path.join(directory, file) - const stats = fs.statSync(fullPath) + // 这段代码会将landing排除在可选主题中 - // landing主题比较特殊,不在可切换的主题中显示 - if (stats.isDirectory() && file !== 'landing') { - subdirectories.push(file) - } + // const fullPath = path.join(directory, file) + // const stats = fs.statSync(fullPath) + // landing主题默认隐藏掉,一般网站不会用到 + // if (stats.isDirectory() && file !== 'landing') { + // subdirectories.push(file) + // } + + subdirectories.push(file) }) return subdirectories @@ -94,7 +97,7 @@ module.exports = withBundleAnalyzer({ // } // 动态主题:添加 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, 'themes', THEME) return config diff --git a/package.json b/package.json index 6a679668..82efcf06 100644 --- a/package.json +++ b/package.json @@ -1,77 +1,78 @@ { - "name": "notion-next", - "version": "4.2.3", - "homepage": "https://github.com/tangly1024/NotionNext.git", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/tangly1024/NotionNext.git" - }, - "author": { - "name": "tangly", - "email": "mail@tangly1024.com", - "url": "http://tangly1024.com" - }, - "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", - "post-build": "next-sitemap --config next-sitemap.config.js", - "export": "next build && next-sitemap --config next-sitemap.config.js && next export", - "bundle-report": "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", - "algoliasearch": "^4.18.0", - "animejs": "^3.2.1", - "aos": "^3.0.0-beta.6", - "axios": ">=0.21.1", - "copy-to-clipboard": "^3.3.1", - "eslint-plugin-react-hooks": "^4.6.0", - "feed": "^4.2.2", - "js-md5": "^0.7.3", - "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", - "nprogress": "^0.2.0", - "preact": "^10.5.15", - "prism-themes": "1.9.0", - "react": "^18.2.0", - "react-cookies": "^0.1.1", - "react-dom": "^18.2.0", - "react-facebook": "^8.1.4", - "react-notion-x": "6.16.0", - "react-share": "^4.4.1", - "react-tweet-embed": "~2.0.0", - "typed.js": "^2.0.12" - }, - "devDependencies": { - "@waline/client": "^2.5.1", - "autoprefixer": "^10.4.13", - "eslint": "^7.26.0", - "eslint-config-next": "^13.1.1", - "eslint-config-standard": "^16.0.2", - "eslint-plugin-import": "^2.23.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.0", - "eslint-plugin-react": "^7.23.2", - "next-sitemap": "^1.6.203", - "postcss": "^8.4.31", - "tailwindcss": "^3.3.2", - "webpack-bundle-analyzer": "^4.5.0" - }, - "resolutions": { - "axios": ">=0.21.1" - }, - "bugs": { - "url": "https://github.com/tangly/NotionNext/issues", - "email": "tlyong1992@hotmail.com" - } -} + "name": "notion-next", + "version": "4.2.4", + "homepage": "https://github.com/tangly1024/NotionNext.git", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/tangly1024/NotionNext.git" + }, + "author": { + "name": "tangly", + "email": "mail@tangly1024.com", + "url": "http://tangly1024.com" + }, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "post-build": "next-sitemap --config next-sitemap.config.js", + "export": "next build && next-sitemap --config next-sitemap.config.js && next export", + "bundle-report": "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", + "algoliasearch": "^4.18.0", + "animejs": "^3.2.1", + "aos": "^3.0.0-beta.6", + "axios": ">=0.21.1", + "copy-to-clipboard": "^3.3.1", + "feed": "^4.2.2", + "js-md5": "^0.7.3", + "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", + "nprogress": "^0.2.0", + "preact": "^10.5.15", + "prism-themes": "1.9.0", + "react": "^18.2.0", + "react-cookies": "^0.1.1", + "react-dom": "^18.2.0", + "react-facebook": "^8.1.4", + "react-notion-x": "6.16.0", + "react-share": "^4.4.1", + "react-tweet-embed": "~2.0.0", + "typed.js": "^2.0.12" + }, + "devDependencies": { + "@waline/client": "^2.5.1", + "autoprefixer": "^10.4.13", + "eslint": "^7.26.0", + "eslint-config-next": "^13.1.1", + "eslint-config-standard": "^16.0.2", + "eslint-plugin-import": "^2.23.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-react": "^7.23.2", + "eslint-plugin-react-hooks": "^4.6.0", + "next-sitemap": "^1.6.203", + "postcss": "^8.4.31", + "prettier": "3.2.5", + "tailwindcss": "^3.3.2", + "webpack-bundle-analyzer": "^4.5.0" + }, + "resolutions": { + "axios": ">=0.21.1" + }, + "bugs": { + "url": "https://github.com/tangly/NotionNext/issues", + "email": "tlyong1992@hotmail.com" + } +} \ No newline at end of file diff --git a/pages/_document.js b/pages/_document.js index 1acc1b6c..b2649d79 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -28,7 +28,7 @@ class MyDocument extends Document { })} -
+{description}
diff --git a/themes/fukasawa/components/ArticleDetail.js b/themes/fukasawa/components/ArticleDetail.js index 1b9076a4..fb038e3d 100644 --- a/themes/fukasawa/components/ArticleDetail.js +++ b/themes/fukasawa/components/ArticleDetail.js @@ -9,6 +9,7 @@ import { AdSlot } from '@/components/GoogleAdsense' import LazyImage from '@/components/LazyImage' import { formatDateFmt } from '@/lib/formatDate' import WWAds from '@/components/WWAds' +import NotionIcon from '@/components/NotionIcon' /** * @@ -36,7 +37,7 @@ export default function ArticleDetail(props) { {/* 文章Title */}
+
+
{siteConfig('LANDING_FEATURES_HEADER_2_P', null, CONFIG)}
+{siteConfig('LANDING_FEATURES_HEADER_2_P', null, CONFIG)}