From 395f402896634e2c874bc0c95e1358b3c82f8259 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 17 Dec 2021 15:38:33 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E7=BC=96=E8=AF=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++ components/SideArea.js | 2 +- lib/cache/cache_manager.js | 25 ++----------------- package.json | 3 +-- pages/article/[slug].js | 3 --- public/robots.txt | 9 ------- public/sitemap.xml | 50 -------------------------------------- 7 files changed, 9 insertions(+), 88 deletions(-) delete mode 100644 public/robots.txt delete mode 100644 public/sitemap.xml diff --git a/.gitignore b/.gitignore index 6fe9ce66..f5b2d6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,8 @@ yarn-error.log* /yarn.lock .idea .vscode + + +# sitemap +/public/robots.txt +/public/sitemap.xml \ No newline at end of file diff --git a/components/SideArea.js b/components/SideArea.js index 6e59963e..ca3b0eda 100644 --- a/components/SideArea.js +++ b/components/SideArea.js @@ -85,7 +85,7 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat )} - {post && ( + {post && post.toc && post.toc.length > 1 && (
{locale.COMMON.TABLE_OF_CONTENTS} diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 1b3b5f1a..84ac9519 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -1,8 +1,6 @@ import BLOG from '@/blog.config' -import { getCacheFromFile, setCacheToFile } from '@/lib/cache/local_file_cache' import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache' const enableCache = true && !BLOG.isProd // 生产环境禁用 -const cacheProvider = 'memory' // ['memory','file'] 用内存或data.json做缓存 /** * 为减少频繁接口请求,notion数据将被缓存 @@ -13,17 +11,7 @@ export async function getDataFromCache (key) { if (!enableCache) { return null } - let dataFromCache - switch (cacheProvider) { - case 'memory': - dataFromCache = await getCacheFromMemory(key) - break - case 'file': - dataFromCache = await getCacheFromFile(key) - break - default: - break - } + const dataFromCache = await getCacheFromMemory(key) if (JSON.stringify(dataFromCache) === '[]') { return null } @@ -34,14 +22,5 @@ export async function setDataToCache (key, data) { if (!enableCache || !data) { return } - switch (cacheProvider) { - case 'memory': - await setCacheToMemory(key, data) - break - case 'file': - await setCacheToFile(key, data) - break - default: - break - } + await setCacheToMemory(key, data) } diff --git a/package.json b/package.json index c1f22df7..b77924f9 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ }, "scripts": { "dev": "next dev", - "dev-mac": "NODE_OPTIONS='--inspect' next dev", - "build": "next build", + "build": "next build && next-sitemap --config next-sitemap.config.js", "start": "next start", "post-build": "next-sitemap --config next-sitemap.config.js" }, diff --git a/pages/article/[slug].js b/pages/article/[slug].js index d2ef039a..4686a74b 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -31,9 +31,7 @@ const Slug = ({ post, blockMap, tags, prev, next, allPosts, recommendPosts, cate export async function getStaticPaths () { let posts = [] - // if (BLOG.isProd) { posts = await getAllPosts({ from: 'slug - paths', includePage: true }) - // } return { paths: posts.map(row => `${BLOG.path}/article/${row.slug}`), fallback: true @@ -51,7 +49,6 @@ export async function getStaticProps ({ params: { slug } }) { } const blockMap = await getPostBlocks(post.id, 'slug') - post.toc = [] if (blockMap) { post.content = Object.keys(blockMap.block) post.toc = getPageTableOfContents(post, blockMap) diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index 6e83f7cb..00000000 --- a/public/robots.txt +++ /dev/null @@ -1,9 +0,0 @@ -# * -User-agent: * -Allow: / - -# Host -Host: https://tangly1024.com - -# Sitemaps -Sitemap: https://tangly1024.com/sitemap.xml diff --git a/public/sitemap.xml b/public/sitemap.xml deleted file mode 100644 index 1f551e90..00000000 --- a/public/sitemap.xml +++ /dev/null @@ -1,50 +0,0 @@ - - -https://tangly1024.comdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tagdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/searchdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/aboutdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/archivedaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/categorydaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/category/技术分享daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/category/碎片杂文daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/category/投资理财daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/category/读书笔记daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Notiondaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Blogdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Verceldaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/NextJSdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Nobeliumdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Fruitiondaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Hexodaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/开发daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Serverlessdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Databasedaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/新闻daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/经济daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/工具daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/CVSdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Macdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/金钱daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/思考daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/VSCodedaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/NodeJSdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Parallels Desktopdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/虚拟机daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/市场daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/ReactJSdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/文字daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/Pythondaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/WebStormdaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/营销daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/健康daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/查理·芒格daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/企业daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/投资daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/教育daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/心理daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/indigodaily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/品牌daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/广告daily0.72021-12-16T13:36:37.657Z -https://tangly1024.com/tag/区块链daily0.72021-12-16T13:36:37.657Z - \ No newline at end of file