diff --git a/themes/example/components/BlogItem.js b/themes/example/components/BlogItem.js index f1e54ffe..90a40f3a 100644 --- a/themes/example/components/BlogItem.js +++ b/themes/example/components/BlogItem.js @@ -2,7 +2,6 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' import TwikooCommentCount from '@/components/TwikooCommentCount' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import CONFIG from '../config' @@ -15,9 +14,6 @@ const BlogItem = ({ post }) => { const showPageCover = siteConfig('EXAMPLE_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` return (
{

{siteConfig('POST_TITLE_ICON') && ( @@ -72,7 +68,7 @@ const BlogItem = ({ post }) => { {/* 图片封面 */} {showPageCover && (
- + {archivePosts[archiveTitle].map(post => { - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return (
  • {post?.publishDay}   {post.title} diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js index 6e31efac..7419dede 100644 --- a/themes/fukasawa/components/BlogCard.js +++ b/themes/fukasawa/components/BlogCard.js @@ -1,7 +1,6 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import CONFIG from '../config' import TagItemMini from './TagItemMini' @@ -41,10 +40,6 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => { } : {} - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return (
    {
    {/* 封面图 */} {showPageCover && ( - +
    {

    - {siteConfig('POST_TITLE_ICON') && } {post.title} + {siteConfig('POST_TITLE_ICON') && ( + + )}{' '} + {post.title}

    diff --git a/themes/fukasawa/components/BlogPostArchive.js b/themes/fukasawa/components/BlogPostArchive.js index 300098d4..bcdafccf 100644 --- a/themes/fukasawa/components/BlogPostArchive.js +++ b/themes/fukasawa/components/BlogPostArchive.js @@ -1,6 +1,4 @@ import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 博客归档 @@ -16,31 +14,28 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => { return (
    + className='pt-16 pb-4 text-3xl dark:text-gray-300' + id={archiveTitle}> {archiveTitle}
      {posts?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return
    • -
      - {post.date?.start_date}{' '} -   - - - {post.title} - - -
      -
    • + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) })}
    diff --git a/themes/game/components/BlogArchiveItem.js b/themes/game/components/BlogArchiveItem.js index ac1c2522..4a92959e 100644 --- a/themes/game/components/BlogArchiveItem.js +++ b/themes/game/components/BlogArchiveItem.js @@ -1,6 +1,4 @@ -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 归档分组文章 @@ -9,36 +7,31 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' */ export default function BlogArchiveItem({ archiveTitle, archivePosts }) { return ( -
    -
    - {archiveTitle} -
    +
    +
    + {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} - - -
      -
    • - })} -
    -
    +
      + {archivePosts[archiveTitle].map(post => { + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) + })} +
    +
    ) } diff --git a/themes/game/components/BlogPost.js b/themes/game/components/BlogPost.js index fbe52fdf..0131dc62 100644 --- a/themes/game/components/BlogPost.js +++ b/themes/game/components/BlogPost.js @@ -1,40 +1,40 @@ -import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import NotionIcon from '@/components/NotionIcon' import NotionPage from '@/components/NotionPage' +import { siteConfig } from '@/lib/config' +import Link from 'next/link' const BlogPost = ({ post }) => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - const showPreview = siteConfig('POST_LIST_PREVIEW') && post.blockMap return ( - ( - -
    -
    -

    - {siteConfig('POST_TITLE_ICON') && }{post.title} + +
    +
    +

    + {siteConfig('POST_TITLE_ICON') && ( + + )} + {post.title}

    -
    - {!showPreview &&

    - {post.summary} -

    } + {!showPreview && ( +

    + {post.summary} +

    + )} {showPreview && post?.blockMap && ( -
    +
    -
    +
    )}
    - - ) + ) } diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js index 8ce99f09..7d288a57 100644 --- a/themes/gitbook/components/BlogPostCard.js +++ b/themes/gitbook/components/BlogPostCard.js @@ -1,7 +1,6 @@ import Badge from '@/components/Badge' import NotionIcon from '@/components/NotionIcon' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import { useRouter } from 'next/router' import CONFIG from '../config' @@ -9,11 +8,9 @@ import CONFIG from '../config' const BlogPostCard = ({ post, className }) => { const router = useRouter() const currentSelected = router.asPath.split('?')[0] === '/' + post.slug - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` + return ( - +
    { +export const MenuBarMobile = props => { const { customMenu, customNav } = props const { locale } = useGlobal() let links = [ - // { name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('GITBOOK_MENU_CATEGORY', null, CONFIG) }, - { name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('GITBOOK_BOOK_MENU_TAG', null, CONFIG) }, - { name: locale.NAV.ARCHIVE, to: '/archive', show: siteConfig('GITBOOK_MENU_ARCHIVE', null, CONFIG) } - // { name: locale.NAV.SEARCH, to: '/search', show: siteConfig('MENU_SEARCH', null, CONFIG) } + // { name: locale.NAV.INDEX, href: '/' || '/', show: true }, + { + name: locale.COMMON.CATEGORY, + href: '/category', + show: siteConfig('GITBOOK_MENU_CATEGORY', null, CONFIG) + }, + { + name: locale.COMMON.TAGS, + href: '/tag', + show: siteConfig('GITBOOK_BOOK_MENU_TAG', null, CONFIG) + }, + { + name: locale.NAV.ARCHIVE, + href: '/archive', + show: siteConfig('GITBOOK_MENU_ARCHIVE', null, CONFIG) + } + // { name: locale.NAV.SEARCH, href: '/search', show: siteConfig('MENU_SEARCH', null, CONFIG) } ] if (customNav) { @@ -30,7 +42,13 @@ export const MenuBarMobile = (props) => { return ( ) } diff --git a/themes/gitbook/components/MenuItemCollapse.js b/themes/gitbook/components/MenuItemCollapse.js index 87453498..96186533 100644 --- a/themes/gitbook/components/MenuItemCollapse.js +++ b/themes/gitbook/components/MenuItemCollapse.js @@ -21,7 +21,7 @@ export const MenuItemCollapse = props => { return null } - const selected = router.pathname === link.to || router.asPath === link.to + const selected = router.pathname === link.href || router.asPath === link.href const toggleShow = () => { changeShow(!show) @@ -43,7 +43,7 @@ export const MenuItemCollapse = props => { onClick={toggleShow}> {!hasSubMenu && (
    @@ -79,7 +79,7 @@ export const MenuItemCollapse = props => { className=' not:last-child:border-b-0 border-b dark:border-gray-800 py-2 px-14 cursor-pointer hover:bg-gray-100 dark:text-gray-200 font-extralight dark:bg-black text-left justify-start text-gray-600 bg-gray-50 dark:hover:bg-gray-900 tracking-widest transition-all duration-200'> - +
    { return null } const hasSubMenu = link?.subMenus?.length > 0 - const selected = router.pathname === link.to || router.asPath === link.to + const selected = router.pathname === link.href || router.asPath === link.href return (
  • { ? 'bg-green-600 text-white hover:text-white' : 'hover:text-green-600') }> - + {link?.icon && } {link?.name}
  • @@ -57,7 +57,7 @@ export const MenuItemDrop = ({ link }) => {
  • - + {link?.icon &&   } {sLink.title} diff --git a/themes/gitbook/components/MenuItemMobileNormal.js b/themes/gitbook/components/MenuItemMobileNormal.js index 17f0d151..e7221365 100644 --- a/themes/gitbook/components/MenuItemMobileNormal.js +++ b/themes/gitbook/components/MenuItemMobileNormal.js @@ -9,19 +9,21 @@ export const NormalMenu = props => { return null } - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.href || router.asPath === link.href - return - -
    -
    {link.name}
    -
    - {link.slot} - - + return ( + +
    +
    {link.name}
    +
    + {link.slot} + + ) } diff --git a/themes/gitbook/components/MenuItemPCNormal.js b/themes/gitbook/components/MenuItemPCNormal.js index 809ae974..bf3a22c7 100644 --- a/themes/gitbook/components/MenuItemPCNormal.js +++ b/themes/gitbook/components/MenuItemPCNormal.js @@ -4,21 +4,27 @@ import { useRouter } from 'next/router' export const MenuItemPCNormal = props => { const { link } = props const router = useRouter() - const selected = (router.pathname === link.to) || (router.asPath === link.to) + const selected = router.pathname === link.href || router.asPath === link.href if (!link || !link.show) { return null } - return -
    - -
    {link.name}
    -
    - {link.slot} + return ( + +
    + +
    {link.name}
    +
    + {link.slot} + ) } diff --git a/themes/heo/components/ArticleRecommend.js b/themes/heo/components/ArticleRecommend.js index 9ffcadbb..02874675 100644 --- a/themes/heo/components/ArticleRecommend.js +++ b/themes/heo/components/ArticleRecommend.js @@ -1,9 +1,8 @@ -import Link from 'next/link' -import CONFIG from '../config' -import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' +import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import CONFIG from '../config' /** * 关联推荐文章 @@ -15,53 +14,52 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) { if ( !siteConfig('HEO_ARTICLE_RECOMMEND', null, CONFIG) || - !recommendPosts || - recommendPosts.length === 0 + !recommendPosts || + recommendPosts.length === 0 ) { return <> } return ( -
    - - {/* 推荐文章 */} -
    -
    - - {locale.COMMON.RELATE_POSTS} -
    -
    - - {/* 文章列表 */} - -
    - {recommendPosts.map(post => { - const headerImage = post?.pageCoverThumbnail - ? post.pageCoverThumbnail - : siteInfo?.pageCover - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return ( - ( - -
    -
    -
    - {post.title} -
    -
    - -
    - - ) - ) - })} -
    +
    + {/* 推荐文章 */} +
    +
    + + {locale.COMMON.RELATE_POSTS}
    +
    + + {/* 文章列表 */} + +
    + {recommendPosts.map(post => { + const headerImage = post?.pageCoverThumbnail + ? post?.pageCoverThumbnail + : siteInfo?.pageCover + + return ( + +
    +
    +
    + {post.title} +
    +
    + +
    + + ) + })} +
    +
    ) } diff --git a/themes/heo/components/BlogPostArchive.js b/themes/heo/components/BlogPostArchive.js index eda2f777..1ba8b2da 100644 --- a/themes/heo/components/BlogPostArchive.js +++ b/themes/heo/components/BlogPostArchive.js @@ -1,9 +1,8 @@ +import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' import Link from 'next/link' import CONFIG from '../config' import TagItemMini from './TagItemMini' -import LazyImage from '@/components/LazyImage' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 博客归档列表 @@ -17,72 +16,89 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => { return <> } else { return ( -
    -
    - {archiveTitle} -
    -
      - {posts?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` +
      +
      + {archiveTitle} +
      +
        + {posts?.map(post => { + const showPreview = + siteConfig('HEO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + if ( + post && + !post.pageCoverThumbnail && + siteConfig('HEO_POST_LIST_COVER_DEFAULT', null, CONFIG) + ) { + post.pageCoverThumbnail = siteInfo?.pageCover + } + const showPageCover = + siteConfig('HEO_POST_LIST_COVER', null, CONFIG) && + post?.pageCoverThumbnail && + !showPreview + return ( +
        + {/* 图片封面 */} + {showPageCover && ( +
        + + + +
        + )} - const showPreview = siteConfig('HEO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap - if (post && !post.pageCoverThumbnail && siteConfig('HEO_POST_LIST_COVER_DEFAULT', null, CONFIG)) { - post.pageCoverThumbnail = siteInfo?.pageCover - } - const showPageCover = siteConfig('HEO_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && !showPreview - return
        + {/* 文字区块 */} +
        +
        + {/* 分类 */} + {post?.category && ( + + )} - {/* 图片封面 */} - {showPageCover && ( -
        - - - -
        - )} + {/* 标题 */} + + {post.title} + +
        - {/* 文字区块 */} -
        -
        - {/* 分类 */} - {post?.category && } - - {/* 标题 */} - - {post.title} - -
        - - {/* 摘要 */} - {/*

        + {/* 摘要 */} + {/*

        {post.summary}

        */} -
        -
        - {' '} - {post.tagItems?.map(tag => ( - - ))} -
        -
        - -
        -
        - })} -
      -
      +
      +
      + {' '} + {post.tagItems?.map(tag => ( + + ))} +
      +
      +
    +
    + ) + })} + +
  • ) } } diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js index 4d32f231..3a1cf689 100644 --- a/themes/heo/components/BlogPostCard.js +++ b/themes/heo/components/BlogPostCard.js @@ -1,74 +1,97 @@ +import LazyImage from '@/components/LazyImage' +import NotionIcon from '@/components/NotionIcon' +import { siteConfig } from '@/lib/config' import Link from 'next/link' import CONFIG from '../config' import TagItemMini from './TagItemMini' -import LazyImage from '@/components/LazyImage' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' -import NotionIcon from '@/components/NotionIcon' const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { - const showPreview = siteConfig('HEO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap - if (post && !post.pageCoverThumbnail && siteConfig('HEO_POST_LIST_COVER_DEFAULT', null, CONFIG)) { + const showPreview = + siteConfig('HEO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + if ( + post && + !post.pageCoverThumbnail && + siteConfig('HEO_POST_LIST_COVER_DEFAULT', null, CONFIG) + ) { post.pageCoverThumbnail = siteInfo?.pageCover } - const showPageCover = siteConfig('HEO_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && !showPreview - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` + const showPageCover = + siteConfig('HEO_POST_LIST_COVER', null, CONFIG) && + post?.pageCoverThumbnail && + !showPreview return ( -
    - -
    - - {/* 图片封面 */} - {showPageCover && ( - -
    - -
    - - )} - - {/* 文字区块 */} -
    -
    - {/* 分类 */} - {post?.category && } - - {/* 标题 */} - - {siteConfig('POST_TITLE_ICON') && }{post.title} - -
    - - {/* 摘要 */} - {(!showPreview || showSummary) && ( -
    - {post.summary} -
    - )} - -
    -
    - {' '} - {post.tagItems?.map(tag => ( - - ))} -
    -
    - -
    +
    +
    + {/* 图片封面 */} + {showPageCover && ( + +
    +
    + + )} -
    + {/* 文字区块 */} +
    +
    + {/* 分类 */} + {post?.category && ( + + )} + {/* 标题 */} + + {siteConfig('POST_TITLE_ICON') && ( + + )} + {post.title} + +
    + + {/* 摘要 */} + {(!showPreview || showSummary) && ( +
    + {post.summary} +
    + )} + +
    +
    + {' '} + {post.tagItems?.map(tag => ( + + ))} +
    +
    +
    +
    +
    ) } diff --git a/themes/heo/components/LatestPostsGroup.js b/themes/heo/components/LatestPostsGroup.js index 5727e9e0..1eb19022 100644 --- a/themes/heo/components/LatestPostsGroup.js +++ b/themes/heo/components/LatestPostsGroup.js @@ -1,7 +1,5 @@ import LazyImage from '@/components/LazyImage' -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 最新文章列表 @@ -16,36 +14,38 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => { return <> } - return
    - {latestPosts.map(post => { - const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` + return ( +
    + {latestPosts.map(post => { + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover - return ( - ( +
    + +
    - className={'my-3 flex flex-col w-full'}> - -
    - -
    - -
    - -
    {post.title}
    - -
    - - ) - ) - })} +
    +
    {post.title}
    +
    + + ) + })}
    + ) } export default LatestPostsGroup diff --git a/themes/heo/components/LatestPostsGroupMini.js b/themes/heo/components/LatestPostsGroupMini.js index 70a9b761..7bc65df3 100644 --- a/themes/heo/components/LatestPostsGroupMini.js +++ b/themes/heo/components/LatestPostsGroupMini.js @@ -4,7 +4,6 @@ import { useGlobal } from '@/lib/global' // import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 最新文章列表 @@ -12,7 +11,7 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' * @param sliceCount 截取展示的数量 默认6 * @constructor */ -export default function LatestPostsGroupMini ({ latestPosts, siteInfo }) { +export default function LatestPostsGroupMini({ latestPosts, siteInfo }) { // 获取当前路径 const currentPath = useRouter().asPath const { locale } = useGlobal() @@ -21,44 +20,48 @@ export default function LatestPostsGroupMini ({ latestPosts, siteInfo }) { return <> } - return <> -
    -
    - - {locale.COMMON.LATEST_POSTS} -
    + return ( + <> +
    +
    + + {locale.COMMON.LATEST_POSTS}
    - {latestPosts.map(post => { - const selected = currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` - const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` +
    + {latestPosts.map(post => { + const selected = + currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover - return ( - ( - -
    - -
    -
    -
    -
    {post.title}
    -
    {post.lastEditedDay}
    -
    -
    - - ) - ) - })} + return ( + +
    + +
    +
    +
    +
    {post.title}
    +
    {post.lastEditedDay}
    +
    +
    + + ) + })} + ) } diff --git a/themes/hexo/components/ArticleRecommend.js b/themes/hexo/components/ArticleRecommend.js index 0bbcd937..b3f9e73a 100644 --- a/themes/hexo/components/ArticleRecommend.js +++ b/themes/hexo/components/ArticleRecommend.js @@ -1,7 +1,6 @@ import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import CONFIG from '../config' @@ -13,7 +12,11 @@ import CONFIG from '../config' export default function ArticleRecommend({ recommendPosts, siteInfo }) { const { locale } = useGlobal() - if (!siteConfig('HEXO_ARTICLE_RECOMMEND', null, CONFIG) || !recommendPosts || recommendPosts.length === 0) { + if ( + !siteConfig('HEXO_ARTICLE_RECOMMEND', null, CONFIG) || + !recommendPosts || + recommendPosts.length === 0 + ) { return <> } @@ -27,16 +30,15 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
    {recommendPosts.map(post => { - const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover return (
    diff --git a/themes/hexo/components/BlogPostArchive.js b/themes/hexo/components/BlogPostArchive.js index e9bf4f22..e296eaef 100644 --- a/themes/hexo/components/BlogPostArchive.js +++ b/themes/hexo/components/BlogPostArchive.js @@ -1,6 +1,4 @@ import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 博客归档列表 @@ -16,31 +14,28 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => { return (
    + className='pt-16 pb-4 text-3xl dark:text-gray-300' + id={archiveTitle}> {archiveTitle}
      {posts?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return
    • -
      - {post.date?.start_date}{' '} -   - - - {post.title} - - -
      -
    • + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) })}
    diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index af682d02..10a47726 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -1,9 +1,8 @@ +import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' import Link from 'next/link' import CONFIG from '../config' import { BlogPostCardInfo } from './BlogPostCardInfo' -import { siteConfig } from '@/lib/config' -import LazyImage from '@/components/LazyImage' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { const showPreview = siteConfig('HEXO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap @@ -12,7 +11,6 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { } const showPageCover = siteConfig('HEXO_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && !showPreview // const delay = (index % 2) * 200 - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` return ( @@ -33,7 +31,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { {/* 图片封面 */} {showPageCover && (
    - +
    diff --git a/themes/hexo/components/BlogPostCardInfo.js b/themes/hexo/components/BlogPostCardInfo.js index 5ab14856..80f8f0f5 100644 --- a/themes/hexo/components/BlogPostCardInfo.js +++ b/themes/hexo/components/BlogPostCardInfo.js @@ -1,102 +1,110 @@ +import NotionIcon from '@/components/NotionIcon' import NotionPage from '@/components/NotionPage' -import Link from 'next/link' -import TagItemMini from './TagItemMini' import TwikooCommentCount from '@/components/TwikooCommentCount' import { siteConfig } from '@/lib/config' import { formatDateFmt } from '@/lib/utils/formatDate' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' -import NotionIcon from '@/components/NotionIcon' +import Link from 'next/link' +import TagItemMini from './TagItemMini' /** * 博客列表的文字内容 * @param {*} param0 * @returns */ -export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary }) => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return
    -
    -
    -

    - {/* 标题 */} - - - {siteConfig('POST_TITLE_ICON') && }{post.title} - - -

    - - {/* 分类 */} - { post?.category &&
    - - - - {post.category} - - - - -
    } -
    - - {/* 摘要 */} - {(!showPreview || showSummary) && !post.results && ( -
    - {post.summary} -
    - )} - - {/* 搜索结果 */} - {post.results && ( -

    - {post.results.map((r, index) => ( - {r} - ))} -

    - )} - - {/* 预览 */} - {showPreview && ( -
    - -
    - )} - -
    - -
    - {/* 日期标签 */} -
    - {/* 日期 */} +export const BlogPostCardInfo = ({ + post, + showPreview, + showPageCover, + showSummary +}) => { + return ( +
    +
    +
    +

    + {/* 标题 */} - - - {post?.publishDay || post.lastEditedDay} - + href={post?.href} + passHref + className={`line-clamp-2 replace cursor-pointer text-2xl ${ + showPreview ? 'text-center' : '' + } leading-tight font-normal text-gray-600 dark:text-gray-100 hover:text-indigo-700 dark:hover:text-indigo-400`}> + {siteConfig('POST_TITLE_ICON') && ( + + )} + {post.title} +

    -
    -
    - {' '} - {post.tagItems?.map(tag => ( - - ))} -
    + {/* 分类 */} + {post?.category && ( +
    + + + {post.category} + + +
    + )} +
    + + {/* 摘要 */} + {(!showPreview || showSummary) && !post.results && ( +
    + {post.summary} +
    + )} + + {/* 搜索结果 */} + {post.results && ( +

    + {post.results.map((r, index) => ( + {r} + ))} +

    + )} + + {/* 预览 */} + {showPreview && ( +
    + +
    + )} +
    + +
    + {/* 日期标签 */} +
    + {/* 日期 */} + + + {post?.publishDay || post.lastEditedDay} + + +
    +
    + {' '} + {post.tagItems?.map(tag => ( + + ))} +
    +
    -
    +
    + ) } diff --git a/themes/hexo/components/LatestPostsGroup.js b/themes/hexo/components/LatestPostsGroup.js index e8dc4140..6254def8 100644 --- a/themes/hexo/components/LatestPostsGroup.js +++ b/themes/hexo/components/LatestPostsGroup.js @@ -1,10 +1,8 @@ -import { siteConfig } from '@/lib/config' import LazyImage from '@/components/LazyImage' import { useGlobal } from '@/lib/global' // import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 最新文章列表 @@ -21,45 +19,48 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => { return <> } - return <> -
    -
    - - {locale.COMMON.LATEST_POSTS} -
    + return ( + <> +
    +
    + + {locale.COMMON.LATEST_POSTS}
    - {latestPosts.map(post => { - const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - const selected = currentPath === url +
    + {latestPosts.map(post => { + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover + const selected = currentPath === post?.href - return ( - ( - -
    - -
    -
    -
    -
    {post.title}
    -
    {post.lastEditedDay}
    -
    -
    - - ) - ) - })} + return ( + +
    + +
    +
    +
    +
    {post.title}
    +
    {post.lastEditedDay}
    +
    +
    + + ) + })} + ) } export default LatestPostsGroup diff --git a/themes/matery/components/ArticleRecommend.js b/themes/matery/components/ArticleRecommend.js index ec0517d3..58fd7398 100644 --- a/themes/matery/components/ArticleRecommend.js +++ b/themes/matery/components/ArticleRecommend.js @@ -1,9 +1,8 @@ -import Link from 'next/link' -import CONFIG from '../config' +import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' -import LazyImage from '@/components/LazyImage' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' +import Link from 'next/link' +import CONFIG from '../config' /** * 关联推荐文章 @@ -15,54 +14,53 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) { if ( !siteConfig('MATERY_ARTICLE_RECOMMEND', null, CONFIG) || - !recommendPosts || - recommendPosts.length === 0 + !recommendPosts || + recommendPosts.length === 0 ) { return <> } return ( -
    -
    -
    - - {locale.COMMON.RELATE_POSTS} -
    -
    -
    - {recommendPosts.map(post => { - const headerImage = post?.pageCoverThumbnail - ? post.pageCoverThumbnail - : siteInfo?.pageCover - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return ( - ( - -
    - - - -
    -
    -
    - - {post.date?.start_date} -
    -
    {post.title}
    -
    -
    -
    - - ) - ) - })} -
    +
    +
    +
    + + {locale.COMMON.RELATE_POSTS}
    +
    +
    + {recommendPosts.map(post => { + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover + + return ( + +
    + + +
    +
    +
    + + {post.date?.start_date} +
    +
    {post.title}
    +
    +
    +
    + + ) + })} +
    +
    ) } diff --git a/themes/matery/components/BlogPostArchive.js b/themes/matery/components/BlogPostArchive.js index 0cfff1ac..e296eaef 100644 --- a/themes/matery/components/BlogPostArchive.js +++ b/themes/matery/components/BlogPostArchive.js @@ -1,6 +1,4 @@ import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 博客归档列表 @@ -16,30 +14,28 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => { return (
    + className='pt-16 pb-4 text-3xl dark:text-gray-300' + id={archiveTitle}> {archiveTitle}
      {posts?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return
    • -
      - {post.date?.start_date}{' '} -   - - - {post.title} - - -
      -
    • + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) })}
    diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index 656e6ebf..8d10fdf4 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -2,7 +2,6 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' import TwikooCommentCount from '@/components/TwikooCommentCount' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import { formatDateFmt } from '@/lib/utils/formatDate' import Link from 'next/link' import CONFIG from '../config' @@ -24,9 +23,6 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { siteConfig('MATERY_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail const delay = (index % 3) * 300 - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` return (
    {
    {/* 头部图片 填充卡片 */} {showPageCover && ( - +
    -
    - {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/medium/components/BlogPostCard.js b/themes/medium/components/BlogPostCard.js index 5e972e7f..a688f601 100644 --- a/themes/medium/components/BlogPostCard.js +++ b/themes/medium/components/BlogPostCard.js @@ -1,84 +1,91 @@ -import { siteConfig } from '@/lib/config' +import LazyImage from '@/components/LazyImage' +import NotionIcon from '@/components/NotionIcon' import NotionPage from '@/components/NotionPage' +import TwikooCommentCount from '@/components/TwikooCommentCount' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import CONFIG from '../config' import CategoryItem from './CategoryItem' import TagItemMini from './TagItemMini' -import TwikooCommentCount from '@/components/TwikooCommentCount' -import LazyImage from '@/components/LazyImage' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' -import NotionIcon from '@/components/NotionIcon' const BlogPostCard = ({ post, showSummary }) => { - const showPreview = siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + const showPreview = + siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap const { locale } = useGlobal() - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` return ( +
    +
    + +

    + {siteConfig('MEDIUM_POST_LIST_COVER', null, CONFIG) && ( +
    + +
    + )} + {siteConfig('POST_TITLE_ICON') && ( + + )} + {post.title} +

    + +
    - -
    - -

    - {siteConfig('MEDIUM_POST_LIST_COVER', null, CONFIG) &&
    - -
    } - {siteConfig('POST_TITLE_ICON') && }{post.title} -

    - - - -
    -
    {post.date?.start_date}
    - {siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && } - {siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) && post?.tagItems?.map(tag => )} - -
    - -
    - - {(!showPreview || showSummary) && ( -
    - {post.summary} -
    - )} - - {showPreview && ( -
    - -
    -
    - - - {locale.COMMON.ARTICLE_DETAIL} - - - -
    -
    -
    - )} -
    + className={ + 'flex mt-2 items-center justify-start flex-wrap space-x-3 text-gray-400' + }> +
    {post.date?.start_date}
    + {siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && ( + + )} + {siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) && + post?.tagItems?.map(tag => ( + + ))} +
    + +
    + + {(!showPreview || showSummary) && ( +
    + {post.summary} +
    + )} + + {showPreview && ( +
    + +
    +
    + + {locale.COMMON.ARTICLE_DETAIL} + + +
    +
    +
    + )} +
    +
    ) } diff --git a/themes/movie/components/BlogListGroupByDate.js b/themes/movie/components/BlogListGroupByDate.js index 7a8fe083..ebc30aa5 100644 --- a/themes/movie/components/BlogListGroupByDate.js +++ b/themes/movie/components/BlogListGroupByDate.js @@ -1,5 +1,3 @@ -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' /** @@ -9,30 +7,30 @@ import Link from 'next/link' * @returns */ export default function BlogListGroupByDate({ archiveTitle, archivePosts }) { - return
    -
    + return ( +
    +
    {archiveTitle} -
    +
    -
      +
        {archivePosts[archiveTitle].map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return
      • -
        - - {post?.publishDay} - {' '} -   - - {post.title} - -
        + return ( +
      • +
        + {post?.publishDay}   + + {post.title} + +
      • + ) })} -
      -
    + +
    + ) } diff --git a/themes/movie/components/BlogPostCard.js b/themes/movie/components/BlogPostCard.js index 088c66a8..771f31b5 100644 --- a/themes/movie/components/BlogPostCard.js +++ b/themes/movie/components/BlogPostCard.js @@ -1,21 +1,21 @@ import LazyImage from '@/components/LazyImage' import NotionIcon from '@/components/NotionIcon' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import TagItemMini from './TagItemMini' const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { // 主题默认强制显示图片 if (post && !post.pageCoverThumbnail) { - post.pageCoverThumbnail = siteInfo?.pageCover || siteConfig('RANDOM_IMAGE_URL') + post.pageCoverThumbnail = + siteInfo?.pageCover || siteConfig('RANDOM_IMAGE_URL') } - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return ( -
    - +
    + {/* 固定高度 ,空白用图片拉升填充 */}
    {/* 图片 填充卡片 */} @@ -40,7 +40,9 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
    {/* 阴影遮罩 */}

    - {siteConfig('POST_TITLE_ICON') && } + {siteConfig('POST_TITLE_ICON') && ( + + )} {post.title}

    diff --git a/themes/movie/components/BlogRecommend.js b/themes/movie/components/BlogRecommend.js index 9e434558..ef87030e 100644 --- a/themes/movie/components/BlogRecommend.js +++ b/themes/movie/components/BlogRecommend.js @@ -1,7 +1,6 @@ import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' import CONFIG from '../config' @@ -13,7 +12,11 @@ import CONFIG from '../config' export default function BlogRecommend(props) { const { recommendPosts, siteInfo } = props const { locale } = useGlobal() - if (!siteConfig('MOVIE_ARTICLE_RECOMMEND', null, CONFIG) || !recommendPosts || recommendPosts.length === 0) { + if ( + !siteConfig('MOVIE_ARTICLE_RECOMMEND', null, CONFIG) || + !recommendPosts || + recommendPosts.length === 0 + ) { return <> } @@ -27,21 +30,22 @@ export default function BlogRecommend(props) {
    {recommendPosts.map(post => { - const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover return (
    -
    {post.title}
    +
    + {post.title} +
    {/* 卡片的阴影遮罩,为了凸显图片上的文字 */}
    diff --git a/themes/movie/components/LatestPostsGroup.js b/themes/movie/components/LatestPostsGroup.js index b7ada599..40366e37 100644 --- a/themes/movie/components/LatestPostsGroup.js +++ b/themes/movie/components/LatestPostsGroup.js @@ -2,7 +2,6 @@ import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 最新文章列表 @@ -21,9 +20,9 @@ const LatestPostsGroup = ({ latestPosts }) => { return (
    -
    -
    - +
    +
    + {locale.COMMON.LATEST_POSTS}
    @@ -31,17 +30,14 @@ const LatestPostsGroup = ({ latestPosts }) => { {latestPosts.map(post => { const selected = currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` - const url = checkContainHttp(post.slug) - ? sliceUrlFromHttp(post.slug) - : `${siteConfig('SUB_PATH', '')}/${post.slug}` + return ( + className={'my-1 flex'}>
    { : 'text-gray-500 dark:text-green-400 ') + ' py-1 flex hover:bg-gray-500 px-2 duration-200 w-full ' + 'hover:text-white dark:hover:text-white cursor-pointer' - } - > -
  • {post.title}
  • + }> +
  • {post.title}
  • ) diff --git a/themes/nav/components/BlogArchiveItem.js b/themes/nav/components/BlogArchiveItem.js index ad9ac831..7d7b5a1c 100755 --- a/themes/nav/components/BlogArchiveItem.js +++ b/themes/nav/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/nav/components/BlogPostCard.js b/themes/nav/components/BlogPostCard.js index 56ca3c2c..b449c0d2 100755 --- a/themes/nav/components/BlogPostCard.js +++ b/themes/nav/components/BlogPostCard.js @@ -1,26 +1,49 @@ -import Link from 'next/link' -import NotionIcon from './NotionIcon' -import { useRouter } from 'next/router' import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' +import { checkContainHttp } from '@/lib/utils' +import Link from 'next/link' +import { useRouter } from 'next/router' +import NotionIcon from './NotionIcon' +/** + * 博客卡牌 + * @param {*} param0 + * @returns + */ const BlogPostCard = ({ post, className }) => { const router = useRouter() const currentSelected = router.asPath.split('?')[0] === '/' + post.slug - let pageIcon = post.pageIcon !== '' ? post.pageIcon : siteConfig('IMG_LAZY_LOAD_PLACEHOLDER') - pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` + let pageIcon = + post.pageIcon !== '' + ? post.pageIcon + : siteConfig('IMG_LAZY_LOAD_PLACEHOLDER') + pageIcon = + post.pageIcon.indexOf('amazonaws.com') !== -1 + ? post.pageIcon + '&width=88' + : post.pageIcon return ( - -
    -
    - {siteConfig('POST_TITLE_ICON') && } -
    -

    {post.title}

    -

    {post.summary ? post.summary : '暂无简介'}

    -
    -
    + +
    +
    + {siteConfig('POST_TITLE_ICON') && ( + + )} +
    +

    {post.title}

    +

    + {post.summary ? post.summary : '暂无简介'} +

    +
    +
    ) } diff --git a/themes/next/components/BlogPostArchive.js b/themes/next/components/BlogPostArchive.js index 2b09e868..589e67b1 100644 --- a/themes/next/components/BlogPostArchive.js +++ b/themes/next/components/BlogPostArchive.js @@ -1,6 +1,4 @@ -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 博客归档列表 @@ -16,32 +14,28 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => { return (
    + className='pt-16 pb-4 text-3xl dark:text-gray-300' + id={archiveTitle}> {archiveTitle}
      {posts?.map(post => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - - return
    • -
      - {post.date?.start_date}{' '} -   - - - {post.title} - - -
      -
    • + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) })}
    diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js index 5c924820..6189fff7 100644 --- a/themes/next/components/BlogPostCard.js +++ b/themes/next/components/BlogPostCard.js @@ -1,92 +1,95 @@ +import NotionIcon from '@/components/NotionIcon' +import NotionPage from '@/components/NotionPage' +import TwikooCommentCount from '@/components/TwikooCommentCount' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' +import { formatDateFmt } from '@/lib/utils/formatDate' import Image from 'next/image' import Link from 'next/link' +import CONFIG from '../config' import Card from './Card' import TagItemMini from './TagItemMini' -import CONFIG from '../config' -import NotionPage from '@/components/NotionPage' -import NotionIcon from '@/components/NotionIcon' -import TwikooCommentCount from '@/components/TwikooCommentCount' -import { formatDateFmt } from '@/lib/utils/formatDate' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' const BlogPostCard = ({ post, index, showSummary }) => { const { locale } = useGlobal() - const showPreview = siteConfig('NEXT_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + const showPreview = + siteConfig('NEXT_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap // 动画样式 首屏卡片不用,后面翻出来的加动画 - const aosProps = index > 2 - ? { - 'data-aos': 'fade-down', - 'data-aos-duration': '400', - 'data-aos-once': 'true', - 'data-aos-anchor-placement': 'top-bottom' - } - : {} - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` + const aosProps = + index > 2 + ? { + 'data-aos': 'fade-down', + 'data-aos-duration': '400', + 'data-aos-once': 'true', + 'data-aos-anchor-placement': 'top-bottom' + } + : {} return ( - +
    -
    - + className='flex flex-col-reverse justify-between duration-300'> +
    {/* 文章标题 */} - - {siteConfig('POST_TITLE_ICON') && } {post.title} - + {siteConfig('POST_TITLE_ICON') && ( + + )}{' '} + {post.title} -
    - +
    {post.category && ( <> - - + className='hover:text-blue-500 dark:hover:text-blue-400 cursor-pointer font-light text-sm transform'> + {post.category} - - | + | )} - - {post.date?.start_date} - + + {post.date?.start_date} +
    - + -
    - {post.tagItems?.map(tag => ( - - ))} +
    + {post.tagItems?.map(tag => ( + + ))}
    {(!showPreview || showSummary) && !post.results && ( -

    +

    {post.summary}

    )} {/* 搜索结果 */} {post.results && ( -

    +

    {post.results.map((r, index) => ( {r} ))} @@ -94,37 +97,36 @@ const BlogPostCard = ({ post, index, showSummary }) => { )} {showPreview && post?.blockMap && ( -

    +
    )} -
    +
    - + href={post?.href} + className='hover:bg-opacity-100 hover:underline transform duration-300 p-3 text-white bg-gray-800 cursor-pointer'> {locale.COMMON.ARTICLE_DETAIL} - - +
    - {siteConfig('NEXT_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && ( - -
    - {post.title} -
    - - )} + {siteConfig('NEXT_POST_LIST_COVER', null, CONFIG) && + post?.pageCoverThumbnail && ( + +
    + {post.title} +
    + + )}
    ) diff --git a/themes/next/components/LatestPostsGroup.js b/themes/next/components/LatestPostsGroup.js index 4dc60bd5..9e612997 100644 --- a/themes/next/components/LatestPostsGroup.js +++ b/themes/next/components/LatestPostsGroup.js @@ -2,7 +2,6 @@ import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 最新文章列表 @@ -19,39 +18,38 @@ const LatestPostsGroup = ({ latestPosts }) => { return <> } - return <> -
    -
    - - {locale.COMMON.LATEST_POSTS} + return ( + <> +
    +
    + + {locale.COMMON.LATEST_POSTS} +
    -
    - {latestPosts.map(post => { - const selected = currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - return ( - ( - -
    -
  • {post.title}
  • -
    - - ) - ) - })} - + {latestPosts.map(post => { + const selected = + currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` + return ( + +
    +
  • {post.title}
  • +
    + + ) + })} + + ) } export default LatestPostsGroup diff --git a/themes/nobelium/components/BlogArchiveItem.js b/themes/nobelium/components/BlogArchiveItem.js index ac1c2522..4a92959e 100644 --- a/themes/nobelium/components/BlogArchiveItem.js +++ b/themes/nobelium/components/BlogArchiveItem.js @@ -1,6 +1,4 @@ -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 归档分组文章 @@ -9,36 +7,31 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' */ export default function BlogArchiveItem({ archiveTitle, archivePosts }) { return ( -
    -
    - {archiveTitle} -
    +
    +
    + {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} - - -
      -
    • - })} -
    -
    +
      + {archivePosts[archiveTitle].map(post => { + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) + })} +
    +
    ) } diff --git a/themes/nobelium/components/BlogPost.js b/themes/nobelium/components/BlogPost.js index fbe52fdf..0131dc62 100644 --- a/themes/nobelium/components/BlogPost.js +++ b/themes/nobelium/components/BlogPost.js @@ -1,40 +1,40 @@ -import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import NotionIcon from '@/components/NotionIcon' import NotionPage from '@/components/NotionPage' +import { siteConfig } from '@/lib/config' +import Link from 'next/link' const BlogPost = ({ post }) => { - const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}` - const showPreview = siteConfig('POST_LIST_PREVIEW') && post.blockMap return ( - ( - -
    -
    -

    - {siteConfig('POST_TITLE_ICON') && }{post.title} + +
    +
    +

    + {siteConfig('POST_TITLE_ICON') && ( + + )} + {post.title}

    -
    - {!showPreview &&

    - {post.summary} -

    } + {!showPreview && ( +

    + {post.summary} +

    + )} {showPreview && post?.blockMap && ( -
    +
    -
    +
    )}
    - - ) + ) } diff --git a/themes/plog/components/BlogArchiveItem.js b/themes/plog/components/BlogArchiveItem.js index 47127415..4a92959e 100644 --- a/themes/plog/components/BlogArchiveItem.js +++ b/themes/plog/components/BlogArchiveItem.js @@ -1,6 +1,4 @@ import Link from 'next/link' -import { siteConfig } from '@/lib/config' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 归档分组文章 @@ -9,36 +7,31 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' */ export default function BlogArchiveItem({ archiveTitle, archivePosts }) { return ( -
    -
    - {archiveTitle} -
    +
    +
    + {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} - - -
      -
    • - })} -
    -
    +
      + {archivePosts[archiveTitle].map(post => { + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) + })} +
    +
    ) } diff --git a/themes/simple/components/BlogArchiveItem.js b/themes/simple/components/BlogArchiveItem.js index 270dc90c..4a92959e 100644 --- a/themes/simple/components/BlogArchiveItem.js +++ b/themes/simple/components/BlogArchiveItem.js @@ -1,6 +1,4 @@ -import { siteConfig } from '@/lib/config' import Link from 'next/link' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' /** * 归档分组文章 @@ -9,35 +7,31 @@ import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' */ export default function BlogArchiveItem({ archiveTitle, archivePosts }) { return ( -
    -
    - {archiveTitle} -
    +
    +
    + {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} - - -
      -
    • - })} -
    -
    +
      + {archivePosts[archiveTitle].map(post => { + return ( +
    • +
      + {post.date?.start_date}{' '} +   + + {post.title} + +
      +
    • + ) + })} +
    +
    ) }