diff --git a/lib/notion/getAllPosts.js b/lib/notion/getAllPosts.js index 246c5c3f..dc89beb7 100644 --- a/lib/notion/getAllPosts.js +++ b/lib/notion/getAllPosts.js @@ -9,10 +9,10 @@ import { delCacheData } from '@/lib/cache/cache_manager' * 获取所有文章列表 * @param notionPageData * @param from - * @param includePage 是否包含Page类型 + * @param pageType 页面类型数组 ['Post','Page'] * @returns {Promise<*[]>} */ -export async function getAllPosts ({ notionPageData, from, includePage = false }) { +export async function getAllPosts ({ notionPageData, from, pageType }) { if (!notionPageData) { notionPageData = await getNotionPageData({ from }) } @@ -31,11 +31,12 @@ export async function getAllPosts ({ notionPageData, from, includePage = false } const id = pageIds[i] const properties = (await getPageProperties(id, pageBlock, schema)) || null properties.slug = properties.slug ?? properties.id - properties.createdTime = new Date(pageBlock[id].value?.created_time).toString() - properties.lastEditedTime = new Date(pageBlock[id].value?.last_edited_time).toString() + properties.createdTime = new Date(pageBlock[id].value?.created_time).toString() // FIXME 似乎没有created_time 字段了 + properties.lastEditedTime = new Date(pageBlock[id].value?.last_edited_time).toString() // FIXME 似乎没有created_time 字段了 properties.fullWidth = pageBlock[id].value?.format?.page_full_width ?? false properties.page_cover = getPostCover(id, pageBlock) ?? null properties.content = pageBlock[id].value?.content ?? [] + properties.icon = pageBlock[id].value?.icon ?? null properties.tagItems = properties?.tags?.map(tag => { return { name: tag, color: tagOptions.find(t => t.value === tag)?.color || 'gray' } }) || [] @@ -45,19 +46,7 @@ export async function getAllPosts ({ notionPageData, from, includePage = false } // remove all the the items doesn't meet requirements const posts = data.filter(post => { - if (includePage) { - return ( - post.title && post.slug && - post?.status?.[0] === 'Published' && - (post?.type?.[0] === 'Post' || post?.type?.[0] === 'Page') - ) - } else { - return ( - post.title && post.slug && - post?.status?.[0] === 'Published' && - (post?.type?.[0] === 'Post') - ) - } + return post.title && post?.status?.[0] === 'Published' && pageType.indexOf(post?.type?.[0]) > -1 }) if (!posts || posts.length === 0) { @@ -65,6 +54,7 @@ export async function getAllPosts ({ notionPageData, from, includePage = false } const cacheKey = 'page_block_' + BLOG.NOTION_PAGE_ID await delCacheData(cacheKey) } + // Sort by date if (BLOG.POSTS_SORT_BY === 'date') { posts.sort((a, b) => { diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 22303348..80930a33 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -12,27 +12,30 @@ import { getAllTags } from './getAllTags' * @param {*} from * @param latestPostCount 截取最新文章数量 * @param tagsCount 截取标签数量 - * @param includePage 是否包含PAGE类型 - * @returns {} - * allPosts 所有博客 - * categories 所有分类 - * tags 所有标签 + * @param pageType 过滤的文章类型,数组格式 ['Page','Post'] + * @returns { + allPosts, 所有博客 + latestPosts, + categories, 所有分类 + postCount, + customNav, 自定义导航菜单 + tags 所有标签 + } + * */ export async function getGlobalNotionData ({ pageId = BLOG.NOTION_PAGE_ID, from, latestPostCount = 5, tagsCount = 16, - includePage + pageType = ['Post'] }) { const notionPageData = await getNotionPageData({ pageId, from }) const tagOptions = notionPageData.tagOptions - const allPosts = await getAllPosts({ notionPageData, from, includePage }) - const postCount = allPosts?.filter(post => - post.title && post.slug && - post?.status?.[0] === 'Published' && - (post?.type?.[0] === 'Post') + const allPosts = await getAllPosts({ notionPageData, from, pageType }) + const postCount = allPosts?.filter(post => post?.status?.[0] === 'Published' && (post?.type?.[0] === 'Post') )?.length + const customNav = await getCustomNav({ notionPageData }) const categories = await getAllCategories(allPosts) const tags = await getAllTags({ allPosts, tagOptions, sliceCount: tagsCount }) // 深拷贝 @@ -51,6 +54,7 @@ export async function getGlobalNotionData ({ latestPosts, categories, postCount, + customNav, tags } } @@ -77,6 +81,18 @@ export async function getNotionPageData ({ pageId, from }) { return pageRecordMap } +async function getCustomNav ({ notionPageData }) { + if (!notionPageData) { + notionPageData = await getNotionPageData({ from: 'custom-nav' }) + } + if (!notionPageData) { + return [] + } + const allPage = await getAllPosts({ notionPageData, from: 'custom-nav', pageType: ['Page'] }) + console.log(allPage) + return [{ icon: 'fas fa-file-alt', name: '简历', to: '/' + 'resume', show: true }] +} + /** * 获取标签选项 * @param schema diff --git a/package.json b/package.json index aa2c37a4..9a7a661c 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,6 @@ "post-build": "next-sitemap --config next-sitemap.config.js" }, "dependencies": { - "@fortawesome/fontawesome-svg-core": "^1.2.36", - "@fortawesome/free-brands-svg-icons": "^5.15.4", - "@fortawesome/free-solid-svg-icons": "^5.15.4", - "@fortawesome/react-fontawesome": "^0.1.16", "@popperjs/core": "^2.9.3", "animate.css": "^4.1.1", "axios": ">=0.21.1", diff --git a/pages/[slug].js b/pages/[slug].js new file mode 100644 index 00000000..3ffa2a56 --- /dev/null +++ b/pages/[slug].js @@ -0,0 +1,59 @@ +import BLOG from '@/blog.config' +import { getPostBlocks } from '@/lib/notion' +import { getGlobalNotionData } from '@/lib/notion/getNotionData' +import { LayoutSlug } from '@/themes' +import Custom404 from '@/pages/404' + +/** + * 根据notion的slug访问页面,针对类型为Page的页面 + * @param {*} props + * @returns + */ +const Slug = (props) => { + if (!props.post) { + return + } + return +} + +export async function getStaticPaths () { + if (!BLOG.isProd) { + return { + paths: [], + fallback: true + } + } + + const from = 'slug-paths' + const { allPosts } = await getGlobalNotionData({ from, pageType: ['Page'] }) + return { + paths: allPosts.map(row => ({ params: { slug: row.slug } })), + fallback: true + } +} + +export async function getStaticProps ({ params: { slug } }) { + const from = `slug-props-${slug}` + const { allPosts, categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from, pageType: ['Page'] }) + + const post = allPosts.find(p => p.slug === slug) + if (!post) { + return { props: {}, revalidate: 1 } + } + + post.blockMap = await getPostBlocks(post.id, 'slug') + + return { + props: { + post, + tags, + categories, + postCount, + latestPosts, + customNav + }, + revalidate: 1 + } +} + +export default Slug diff --git a/pages/_app.js b/pages/_app.js index 43aeb3f2..98c5abc1 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -14,9 +14,6 @@ import 'prismjs/themes/prism-okaidia.css' import 'katex/dist/katex.min.css' import dynamic from 'next/dynamic' import { GlobalContextProvider } from '@/lib/global' -import { config } from '@fortawesome/fontawesome-svg-core' -import '@fortawesome/fontawesome-svg-core/styles.css' -config.autoAddCss = false const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false }) const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false }) @@ -30,6 +27,7 @@ const MyApp = ({ Component, pageProps }) => { {BLOG.ANALYTICS_GOOGLE_ID && } {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && } {BLOG.ADSENSE_GOOGLE_ID && } + ) diff --git a/pages/about.js b/pages/about.js index 895a94f3..24345e94 100644 --- a/pages/about.js +++ b/pages/about.js @@ -26,7 +26,7 @@ export async function getStaticProps () { latestPosts } = await getGlobalNotionData({ from, - includePage: true + pageType: ['Page'] }) const post = allPosts.find(p => p.slug === 'about') diff --git a/pages/article/[slug].js b/pages/article/[slug].js index d20cf97a..784b892e 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -13,7 +13,7 @@ const Slug = (props) => { if (!props.post) { return } - return + return } export async function getStaticPaths () { @@ -25,7 +25,7 @@ export async function getStaticPaths () { } const from = 'slug-paths' - const { allPosts } = await getGlobalNotionData({ from, includePage: true }) + const { allPosts } = await getGlobalNotionData({ from }) return { paths: allPosts.map(row => ({ params: { slug: row.slug } })), fallback: true @@ -34,8 +34,8 @@ export async function getStaticPaths () { export async function getStaticProps ({ params: { slug } }) { const from = `slug-props-${slug}` - const { allPosts, categories, tags, postCount, latestPosts } = - await getGlobalNotionData({ from, includePage: true }) + const { customNav, allPosts, categories, tags, postCount, latestPosts } = + await getGlobalNotionData({ from }) const post = allPosts.find(p => p.slug === slug) @@ -61,7 +61,8 @@ export async function getStaticProps ({ params: { slug } }) { recommendPosts, categories, postCount, - latestPosts + latestPosts, + customNav }, revalidate: 1 } diff --git a/pages/index.js b/pages/index.js index c499cd6f..be549212 100644 --- a/pages/index.js +++ b/pages/index.js @@ -9,7 +9,7 @@ const Index = (props) => { export async function getStaticProps () { const from = 'index' - const { allPosts, latestPosts, categories, tags, postCount } = await getGlobalNotionData({ from }) + const { allPosts, latestPosts, categories, tags, postCount, customNav } = await getGlobalNotionData({ from, pageType: ['Post'] }) const meta = { title: `${BLOG.TITLE}`, description: BLOG.DESCRIPTION, @@ -45,7 +45,8 @@ export async function getStaticProps () { postCount, tags, categories, - meta + meta, + customNav }, revalidate: 1 } diff --git a/pages/search.js b/pages/search.js index 79854860..5f765482 100644 --- a/pages/search.js +++ b/pages/search.js @@ -8,7 +8,7 @@ export async function getStaticProps () { tags, postCount, latestPosts - } = await getGlobalNotionData({ from: 'search-props' }) + } = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] }) return { props: { posts: allPosts, diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 2c72b75f..01cf5220 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -50,10 +50,7 @@ function getTagNames (tags) { export async function getStaticPaths () { const from = 'tag-static-path' - const { tags } = await getGlobalNotionData({ - from, - tagsCount: 0 - }) + const { tags } = await getGlobalNotionData({ from, tagsCount: 0 }) const tagNames = getTagNames(tags) return { diff --git a/pages/tag/index.js b/pages/tag/index.js index 806cd993..eda44e7d 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -8,16 +8,7 @@ const TagIndex = (props) => { export async function getStaticProps () { const from = 'tag-index-props' - const { - categories, - tags, - postCount, - latestPosts - } = await getGlobalNotionData({ - from, - includePage: false, - tagsCount: 0 - }) + const { categories, tags, postCount, latestPosts } = await getGlobalNotionData({ from, tagsCount: 0 }) return { props: { diff --git a/themes/NEXT/Layout404.js b/themes/NEXT/Layout404.js index 54e31429..ff7a14a7 100644 --- a/themes/NEXT/Layout404.js +++ b/themes/NEXT/Layout404.js @@ -1,8 +1,6 @@ import { useRouter } from 'next/router' import LayoutBase from './LayoutBase' import BLOG from '@/blog.config' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faSpinner } from '@fortawesome/free-solid-svg-icons' import { useEffect } from 'react' export const Layout404 = () => { @@ -25,7 +23,7 @@ export const Layout404 = () => {
-

404

+

404

页面无法加载,即将返回首页

diff --git a/themes/NEXT/LayoutBase.js b/themes/NEXT/LayoutBase.js index d93def9a..8a56d68f 100644 --- a/themes/NEXT/LayoutBase.js +++ b/themes/NEXT/LayoutBase.js @@ -15,33 +15,11 @@ import CONFIG_NEXT from './config_next' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 - * @param children - * @param layout - * @param tags - * @param meta - * @param post - * @param currentSearch - * @param currentCategory - * @param currentTag - * @param categories * @returns {JSX.Element} * @constructor */ -const LayoutBase = ({ - children, - headerSlot, - tags, - meta, - post, - postCount, - sideBarSlot, - floatSlot, - rightAreaSlot, - currentSearch, - currentCategory, - currentTag, - categories -}) => { +const LayoutBase = (props) => { + const { children, headerSlot, meta, sideBarSlot, floatSlot, rightAreaSlot } = props const { onLoading } = useGlobal() const targetRef = useRef(null) @@ -71,23 +49,18 @@ const LayoutBase = ({ - + <>{headerSlot}
- +
- {onLoading - ? - : <> - {children} - - } + {onLoading ? : <> {children} }
- +
{/* 右下角悬浮 */} diff --git a/themes/NEXT/LayoutCategoryIndex.js b/themes/NEXT/LayoutCategoryIndex.js index b890f32b..a6cf3eea 100644 --- a/themes/NEXT/LayoutCategoryIndex.js +++ b/themes/NEXT/LayoutCategoryIndex.js @@ -1,8 +1,6 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import LayoutBase from './LayoutBase' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faFolder, faThList } from '@fortawesome/free-solid-svg-icons' import Link from 'next/link' export const LayoutCategoryIndex = ({ @@ -21,14 +19,14 @@ export const LayoutCategoryIndex = ({ return
- {locale.COMMON.CATEGORY}: + {locale.COMMON.CATEGORY}:
{Object.keys(categories).map(category => { return
- {category}({categories[category]}) + {category}({categories[category]})
})} diff --git a/themes/NEXT/LayoutIndex.js b/themes/NEXT/LayoutIndex.js index 19993b20..12d77aa0 100644 --- a/themes/NEXT/LayoutIndex.js +++ b/themes/NEXT/LayoutIndex.js @@ -6,24 +6,18 @@ import BlogPostListScroll from './components/BlogPostListScroll' import BlogPostListPage from './components/BlogPostListPage' import CONFIG_NEXT from './config_next' -export const LayoutIndex = ({ posts, tags, meta, categories, postCount, latestPosts }) => { +export const LayoutIndex = (props) => { + const { latestPosts } = props + const rightAreaSlot = CONFIG_NEXT.RIGHT_LATEST_POSTS && return } - meta={meta} - tags={tags} sideBarSlot={} - rightAreaSlot={ - CONFIG_NEXT.RIGHT_LATEST_POSTS && - } - postCount={postCount} - categories={categories} + rightAreaSlot={rightAreaSlot} + {...props} > {CONFIG_NEXT.POST_LIST_TYPE !== 'page' - ? ( - - ) - : ( - - )} + ? + : + } } diff --git a/themes/NEXT/LayoutSearch.js b/themes/NEXT/LayoutSearch.js index 4e845942..35aacdce 100644 --- a/themes/NEXT/LayoutSearch.js +++ b/themes/NEXT/LayoutSearch.js @@ -1,7 +1,5 @@ import LayoutBase from './LayoutBase' import StickyBar from './components/StickyBar' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faSearch } from '@fortawesome/free-solid-svg-icons' import BlogPostListScroll from './components/BlogPostListScroll' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' @@ -36,7 +34,7 @@ export const LayoutSearch = ({ posts, tags, categories, postCount }) => { >
- {' '} + {' '} {filteredPosts.length} {locale.COMMON.RESULT_OF_SEARCH}
diff --git a/themes/NEXT/LayoutSlug.js b/themes/NEXT/LayoutSlug.js index ec1ad070..1a9d4185 100644 --- a/themes/NEXT/LayoutSlug.js +++ b/themes/NEXT/LayoutSlug.js @@ -10,16 +10,8 @@ import Live2D from './components/Live2D' import { useRef } from 'react' import CONFIG_NEXT from './config_next' -export const LayoutSlug = ({ - post, - tags, - prev, - next, - recommendPosts, - categories, - postCount, - latestPosts -}) => { +export const LayoutSlug = (props) => { + const { post, prev, next, recommendPosts, latestPosts, showArticleInfo } = props const meta = { title: `${post.title} | ${BLOG.TITLE}`, description: post.summary, @@ -41,12 +33,8 @@ export const LayoutSlug = ({ return ( @@ -54,9 +42,10 @@ export const LayoutSlug = ({ > {/* 悬浮目录按钮 */} diff --git a/themes/NEXT/LayoutTagIndex.js b/themes/NEXT/LayoutTagIndex.js index 3abdfd25..801461a9 100644 --- a/themes/NEXT/LayoutTagIndex.js +++ b/themes/NEXT/LayoutTagIndex.js @@ -1,8 +1,6 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import LayoutBase from './LayoutBase' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faTags } from '@fortawesome/free-solid-svg-icons' import TagItem from './components/TagItem' export const LayoutTagIndex = ({ tags, categories, postCount, latestPosts }) => { @@ -14,7 +12,7 @@ export const LayoutTagIndex = ({ tags, categories, postCount, latestPosts }) => } return
-
{locale.COMMON.TAGS}:
+
{locale.COMMON.TAGS}:
{ tags.map(tag => { return
diff --git a/themes/NEXT/components/ArticleDetail.js b/themes/NEXT/components/ArticleDetail.js index de71819c..ae430539 100644 --- a/themes/NEXT/components/ArticleDetail.js +++ b/themes/NEXT/components/ArticleDetail.js @@ -6,8 +6,6 @@ import ShareBar from './ShareBar' import TagItem from './TagItem' import formatDate from '@/lib/formatDate' import { useGlobal } from '@/lib/global' -import { faEye, faFolderOpen } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import mediumZoom from 'medium-zoom' import Link from 'next/link' import { useRouter } from 'next/router' @@ -28,7 +26,8 @@ import WordCount from './WordCount' * @param {*} param0 * @returns */ -export default function ArticleDetail ({ post, recommendPosts, prev, next }) { +export default function ArticleDetail (props) { + const { post, recommendPosts, prev, next, showArticleInfo } = props const url = BLOG.LINK + useRouter().asPath const { locale } = useGlobal() const date = formatDate(post?.date?.start_date || post.createdTime, locale.LOCALE) @@ -56,20 +55,11 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) { className="subpixel-antialiased py-10 px-5 lg:pt-24 md:px-24 dark:border-gray-700 bg-white dark:bg-gray-800" > -
+ {showArticleInfo &&
{post.type && !post.type.includes('Page') && post?.page_cover && (
{/* eslint-disable-next-line @next/next/no-img-element */} {post.title} - {/*
- {post.title} -
*/}
)} @@ -80,14 +70,14 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) {
- + {post.category && <> + - - {post.category} + {post.category} | - + } {post.type[0] !== 'Page' && (<> )}
- +   | @@ -113,11 +103,9 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) {
- {/*
*/} +
} -
- - {/* Notion文章主体 */} + {/* Notion内容主体 */}
{post.blockMap && ( + {showArticleInfo && <> {/* 版权声明 */} @@ -168,6 +157,7 @@ export default function ArticleDetail ({ post, recommendPosts, prev, next }) { + } {/* 评论互动 */}
diff --git a/themes/NEXT/components/BlogAround.js b/themes/NEXT/components/BlogAround.js index f69d4d78..0e572c94 100644 --- a/themes/NEXT/components/BlogAround.js +++ b/themes/NEXT/components/BlogAround.js @@ -1,6 +1,4 @@ import Link from 'next/link' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faAngleDoubleLeft, faAngleDoubleRight } from '@fortawesome/free-solid-svg-icons' /** * 上一篇,下一篇文章 @@ -14,12 +12,12 @@ export default function BlogAround ({ prev, next }) { return
{prev && - {prev.title} + {prev.title} } {next && {next.title} - + }
diff --git a/themes/NEXT/components/BlogPostCard.js b/themes/NEXT/components/BlogPostCard.js index 1f00a6ca..8fb3ce7e 100644 --- a/themes/NEXT/components/BlogPostCard.js +++ b/themes/NEXT/components/BlogPostCard.js @@ -1,7 +1,5 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' -import { faAngleRight, faFolder } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Image from 'next/image' import Link from 'next/link' import React from 'react' @@ -26,12 +24,14 @@ const BlogPostCard = ({ post, showSummary }) => {
+ { post.category && (<> - {post.category} + {post.category} | + ) } {post.date.start_date} @@ -63,7 +63,7 @@ const BlogPostCard = ({ post, showSummary }) => { {locale.COMMON.ARTICLE_DETAIL} - +
diff --git a/themes/NEXT/components/CategoryGroup.js b/themes/NEXT/components/CategoryGroup.js index e768757f..a0c8eed0 100644 --- a/themes/NEXT/components/CategoryGroup.js +++ b/themes/NEXT/components/CategoryGroup.js @@ -1,5 +1,3 @@ -import { faFolder, faFolderOpen } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import React from 'react' @@ -13,7 +11,7 @@ const CategoryGroup = ({ currentCategory, categories }) => { ? 'hover:text-white dark:hover:text-white bg-gray-600 text-white ' : 'dark:text-gray-400 text-gray-500 hover:text-white hover:bg-gray-500 dark:hover:text-white') + ' text-sm w-full items-center duration-300 px-2 cursor-pointer py-1 font-light'}> - {category}({categories[category]}) + {category}({categories[category]}) })} diff --git a/themes/NEXT/components/CategoryList.js b/themes/NEXT/components/CategoryList.js index cc876f82..d7447424 100644 --- a/themes/NEXT/components/CategoryList.js +++ b/themes/NEXT/components/CategoryList.js @@ -1,7 +1,5 @@ import Link from 'next/link' import React from 'react' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faFolder, faFolderOpen } from '@fortawesome/free-solid-svg-icons' import { useGlobal } from '@/lib/global' const CategoryList = ({ currentCategory, categories }) => { @@ -24,7 +22,7 @@ const CategoryList = ({ currentCategory, categories }) => { }`} > - + {`${category} `} diff --git a/themes/NEXT/components/FloatDarkModeButton.js b/themes/NEXT/components/FloatDarkModeButton.js index 74257bf0..2e610a2f 100644 --- a/themes/NEXT/components/FloatDarkModeButton.js +++ b/themes/NEXT/components/FloatDarkModeButton.js @@ -1,7 +1,5 @@ import { useGlobal } from '@/lib/global' import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme' -import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import CONFIG_NEXT from '../config_next' export default function FloatDarkModeButton () { @@ -27,10 +25,9 @@ export default function FloatDarkModeButton () { className={ ' text-black dark:border-gray-500 flex justify-center items-center dark:text-gray-200 py-2 px-3' } > -
) diff --git a/themes/NEXT/components/Footer.js b/themes/NEXT/components/Footer.js index 57ad7797..c0bd960c 100644 --- a/themes/NEXT/components/Footer.js +++ b/themes/NEXT/components/Footer.js @@ -1,5 +1,3 @@ -import { faCopyright, faEye, faShieldAlt, faUsers, faHeart } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React from 'react' import BLOG from '@/blog.config' @@ -11,16 +9,16 @@ const Footer = ({ title }) => { diff --git a/themes/NEXT/components/Header.js b/themes/NEXT/components/Header.js index 2e18fbe3..4f04f58f 100644 --- a/themes/NEXT/components/Header.js +++ b/themes/NEXT/components/Header.js @@ -1,6 +1,4 @@ import { useGlobal } from '@/lib/global' -import { faAngleDown } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useEffect, useState } from 'react' import Typed from 'typed.js' import CONFIG_NEXT from '../config_next' @@ -111,7 +109,7 @@ export default function Header () { }} className="cursor-pointer w-full text-center py-4 text-5xl absolute bottom-10 text-white" > - +
) diff --git a/themes/NEXT/components/JumpToBottomButton.js b/themes/NEXT/components/JumpToBottomButton.js index 70c31f2e..a629c78d 100644 --- a/themes/NEXT/components/JumpToBottomButton.js +++ b/themes/NEXT/components/JumpToBottomButton.js @@ -1,5 +1,3 @@ -import { faArrowDown } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React, { useEffect, useState } from 'react' import smoothscroll from 'smoothscroll-polyfill' import CONFIG_NEXT from '../config_next' @@ -47,7 +45,7 @@ const JumpToBottomButton = ({ showPercent = false }) => { return (
- +
{showPercent && (
{percent}%
)}
) diff --git a/themes/NEXT/components/JumpToTopButton.js b/themes/NEXT/components/JumpToTopButton.js index e4f27c05..ce7685a1 100644 --- a/themes/NEXT/components/JumpToTopButton.js +++ b/themes/NEXT/components/JumpToTopButton.js @@ -1,6 +1,4 @@ import { useGlobal } from '@/lib/global' -import { faArrowUp } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React from 'react' import CONFIG_NEXT from '../config_next' @@ -19,7 +17,7 @@ const JumpToTopButton = ({ showPercent = true, percent }) => { const { locale } = useGlobal() return (
window.scrollTo({ top: 0, behavior: 'smooth' })} >
- +
{showPercent && (
{percent}%
)}
) diff --git a/themes/NEXT/components/LatestPostsGroup.js b/themes/NEXT/components/LatestPostsGroup.js index 4c57e17f..914c73f9 100644 --- a/themes/NEXT/components/LatestPostsGroup.js +++ b/themes/NEXT/components/LatestPostsGroup.js @@ -1,7 +1,5 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' -import { faArchive, faFileAlt } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import { useRouter } from 'next/router' @@ -21,7 +19,7 @@ const LatestPostsGroup = ({ posts }) => { return <>
-
{locale.COMMON.LATEST_POSTS}
+
{locale.COMMON.LATEST_POSTS}
{posts.map(post => { const selected = currentPath === `${BLOG.PATH}/article/${post.slug}` @@ -30,7 +28,7 @@ const LatestPostsGroup = ({ posts }) => {
- +
{post.title}
diff --git a/themes/NEXT/components/LoadingCover.js b/themes/NEXT/components/LoadingCover.js index b00a8317..93e81005 100644 --- a/themes/NEXT/components/LoadingCover.js +++ b/themes/NEXT/components/LoadingCover.js @@ -1,10 +1,7 @@ -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faSpinner } from '@fortawesome/free-solid-svg-icons' - export default function LoadingCover () { return (
- +
) diff --git a/themes/NEXT/components/MenuButtonGroup.js b/themes/NEXT/components/MenuButtonGroup.js index a8a730fb..c1af7738 100644 --- a/themes/NEXT/components/MenuButtonGroup.js +++ b/themes/NEXT/components/MenuButtonGroup.js @@ -2,31 +2,34 @@ import React from 'react' import Link from 'next/link' import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faArchive, faHome, faTag, faTh, faUser } from '@fortawesome/free-solid-svg-icons' import CONFIG_NEXT from '../config_next' -const MenuButtonGroup = ({ postCount }) => { +const MenuButtonGroup = (props) => { + const { postCount, customNav } = props const { locale } = useGlobal() const router = useRouter() const archiveSlot =
{postCount}
- const links = [ - { id: 0, icon: faHome, name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { id: 1, icon: faTh, name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_NEXT.MENU_CATEGORY }, - { id: 2, icon: faTag, name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_NEXT.MENU_TAG }, - { id: 3, icon: faArchive, name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: CONFIG_NEXT.MENU_ARCHIVE }, - { id: 4, icon: faUser, name: locale.NAV.ABOUT, to: '/about', show: CONFIG_NEXT.MENU_ABOUT } + let links = [ + { icon: 'fas fa-home', name: locale.NAV.INDEX, to: '/' || '/', show: true }, + { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_NEXT.MENU_CATEGORY }, + { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_NEXT.MENU_TAG }, + { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: CONFIG_NEXT.MENU_ARCHIVE }, + { icon: 'fas fa-user', name: locale.NAV.ABOUT, to: '/about', show: CONFIG_NEXT.MENU_ABOUT } ] + if (customNav) { + links = links.concat(customNav) + } + return
@@ -41,7 +39,7 @@ const PaginationNumber = ({ page, totalPage }) => { rel='next' className={`${+showNext ? 'block' : 'invisible'} border-t-2 border-white dark:border-gray-700 hover:border-gray-400 dark:hover:border-gray-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`} > - +
diff --git a/themes/NEXT/components/SearchInput.js b/themes/NEXT/components/SearchInput.js index 5c3cface..2c18732f 100644 --- a/themes/NEXT/components/SearchInput.js +++ b/themes/NEXT/components/SearchInput.js @@ -1,8 +1,6 @@ import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' import { useImperativeHandle, useRef, useState } from 'react' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faSearch, faSpinner, faTimes } from '@fortawesome/free-solid-svg-icons' const SearchInput = ({ currentTag, currentSearch, cRef }) => { const { locale } = useGlobal() @@ -54,11 +52,11 @@ const SearchInput = ({ currentTag, currentSearch, cRef }) => { onChange={e => updateSearchKey(e.target.value)} defaultValue={searchKey} /> - {(searchKey && searchKey.length && )} + {(searchKey && searchKey.length && )}
{ handleSearch(searchKey) }}> - +
} diff --git a/themes/NEXT/components/ShareBar.js b/themes/NEXT/components/ShareBar.js index 57190d3c..cfbf13b1 100644 --- a/themes/NEXT/components/ShareBar.js +++ b/themes/NEXT/components/ShareBar.js @@ -5,16 +5,6 @@ import { createPopper } from '@popperjs/core' import copy from 'copy-to-clipboard' import QRCode from 'qrcode.react' import { useGlobal } from '@/lib/global' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { - faFacebookSquare, - faQq, - faTelegram, - faTwitterSquare, - faWeibo, - faWeixin -} from '@fortawesome/free-brands-svg-icons' -import { faLink } from '@fortawesome/free-solid-svg-icons' import CONFIG_NEXT from '../config_next' const ShareBar = ({ post }) => { @@ -51,22 +41,22 @@ const ShareBar = ({ post }) => {
{locale.COMMON.SHARE}:
- + diff --git a/themes/NEXT/components/SideAreaLeft.js b/themes/NEXT/components/SideAreaLeft.js index ad32fb82..193d58ae 100644 --- a/themes/NEXT/components/SideAreaLeft.js +++ b/themes/NEXT/components/SideAreaLeft.js @@ -18,7 +18,8 @@ import CONFIG_NEXT from '../config_next' * @returns {JSX.Element} * @constructor */ -const SideAreaLeft = ({ currentTag, post, postCount, currentSearch }) => { +const SideAreaLeft = (props) => { + const { currentTag, post, postCount, currentSearch } = props const { locale } = useGlobal() const showToc = post && post.toc && post.toc.length > 1 return
diff --git a/themes/NEXT/components/WordCount.js b/themes/NEXT/components/WordCount.js index 1f814a24..dfcdf91f 100644 --- a/themes/NEXT/components/WordCount.js +++ b/themes/NEXT/components/WordCount.js @@ -1,5 +1,3 @@ -import { faClock, faFileWord } from '@fortawesome/free-solid-svg-icons' -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useEffect } from 'react' /** @@ -12,7 +10,7 @@ export default function WordCount () { }) return
- 本文字数 0  |  阅读时长 ≈ 0 分钟 + 本文字数 0  |  阅读时长 ≈ 0 分钟
}