From 9b78eb499c70fc2dd4a287a088994e1d14bf77fe Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 8 May 2024 16:22:14 +0800 Subject: [PATCH] =?UTF-8?q?slug=20=E8=B0=83=E6=95=B4=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=B7=B2=E6=9C=89=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/db/getSiteData.js | 1 + themes/gitbook/components/ArticleAround.js | 12 +- themes/gitbook/components/BlogArchiveItem.js | 53 +- themes/gitbook/components/BlogPostCard.js | 3 +- .../components/MenuItemMobileNormal.js | 2 +- themes/gitbook/index.js | 1 + themes/heo/components/MenuGroupCard.js | 10 +- themes/heo/components/MenuItemCollapse.js | 4 +- themes/heo/components/MenuItemDrop.js | 4 +- themes/heo/components/MenuListSide.js | 42 +- themes/heo/components/MenuListTop.js | 45 +- themes/hexo/components/MenuGroupCard.js | 12 +- themes/hexo/components/MenuItemCollapse.js | 4 +- themes/hexo/components/MenuItemDrop.js | 4 +- themes/hexo/components/MenuListSide.js | 8 +- themes/hexo/components/MenuListTop.js | 49 +- themes/matery/components/MenuGroupCard.js | 12 +- themes/matery/components/MenuItemCollapse.js | 6 +- themes/matery/components/MenuItemDrop.js | 4 +- themes/matery/components/MenuItemNormal.js | 32 +- themes/matery/components/MenuList.js | 65 ++- themes/matery/components/MenuListSide.js | 40 +- themes/matery/components/MenuListTop.js | 8 +- themes/medium/components/MenuBarMobile.js | 35 +- themes/medium/components/MenuItemCollapse.js | 6 +- themes/medium/components/MenuItemDrop.js | 6 +- .../medium/components/MenuItemMobileNormal.js | 30 +- themes/medium/components/MenuItemPCNormal.js | 30 +- themes/medium/components/TopNavBar.js | 108 ++-- themes/movie/components/Header.js | 41 +- themes/movie/components/MenuItemCollapse.js | 4 +- themes/movie/components/MenuItemDrop.js | 4 +- themes/movie/components/NormalMenuItem.js | 14 +- themes/nav/components/ArticleAround.js | 12 +- themes/nav/components/MenuBarMobile.js | 34 +- themes/nav/components/MenuItem.js | 97 ++-- themes/nav/components/MenuItemCollapse.js | 6 +- themes/nav/components/MenuItemDrop.js | 6 +- themes/nav/components/MenuItemMobileNormal.js | 30 +- themes/nav/components/MenuItemPCNormal.js | 30 +- themes/nav/components/SearchInput.js | 73 +-- themes/nav/index.js | 476 ++++++++++-------- themes/next/components/MenuItemCollapse.js | 4 +- themes/next/components/MenuItemDrop.js | 4 +- themes/next/components/MenuList.js | 92 +++- themes/next/components/SideAreaLeft.js | 121 +++-- .../nobelium/components/MenuItemCollapse.js | 4 +- themes/nobelium/components/MenuItemDrop.js | 4 +- themes/nobelium/components/Nav.js | 10 +- themes/plog/components/BottomNav.js | 88 +++- themes/plog/components/MenuItemCollapse.js | 4 +- themes/plog/components/MenuItemDrop.js | 4 +- themes/plog/components/Modal.js | 85 ++-- themes/plog/components/Nav.js | 147 ++++-- themes/starter/components/MenuItem.js | 4 +- themes/starter/components/MenuList.js | 110 ++-- 56 files changed, 1318 insertions(+), 826 deletions(-) diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index 6834a61d..37bd6d45 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -295,6 +295,7 @@ export function getNavPages({ allPages }) { tags: item.tags || null, summary: item.summary || null, slug: item.slug, + href: item.href, pageIcon: item.pageIcon || '', lastEditedDate: item.lastEditedDate, publishDate: item.publishDate, diff --git a/themes/gitbook/components/ArticleAround.js b/themes/gitbook/components/ArticleAround.js index 95b6f83f..58069682 100644 --- a/themes/gitbook/components/ArticleAround.js +++ b/themes/gitbook/components/ArticleAround.js @@ -5,27 +5,25 @@ import Link from 'next/link' * @param {prev,next} param0 * @returns */ -export default function ArticleAround ({ prev, next }) { +export default function ArticleAround({ prev, next }) { if (!prev || !next) { return <> } return (
- - {prev.title} - + + {prev.title} {next.title} -
) diff --git a/themes/gitbook/components/BlogArchiveItem.js b/themes/gitbook/components/BlogArchiveItem.js index ad9ac831..7d7b5a1c 100644 --- a/themes/gitbook/components/BlogArchiveItem.js +++ b/themes/gitbook/components/BlogArchiveItem.js @@ -1,6 +1,4 @@ -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 归档分组 @@ -9,31 +7,30 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' */ export default function BlogArchiveItem({ archiveTitle, archivePosts }) { return ( -
-
- {archiveTitle} -
-
    - {archivePosts[archiveTitle]?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return
  • -
    - - {post.date?.start_date} - {' '} -   - - - {post.title} - -
    -
  • - })} -
-
+
+
+ {archiveTitle} +
+
    + {archivePosts[archiveTitle]?.map(post => { + return ( +
  • +
    + {post.date?.start_date}{' '} +   + + {post.title} + +
    +
  • + ) + })} +
+
) } diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js index 7d288a57..3528512a 100644 --- a/themes/gitbook/components/BlogPostCard.js +++ b/themes/gitbook/components/BlogPostCard.js @@ -7,8 +7,7 @@ import CONFIG from '../config' const BlogPostCard = ({ post, className }) => { const router = useRouter() - const currentSelected = router.asPath.split('?')[0] === '/' + post.slug - + const currentSelected = router.asPath.split('?')[0] === post?.href return (
{ return ( { const links = [ { name: locale.COMMON.ARTICLE, - to: '/archive', + href: '/archive', slot: archiveSlot, show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) }, { name: locale.COMMON.CATEGORY, - to: '/category', + href: '/category', slot: categorySlot, show: siteConfig('HEO_MENU_CATEGORY', null, CONFIG) }, { name: locale.COMMON.TAGS, - to: '/tag', + href: '/tag', slot: tagSlot, show: siteConfig('HEO_MENU_TAG', null, CONFIG) } @@ -40,8 +40,8 @@ const MenuGroupCard = props => { return (
{ onClick={toggleShow}> {!hasSubMenu && ( @@ -63,7 +63,7 @@ export const MenuItemCollapse = ({ link }) => {
- + {link?.icon && }{' '} {sLink.title} diff --git a/themes/heo/components/MenuItemDrop.js b/themes/heo/components/MenuItemDrop.js index 076c22a2..2e6929a7 100644 --- a/themes/heo/components/MenuItemDrop.js +++ b/themes/heo/components/MenuItemDrop.js @@ -17,7 +17,7 @@ export const MenuItemDrop = ({ link }) => { {!hasSubMenu && ( {link?.icon && } {link?.name} @@ -42,7 +42,7 @@ export const MenuItemDrop = ({ link }) => {
  • - + {link?.icon &&   } {sLink.title} diff --git a/themes/heo/components/MenuListSide.js b/themes/heo/components/MenuListSide.js index fa6d42a1..5716d5b8 100644 --- a/themes/heo/components/MenuListSide.js +++ b/themes/heo/components/MenuListSide.js @@ -1,17 +1,37 @@ -import { useGlobal } from '@/lib/global' import { siteConfig } from '@/lib/config' -import { MenuItemCollapse } from './MenuItemCollapse' +import { useGlobal } from '@/lib/global' import CONFIG from '../config' +import { MenuItemCollapse } from './MenuItemCollapse' -export const MenuListSide = (props) => { +export const MenuListSide = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('HEO_MENU_SEARCH', null, CONFIG) }, - { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('HEO_MENU_CATEGORY', null, CONFIG) }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('HEO_MENU_TAG', null, CONFIG) } + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: siteConfig('HEO_MENU_SEARCH', null, CONFIG) + }, + { + icon: 'fas fa-folder', + name: locale.COMMON.CATEGORY, + href: '/category', + show: siteConfig('HEO_MENU_CATEGORY', null, CONFIG) + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + href: '/tag', + show: siteConfig('HEO_MENU_TAG', null, CONFIG) + } ] if (customNav) { @@ -28,8 +48,10 @@ export const MenuListSide = (props) => { } return ( - + ) } diff --git a/themes/heo/components/MenuListTop.js b/themes/heo/components/MenuListTop.js index 74d116a5..b8e36dee 100644 --- a/themes/heo/components/MenuListTop.js +++ b/themes/heo/components/MenuListTop.js @@ -1,16 +1,34 @@ +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import CONFIG from '../config' -import { siteConfig } from '@/lib/config' import { MenuItemDrop } from './MenuItemDrop' -export const MenuListTop = (props) => { +export const MenuListTop = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { id: 1, icon: 'fa-solid fa-house', name: locale.NAV.INDEX, to: '/', show: siteConfig('HEO_MENU_INDEX', null, CONFIG) }, - { id: 2, icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('HEO_MENU_SEARCH', null, CONFIG) }, - { id: 3, icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) } + { + id: 1, + icon: 'fa-solid fa-house', + name: locale.NAV.INDEX, + href: '/', + show: siteConfig('HEO_MENU_INDEX', null, CONFIG) + }, + { + id: 2, + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: siteConfig('HEO_MENU_SEARCH', null, CONFIG) + }, + { + id: 3, + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: siteConfig('HEO_MENU_ARCHIVE', null, CONFIG) + } ] if (customNav) { @@ -26,9 +44,16 @@ export const MenuListTop = (props) => { return null } - return (<> - - ) + return ( + <> + + + ) } diff --git a/themes/hexo/components/MenuGroupCard.js b/themes/hexo/components/MenuGroupCard.js index 3753d31b..de0368e2 100644 --- a/themes/hexo/components/MenuGroupCard.js +++ b/themes/hexo/components/MenuGroupCard.js @@ -15,19 +15,19 @@ const MenuGroupCard = props => { const links = [ { name: locale.COMMON.ARTICLE, - to: '/archive', + href: '/archive', slot: archiveSlot, show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) }, { name: locale.COMMON.CATEGORY, - to: '/category', + href: '/category', slot: categorySlot, show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) }, { name: locale.COMMON.TAGS, - to: '/tag', + href: '/tag', slot: tagSlot, show: siteConfig('HEXO_MENU_TAG', null, CONFIG) } @@ -47,9 +47,9 @@ const MenuGroupCard = props => { if (link.show) { return ( { onClick={toggleShow}> {!hasSubMenu && ( @@ -64,7 +64,7 @@ export const MenuItemCollapse = props => {
    - + {link?.icon && }{' '} {sLink.title} diff --git a/themes/hexo/components/MenuItemDrop.js b/themes/hexo/components/MenuItemDrop.js index 18ea74b6..7e1896d7 100644 --- a/themes/hexo/components/MenuItemDrop.js +++ b/themes/hexo/components/MenuItemDrop.js @@ -19,7 +19,7 @@ export const MenuItemDrop = ({ link }) => { onMouseOut={() => changeShow(false)}> {!hasSubMenu && ( {link?.icon && } {link?.name} @@ -47,7 +47,7 @@ export const MenuItemDrop = ({ link }) => {
  • - + {link?.icon &&   } {sLink.title} diff --git a/themes/hexo/components/MenuListSide.js b/themes/hexo/components/MenuListSide.js index ab0b4278..7d967d06 100644 --- a/themes/hexo/components/MenuListSide.js +++ b/themes/hexo/components/MenuListSide.js @@ -15,25 +15,25 @@ export const MenuListSide = props => { { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, - to: '/archive', + href: '/archive', show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) }, { icon: 'fas fa-search', name: locale.NAV.SEARCH, - to: '/search', + href: '/search', show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) }, { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, - to: '/category', + href: '/category', show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) }, { icon: 'fas fa-tag', name: locale.COMMON.TAGS, - to: '/tag', + href: '/tag', show: siteConfig('HEXO_MENU_TAG', null, CONFIG) } ] diff --git a/themes/hexo/components/MenuListTop.js b/themes/hexo/components/MenuListTop.js index f5d2c9cd..e52f097f 100644 --- a/themes/hexo/components/MenuListTop.js +++ b/themes/hexo/components/MenuListTop.js @@ -1,18 +1,36 @@ +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import CONFIG from '../config' -import { siteConfig } from '@/lib/config' import { MenuItemDrop } from './MenuItemDrop' -export const MenuListTop = (props) => { +export const MenuListTop = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { id: 1, icon: 'fa-solid fa-house', name: locale.NAV.INDEX, to: '/', show: siteConfig('HEXO_MENU_INDEX', null, CONFIG) }, - { id: 2, icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) }, - { id: 3, icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) } - // { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('MENU_CATEGORY', null, CONFIG) }, - // { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('MENU_TAG', null, CONFIG) } + { + id: 1, + icon: 'fa-solid fa-house', + name: locale.NAV.INDEX, + href: '/', + show: siteConfig('HEXO_MENU_INDEX', null, CONFIG) + }, + { + id: 2, + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) + }, + { + id: 3, + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) + } + // { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, href: '/category', show: siteConfig('MENU_CATEGORY', null, CONFIG) }, + // { icon: 'fas fa-tag', name: locale.COMMON.TAGS, href: '/tag', show: siteConfig('MENU_TAG', null, CONFIG) } ] if (customNav) { @@ -34,9 +52,16 @@ export const MenuListTop = (props) => { return null } - return (<> - - ) + return ( + <> + + + ) } diff --git a/themes/matery/components/MenuGroupCard.js b/themes/matery/components/MenuGroupCard.js index 8c6c43a2..4aafb5d9 100644 --- a/themes/matery/components/MenuGroupCard.js +++ b/themes/matery/components/MenuGroupCard.js @@ -13,19 +13,19 @@ const MenuGroupCard = props => { const links = [ { name: locale.COMMON.ARTICLE, - to: '/archive', + href: '/archive', slot: archiveSlot, show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) }, { name: locale.COMMON.CATEGORY, - to: '/category', + href: '/category', slot: categorySlot, show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) }, { name: locale.COMMON.TAGS, - to: '/tag', + href: '/tag', slot: tagSlot, show: siteConfig('MATERY_MENU_TAG', null, CONFIG) } @@ -37,9 +37,9 @@ const MenuGroupCard = props => { if (link.show) { return ( { return null } - const selected = router.pathname === link.to || router.asPath === link.to + const selected = router.pathname === link.href || router.asPath === link.href return ( <> @@ -40,7 +40,7 @@ export const MenuItemCollapse = ({ link }) => { : ' text-black dark:text-white ') }> {!hasSubMenu && ( - +
    {link.icon && ( @@ -73,7 +73,7 @@ export const MenuItemCollapse = ({ link }) => {
    - + {sLink.title} diff --git a/themes/matery/components/MenuItemDrop.js b/themes/matery/components/MenuItemDrop.js index 93dfe7c6..378b3b14 100644 --- a/themes/matery/components/MenuItemDrop.js +++ b/themes/matery/components/MenuItemDrop.js @@ -18,7 +18,7 @@ export const MenuItemDrop = ({ link }) => { onMouseOut={() => changeShow(false)}> {!hasSubMenu && ( {link?.icon && } {link?.name} @@ -46,7 +46,7 @@ export const MenuItemDrop = ({ link }) => {
  • - + {link?.icon &&   } {sLink.title} diff --git a/themes/matery/components/MenuItemNormal.js b/themes/matery/components/MenuItemNormal.js index b54324ac..0254089b 100644 --- a/themes/matery/components/MenuItemNormal.js +++ b/themes/matery/components/MenuItemNormal.js @@ -5,20 +5,24 @@ export const MenuItemNormal = props => { const router = useRouter() const { link } = props - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.href || router.asPath === link.href - return - -
    + return ( + +
    -
    {link.name}
    -
    - {link.slot} - - +
    {link.name}
    +
    + {link.slot} + + ) } diff --git a/themes/matery/components/MenuList.js b/themes/matery/components/MenuList.js index fb16873f..ecd306c1 100644 --- a/themes/matery/components/MenuList.js +++ b/themes/matery/components/MenuList.js @@ -1,21 +1,51 @@ +import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' -import { useGlobal } from '@/lib/global' import CONFIG from '../config' -import { siteConfig } from '@/lib/config' -const MenuList = (props) => { +const MenuList = props => { const { postCount, customNav } = props const { locale } = useGlobal() const router = useRouter() - const archiveSlot =
    {postCount}
    + const archiveSlot = ( +
    + {postCount} +
    + ) let links = [ - { icon: 'fas fa-home', name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('MATERY_MENU_TAG', null, CONFIG) }, - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('MATERY_MENU_SEARCH', null, CONFIG) } + { + icon: 'fas fa-home', + name: locale.NAV.INDEX, + href: '/' || '/', + show: true + }, + { + icon: 'fas fa-th', + name: locale.COMMON.CATEGORY, + href: '/category', + show: siteConfig('MATERY_MENU_CATEGORY', null, CONFIG) + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + href: '/tag', + show: siteConfig('MATERY_MENU_TAG', null, CONFIG) + }, + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + href: '/archive', + slot: archiveSlot, + show: siteConfig('MATERY_MENU_ARCHIVE', null, CONFIG) + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + href: '/search', + show: siteConfig('MATERY_MENU_SEARCH', null, CONFIG) + } ] if (customNav) { links = links.concat(customNav) @@ -25,21 +55,22 @@ const MenuList = (props) => {