+ className='flex space-x-10 animate__animated animate__fadeIn duration-200 my-5 px-5 py-6 justify-center bg-white dark:bg-black dark:text-gray-200'>
diff --git a/components/SearchInput.js b/components/SearchInput.js
index 6ed58415..04e0c17c 100644
--- a/components/SearchInput.js
+++ b/components/SearchInput.js
@@ -5,11 +5,14 @@ import { useRef, useState } from 'react'
const SearchInput = ({ currentTag, currentSearch }) => {
const { locale } = useGlobal()
const [searchKey, setSearchKey] = useState(currentSearch)
+ const [onLoading,setLoadingState] = useState(false)
const router = useRouter()
const searchInputRef = useRef()
const handleSearch = (key) => {
if (key && key !== '') {
+ setLoadingState(true)
router.push({ pathname: '/search', query: { s: key } }).then(r => {
+ setLoadingState(false)
})
} else {
router.push({ pathname: '/' }).then(r => {
@@ -43,11 +46,11 @@ const SearchInput = ({ currentTag, currentSearch }) => {
onChange={e => updateSearchKey(e.target.value)}
defaultValue={currentSearch}
/>
- { (searchKey && searchKey.length &&
)}
+ { (searchKey && searchKey.length &&
)}
{ handleSearch(searchKey) }}>
-
+
}
diff --git a/components/TagItemMini.js b/components/TagItemMini.js
index 01f3a857..c531bca7 100644
--- a/components/TagItemMini.js
+++ b/components/TagItemMini.js
@@ -1,7 +1,7 @@
import Link from 'next/link'
-const TagItemMini = ({ tag, selected = false, count }) => (
-
+const TagItemMini = ({ tag, selected = false, count }) => {
+ return
(
{tag + (count ? `(${count})` : '')}
-)
+}
export default TagItemMini
diff --git a/components/TagList.js b/components/TagList.js
index a4f77534..65ab2f44 100644
--- a/components/TagList.js
+++ b/components/TagList.js
@@ -10,13 +10,13 @@ import TagItemMini from '@/components/TagItemMini'
const TagList = ({ tags, currentTag }) => {
if (!tags) return <>>
return (
-
- 标签:
- {Object.keys(tags).map(key => {
- const selected = key === currentTag
+ {tags.map(tag => {
+ const selected = tag.name === currentTag
return (
-
+
-
- {`${key} (${tags[key]})`}
+ {`${tag.name} (${tag.count})`}
diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js
index 7b2d8a5e..742bc6ee 100644
--- a/lib/notion/getAllTags.js
+++ b/lib/notion/getAllTags.js
@@ -1,3 +1,5 @@
+import { rest } from "lodash"
+
/**
* 获取所有文章的标签
* @param allPosts
@@ -10,6 +12,8 @@ export async function getAllTags (allPosts) {
let tags = allPosts.map(p => p.tags)
tags = [...tags.flat()]
+
+ // 标签计数
const tagObj = {}
tags.forEach(tag => {
if (tag in tagObj) {
@@ -18,5 +22,9 @@ export async function getAllTags (allPosts) {
tagObj[tag] = 1
}
})
- return tagObj
+
+ // 按照标签数量排序
+ const list = Object.keys(tagObj).map((index) => {return {name:index,count:tagObj[index]}})
+ list.sort((a, b) => b.count - a.count)
+ return list
}
diff --git a/pages/article/[slug].js b/pages/article/[slug].js
index 3104e41a..58c7ec6a 100644
--- a/pages/article/[slug].js
+++ b/pages/article/[slug].js
@@ -111,12 +111,12 @@ const ArticleDetail = ({ post, blockMap, tags, prev, next, posts, categories })
-
+
———
💖 本 文 结 束 😚 感 谢 您 的 阅 读 💖
———
-
+
打赏一杯咖啡~
@@ -133,7 +133,7 @@ const ArticleDetail = ({ post, blockMap, tags, prev, next, posts, categories })
-
+
{post.tags && (
diff --git a/styles/notion.css b/styles/notion.css
index 6f2774ab..a24dc846 100644
--- a/styles/notion.css
+++ b/styles/notion.css
@@ -180,13 +180,14 @@
min-height: 100vh;
}
-.notion-viewport {
+/* .notion-viewport {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
-}
+ z-index: -10;
+} */
.medium-zoom-overlay {
z-index: 300;
@@ -1613,9 +1614,6 @@ pre[class*='language-'] {
.notion-bookmark:hover {
@apply border-blue-400;
}
-.notion-viewport {
- z-index: -10;
-}
.notion-asset-caption {
@apply text-center;
}