From 917b94833981d87b6f02e8f8f9882d018d94d775 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 29 Dec 2022 20:28:01 +0800 Subject: [PATCH 1/5] new contributor --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 495a7042..137323ab 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ Ylarod
Ylarod

🔧 🐛 + Etherrreal.
Etherrreal.

🔧 🐛 + From 28de8eb49e989919d49bcb7b64b3b075a444724d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 29 Dec 2022 20:51:47 +0800 Subject: [PATCH 2/5] =?UTF-8?q?hexo=E5=BE=AE=E8=B0=83=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/notion.css | 2 +- themes/hexo/components/ArticleRecommend.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/styles/notion.css b/styles/notion.css index f3047f6b..9ec0e222 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -1965,7 +1965,7 @@ thead, tbody tr { } .notion-collection-card{ - @apply dark:hover:text-gray-200 + @apply dark:text-gray-200 dark:bg-gray-800 dark:hover:bg-black } .notion-code-copy{ diff --git a/themes/hexo/components/ArticleRecommend.js b/themes/hexo/components/ArticleRecommend.js index e6900c09..af081a1c 100644 --- a/themes/hexo/components/ArticleRecommend.js +++ b/themes/hexo/components/ArticleRecommend.js @@ -9,6 +9,8 @@ import { useGlobal } from '@/lib/global' * @returns */ export default function ArticleRecommend({ recommendPosts, siteInfo }) { + const { locale } = useGlobal() + if ( !CONFIG_HEXO.ARTICLE_RECOMMEND || !recommendPosts || @@ -16,11 +18,11 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) { ) { return <> } - const { locale } = useGlobal() + return (
-
+
{locale.COMMON.RELATE_POSTS}
From cf254a27977fc2c373b301ef7094a0b789ea004a Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 29 Dec 2022 20:57:29 +0800 Subject: [PATCH 3/5] =?UTF-8?q?matery=E8=8F=9C=E5=8D=95=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/matery/components/MenuButtonGroupTop.js | 6 +++--- themes/matery/components/SideBar.js | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/themes/matery/components/MenuButtonGroupTop.js b/themes/matery/components/MenuButtonGroupTop.js index 89113279..e76eaa4a 100644 --- a/themes/matery/components/MenuButtonGroupTop.js +++ b/themes/matery/components/MenuButtonGroupTop.js @@ -9,9 +9,9 @@ const MenuButtonGroupTop = (props) => { let links = [ { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_MATERY.MENU_ARCHIVE }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_MATERY.MENU_SEARCH } - // { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_MATERY.MENU_CATEGORY }, - // { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_MATERY.MENU_TAG } + { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_MATERY.MENU_SEARCH }, + { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_MATERY.MENU_CATEGORY }, + { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_MATERY.MENU_TAG } ] if (customNav) { diff --git a/themes/matery/components/SideBar.js b/themes/matery/components/SideBar.js index 3f529729..20449e19 100644 --- a/themes/matery/components/SideBar.js +++ b/themes/matery/components/SideBar.js @@ -2,6 +2,7 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' +import CONFIG_MATERY from '../config_matery' /** * 标签组 @@ -18,7 +19,10 @@ const SideBar = (props) => { const defaultLinks = [ { icon: 'fas fa-home', name: locale.NAV.INDEX, to: '/' || '/', show: true }, { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: true }, - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: true } + { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_MATERY.MENU_ARCHIVE }, + { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_MATERY.MENU_CATEGORY }, + { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_MATERY.MENU_TAG } + ] let links = [].concat(defaultLinks) if (customNav) { From 8640eee3929981c38dec62d22e066312da111d7a Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 29 Dec 2022 21:38:58 +0800 Subject: [PATCH 4/5] =?UTF-8?q?sitemap.xml=E6=89=8B=E5=8A=A8=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pages/sitemap.xml.js | 55 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 pages/sitemap.xml.js diff --git a/package.json b/package.json index 8d68b740..3024d51a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "scripts": { "dev": "next dev", - "build": "next build && next-sitemap --config next-sitemap.config.js", + "build": "next build", "start": "next start", "post-build": "next-sitemap --config next-sitemap.config.js", "bundle-report": "ANALYZE=true yarn build" diff --git a/pages/sitemap.xml.js b/pages/sitemap.xml.js new file mode 100644 index 00000000..403d6cd7 --- /dev/null +++ b/pages/sitemap.xml.js @@ -0,0 +1,55 @@ +// pages/sitemap.xml.js +import { getServerSideSitemap } from 'next-sitemap' +import { getGlobalNotionData } from '@/lib/notion/getNotionData' +import BLOG from '@/blog.config' + +export const getServerSideProps = async (ctx) => { + const { allPages } = await getGlobalNotionData({ from: 'rss' }) + const defaultFields = [ + { + loc: `${BLOG.LINK}`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + }, { + loc: `${BLOG.LINK}/archive`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + }, { + loc: `${BLOG.LINK}/category`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + }, { + loc: `${BLOG.LINK}/feed`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + }, { + loc: `${BLOG.LINK}/search`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + }, { + loc: `${BLOG.LINK}/tag`, // Absolute url + lastmod: new Date(), + changefreq: 'daily', + priority: '0.7' + } + ] + const postFields = allPages?.map(post => { + console.log(post) + return { + loc: `${BLOG.LINK}/${post.slug}`, // Absolute url + lastmod: new Date(post?.date?.start_date || post?.createdTime), + changefreq: 'daily', + priority: '0.7' + } + }) + const fields = defaultFields.concat(postFields) + + return getServerSideSitemap(ctx, fields) +} + +export default () => { } From 2d64451dfe9b1bf362e5cc3a5e94e3a6b217ba61 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 1 Jan 2023 18:55:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[...slug].js | 1 - pages/sitemap.xml.js | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pages/[...slug].js b/pages/[...slug].js index b4e1d47e..3013696d 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -108,7 +108,6 @@ export async function getStaticPaths() { export async function getStaticProps({ params: { slug } }) { let fullSlug = slug.join('/') - console.log('[读取Notion]', fullSlug) if (BLOG.PSEUDO_STATIC) { if (!fullSlug.endsWith('.html')) { fullSlug += '.html' diff --git a/pages/sitemap.xml.js b/pages/sitemap.xml.js index 403d6cd7..083edc0b 100644 --- a/pages/sitemap.xml.js +++ b/pages/sitemap.xml.js @@ -7,41 +7,40 @@ export const getServerSideProps = async (ctx) => { const { allPages } = await getGlobalNotionData({ from: 'rss' }) const defaultFields = [ { - loc: `${BLOG.LINK}`, // Absolute url + loc: `${BLOG.LINK}`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/archive`, // Absolute url + loc: `${BLOG.LINK}/archive`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/category`, // Absolute url + loc: `${BLOG.LINK}/category`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/feed`, // Absolute url + loc: `${BLOG.LINK}/feed`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/search`, // Absolute url + loc: `${BLOG.LINK}/search`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' }, { - loc: `${BLOG.LINK}/tag`, // Absolute url + loc: `${BLOG.LINK}/tag`, lastmod: new Date(), changefreq: 'daily', priority: '0.7' } ] const postFields = allPages?.map(post => { - console.log(post) return { - loc: `${BLOG.LINK}/${post.slug}`, // Absolute url + loc: `${BLOG.LINK}/${post.slug}`, lastmod: new Date(post?.date?.start_date || post?.createdTime), changefreq: 'daily', priority: '0.7' @@ -49,6 +48,12 @@ export const getServerSideProps = async (ctx) => { }) const fields = defaultFields.concat(postFields) + // 缓存 + // ctx.res.setHeader( + // 'Cache-Control', + // 'public, s-maxage=10, stale-while-revalidate=59' + // ) + return getServerSideSitemap(ctx, fields) }