)}
- {siteConfig('CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH') && (
+ {CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH && (
}
*/
@@ -13,8 +13,14 @@ import { isIterable } from '../utils'
* @param allPosts
* @returns {Promise<{}|*[]>}
*/
-export function getAllCategories({ allPages, categoryOptions, sliceCount = 0 }) {
- const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
+export function getAllCategories({
+ allPages,
+ categoryOptions,
+ sliceCount = 0
+}) {
+ const allPosts = allPages?.filter(
+ page => page.type === 'Post' && page.status === 'Published'
+ )
if (!allPosts || !categoryOptions) {
return []
}
diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js
index 4c7559b9..cac8dac7 100644
--- a/lib/notion/getAllTags.js
+++ b/lib/notion/getAllTags.js
@@ -1,5 +1,5 @@
+import { siteConfig } from '../config'
import { isIterable } from '../utils'
-import BLOG from '@/blog.config'
/**
* 获取所有文章的标签
@@ -8,8 +8,15 @@ import BLOG from '@/blog.config'
* @param tagOptions tags的下拉选项
* @returns {Promise<{}|*[]>}
*/
-export function getAllTags({ allPages, sliceCount = 0, tagOptions }) {
- const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
+export function getAllTags({
+ allPages,
+ sliceCount = 0,
+ tagOptions,
+ NOTION_CONFIG
+}) {
+ const allPosts = allPages?.filter(
+ page => page.type === 'Post' && page.status === 'Published'
+ )
if (!allPosts || !tagOptions) {
return []
@@ -27,7 +34,12 @@ export function getAllTags({ allPages, sliceCount = 0, tagOptions }) {
})
const list = []
- const { IS_TAG_COLOR_DISTINGUISHED } = BLOG
+ const IS_TAG_COLOR_DISTINGUISHED = siteConfig(
+ 'IS_TAG_COLOR_DISTINGUISHED',
+ false,
+ NOTION_CONFIG
+ )
+ const TAG_SORT_BY_COUNT = siteConfig('TAG_SORT_BY_COUNT', true, NOTION_CONFIG)
if (isIterable(tagOptions)) {
if (!IS_TAG_COLOR_DISTINGUISHED) {
// 如果不区分颜色, 那么不同颜色相同名称的tag当做同一种tag
@@ -52,7 +64,10 @@ export function getAllTags({ allPages, sliceCount = 0, tagOptions }) {
}
// 按照数量排序
- // list.sort((a, b) => b.count - a.count)
+ if (TAG_SORT_BY_COUNT) {
+ list.sort((a, b) => b.count - a.count)
+ }
+
if (sliceCount && sliceCount > 0) {
return list.slice(0, sliceCount)
} else {
diff --git a/themes/heo/components/PaginationNumber.js b/themes/heo/components/PaginationNumber.js
index 54c1bf34..5110064e 100644
--- a/themes/heo/components/PaginationNumber.js
+++ b/themes/heo/components/PaginationNumber.js
@@ -44,7 +44,7 @@ const PaginationNumber = ({ page, totalPage }) => {
return (
<>
{/* pc端分页按钮 */}
-
+
{/* 上一页 */}
{
: `${pagePrefix}/page/${currentPage - 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
- rel="prev"
- className={`${currentPage === 1 ? 'invisible' : 'block'}`}
- >
-
-
-
+ rel='prev'
+ className={`${currentPage === 1 ? 'invisible' : 'block'}`}>
+
+
+
{locale.PAGINATION.PREV}
{/* 分页 */}
-
+
{pages}
{/* 跳转页码 */}
-
+
@@ -91,12 +88,11 @@ const PaginationNumber = ({ page, totalPage }) => {
pathname: `${pagePrefix}/page/${currentPage + 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
- rel="next"
- className={`${+showNext ? 'block' : 'invisible'} `}
- >
-
-
-
+ rel='next'
+ className={`${+showNext ? 'block' : 'invisible'} `}>
+
+
+
{locale.PAGINATION.NEXT}
@@ -105,7 +101,7 @@ const PaginationNumber = ({ page, totalPage }) => {
{/* 移动端分页 */}
-
+
{/* 上一页 */}
{
: `${pagePrefix}/page/${currentPage - 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
- rel="prev"
- className={`${showPrev ? 'block' : 'hidden'} dark:text-white relative w-full flex-1 h-14 flex items-center transition-all duration-200 justify-center py-2 px-2 bg-white dark:bg-[#1e1e1e] border rounded-xl cursor-pointer`}
- >
+ rel='prev'
+ className={`${showPrev ? 'block' : 'hidden'} dark:text-white relative w-full flex-1 h-14 flex items-center transition-all duration-200 justify-center py-2 px-2 bg-white dark:bg-[#1e1e1e] border rounded-xl cursor-pointer`}>
{locale.PAGINATION.PREV}
- {showPrev && showNext &&
}
+ {showPrev && showNext &&
}
{/* 下一页 */}
{
pathname: `${pagePrefix}/page/${currentPage + 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
- rel="next"
- className={`${+showNext ? 'block' : 'hidden'} dark:text-white relative w-full flex-1 h-14 flex items-center transition-all duration-200 justify-center py-2 px-2 bg-white dark:bg-[#1e1e1e] border rounded-xl cursor-pointer`}
- >
+ rel='next'
+ className={`${+showNext ? 'block' : 'hidden'} dark:text-white relative w-full flex-1 h-14 flex items-center transition-all duration-200 justify-center py-2 px-2 bg-white dark:bg-[#1e1e1e] border rounded-xl cursor-pointer`}>
{locale.PAGINATION.NEXT}
@@ -161,8 +155,7 @@ function getPageElement(page, currentPage, pagePrefix) {
? 'bg-indigo-600 dark:bg-yellow-600 text-white '
: 'dark:bg-[#1e1e1e] bg-white') +
' hover:border-indigo-600 dark:hover:bg-yellow-600 dark:border-gray-600 px-4 border py-2 rounded-lg drop-shadow-sm duration-200 transition-colors'
- }
- >
+ }>
{page}
)
@@ -195,7 +188,7 @@ function generatePages(pagePrefix, page, currentPage, totalPage) {
}
if (startPage > 2) {
pages.push(
-
+
...{' '}
)
diff --git a/themes/heo/components/SideRight.js b/themes/heo/components/SideRight.js
index 775b9b76..996c50de 100644
--- a/themes/heo/components/SideRight.js
+++ b/themes/heo/components/SideRight.js
@@ -1,12 +1,12 @@
+import Live2D from '@/components/Live2D'
+import dynamic from 'next/dynamic'
+import { AnalyticsCard } from './AnalyticsCard'
import Card from './Card'
-import TagGroups from './TagGroups'
import Catalog from './Catalog'
import { InfoCard } from './InfoCard'
-import dynamic from 'next/dynamic'
-import Live2D from '@/components/Live2D'
-import { AnalyticsCard } from './AnalyticsCard'
-import TouchMeCard from './TouchMeCard'
import LatestPostsGroupMini from './LatestPostsGroupMini'
+import TagGroups from './TagGroups'
+import TouchMeCard from './TouchMeCard'
const FaceBookPage = dynamic(
() => {
@@ -27,46 +27,46 @@ const FaceBookPage = dynamic(
* @returns
*/
export default function SideRight(props) {
- const {
- post, tagOptions,
- currentTag, rightAreaSlot
- } = props
+ const { post, tagOptions, currentTag, rightAreaSlot } = props
+
+ // 只摘取标签的前60个,防止右侧过长
+ const sortedTags = tagOptions?.slice(0, 60) || []
return (
-
+
+
-
+
+ {/* 文章页显示目录 */}
+ {post && post.toc && post.toc.length > 0 && (
+
+
+
+ )}
-
-
- {/* 文章页显示目录 */}
- {post && post.toc && post.toc.length > 0 && (
-
-
-
- )}
-
- {/* 联系交流群 */}
-
-
- {/* 最新文章列表 */}
-
-
-
-
- {rightAreaSlot}
-
-
-
-
- {/* 标签和成绩 */}
-
-
-
-
-
-
+ {/* 联系交流群 */}
+
+ {/* 最新文章列表 */}
+
+
+
+ {rightAreaSlot}
+
+
+
+
+ {/* 标签和成绩 */}
+
+
+
+
+
+
+
)
}
diff --git a/themes/heo/index.js b/themes/heo/index.js
index f7725939..bd2fb42b 100644
--- a/themes/heo/index.js
+++ b/themes/heo/index.js
@@ -56,7 +56,7 @@ const LayoutBase = props => {
const router = useRouter()
const headerSlot = (
-