diff --git a/blog.config.js b/blog.config.js
index f13937be..3aa7b0a8 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -37,6 +37,8 @@ const BLOG = {
BLOG_FAVICON: process.env.NEXT_PUBLIC_FAVICON || '/favicon.ico', // blog favicon 配置, 默认使用 /public/favicon.ico,支持在线图片,如 https://img.imesong.com/favicon.png
+ IMAGE_COMPRESS_WIDTH: process.env.NEXT_PUBLIC_IMAGE_COMPRESS_WIDTH || 800, // 图片压缩宽度默认值,作用于博客封面和文章内容 越小加载图片越快
+ IMAGE_ZOOM_IN_WIDTH: process.env.NEXT_PUBLIC_IMAGE_ZOOM_IN_WIDTH || 1200, // 文章图片点击放大后的画质宽度,不代表在网页中的实际展示宽度
RANDOM_IMAGE_URL: process.env.NEXT_PUBLIC_RANDOM_IMAGE_URL || '', // 随机图片API,如果未配置下面的关键字,主页封面,头像,文章封面图都会被替换为随机图片
RANDOM_IMAGE_REPLACE_TEXT: process.env.NEXT_PUBLIC_RANDOM_IMAGE_NOT_REPLACE_TEXT || 'images.unsplash.com', // 触发替换图片的 url 关键字(多个支持用英文逗号分开),只有图片地址中包含此关键字才会替换为上方随机图片url
// eg: images.unsplash.com(notion图床的所有图片都会替换),如果你在 notion 里已经添加了一个随机图片 url,恰巧那个服务跑路或者挂掉,想一键切换所有配图可以将该 url 配置在这里
diff --git a/components/NotionPage.js b/components/NotionPage.js
index fb68691a..58153fbd 100644
--- a/components/NotionPage.js
+++ b/components/NotionPage.js
@@ -2,7 +2,7 @@ import dynamic from 'next/dynamic'
import mediumZoom from '@fisch0920/medium-zoom'
import { useEffect, useRef } from 'react'
import 'katex/dist/katex.min.css'
-import { mapImgUrl } from '@/lib/notion/mapImage'
+import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
import { isBrowser } from '@/lib/utils'
import { siteConfig } from '@/lib/config'
import { NotionRenderer } from 'react-notion-x'
@@ -61,6 +61,11 @@ const Tweet = ({ id }) => {
return
}
+/**
+ * Notin渲染成网页的核心组件
+ * @param {*} param0
+ * @returns
+ */
const NotionPage = ({ post, className }) => {
useEffect(() => {
autoScrollToTarget()
@@ -74,6 +79,8 @@ const NotionPage = ({ post, className }) => {
const zoomRef = useRef(zoom ? zoom.clone() : null)
useEffect(() => {
+ if (!isBrowser) return;
+
// 将相册gallery下的图片加入放大功能
if (siteConfig('POST_DISABLE_GALLERY_CLICK')) {
setTimeout(() => {
@@ -111,6 +118,30 @@ const NotionPage = ({ post, className }) => {
}
}
}
+
+ // 放大图片:调整图片质量
+ const observer = new MutationObserver((mutationsList, observer) => {
+ mutationsList.forEach(mutation => {
+ if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
+ if (mutation.target.classList.contains('medium-zoom-image--opened')) {
+ // 等待动画完成后替换为更高清的图像
+ setTimeout(() => {
+ // 获取该元素的 src 属性
+ const src = mutation?.target?.getAttribute('src');
+ // 替换为更高清的图像
+ mutation?.target?.setAttribute('src', compressImage(src, siteConfig('IMAGE_ZOOM_IN_WIDTH', 1200)));
+ }, 800);
+ }
+ }
+ });
+ });
+
+ // 监视整个文档中的元素和属性的变化
+ observer.observe(document.body, { attributes: true, subtree: true, attributeFilter: ['class'] });
+
+ return () => {
+ observer.disconnect();
+ };
}, [])
if (!post || !post.blockMap) {
diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js
index 4902f5e4..d094dd57 100755
--- a/lib/notion/getNotionData.js
+++ b/lib/notion/getNotionData.js
@@ -7,7 +7,7 @@ import { getAllCategories } from './getAllCategories'
import getAllPageIds from './getAllPageIds'
import { getAllTags } from './getAllTags'
import getPageProperties from './getPageProperties'
-import { mapImgUrl, compressImage } from './mapImage'
+import { compressImage, mapImgUrl } from './mapImage'
import { getConfigMapFromConfigPage } from './getNotionConfig'
/**
diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js
index b0888386..615ed5c9 100644
--- a/lib/notion/mapImage.js
+++ b/lib/notion/mapImage.js
@@ -1,4 +1,5 @@
import BLOG from '@/blog.config'
+import { siteConfig } from '../config'
/**
* 图片映射
@@ -58,7 +59,7 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => {
// 统一压缩图片
if (from === 'pageCoverThumbnail' || block.type === 'image' || block.type === 'page') {
- const width = block?.format?.block_width || 200
+ const width = block?.format?.block_width
ret = compressImage(ret, width)
}
@@ -81,19 +82,29 @@ function isEmoji(str) {
* 2. UnPlash 图片可以通过api q=50 控制压缩质量 width=400 控制图片尺寸
* @param {*} image
*/
-const compressImage = (image, width = 800, quality = 50, fmt = 'webp') => {
- if (!image) {
- return null
+const compressImage = (image, width, quality = 50, fmt = 'webp') => {
+ if (!image || image.indexOf('http') !== 0) {
+ return image
}
+
+ if (!width || width === 0) {
+ width = siteConfig('IMAGE_COMPRESS_WIDTH')
+ }
+
+ // 将URL解析为一个对象
+ const urlObj = new URL(image)
+ // 获取URL参数
+ const params = new URLSearchParams(urlObj.search)
+
+ // Notion图床
if (image.indexOf(BLOG.NOTION_HOST) === 0 && image.indexOf('amazonaws.com') > 0) {
- return `${image}&width=${width}&cache=v2`
- }
- // 压缩unsplash图片
- if (image.indexOf('https://images.unsplash.com/') === 0) {
- // 将URL解析为一个对象
- const urlObj = new URL(image)
- // 获取URL参数
- const params = new URLSearchParams(urlObj.search)
+ params.set('width', width)
+ params.set('cache', 'v2')
+ // 生成新的URL
+ urlObj.search = params.toString()
+ return urlObj.toString()
+ } else if (image.indexOf('https://images.unsplash.com/') === 0) {
+ // 压缩unsplash图片
// 将q参数的值替换
params.set('q', quality)
// 尺寸
@@ -104,11 +115,9 @@ const compressImage = (image, width = 800, quality = 50, fmt = 'webp') => {
// 生成新的URL
urlObj.search = params.toString()
return urlObj.toString()
- }
-
- // 此处还可以添加您的自定义图传的封面图压缩参数。
+ } else if (image.indexOf('https://your_picture_bed') === 0) {
+ // 此处还可以添加您的自定义图传的封面图压缩参数。
// .e.g
- if (image.indexOf('https://your_picture_bed') === 0) {
return 'do_somethin_here'
}
diff --git a/lib/utils.js b/lib/utils.js
index 3f0d858e..a892c275 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -30,6 +30,33 @@ export const memorize = (Component) => {
}
return memo(MemoizedComponent)
}
+
+// 转换外链
+export function sliceUrlFromHttp(str) {
+ // 检查字符串是否包含http
+ if (str.includes('http')) {
+ // 如果包含,找到http的位置
+ const index = str.indexOf('http');
+ // 返回http之后的部分
+ return str.slice(index, str.length);
+ } else {
+ // 如果不包含,返回原字符串
+ return str;
+ }
+}
+
+// 检查是否外链
+export function checkContainHttp(str) {
+ // 检查字符串是否包含http
+ if (str.includes('http')) {
+ // 如果包含,找到http的位置
+ return str.indexOf('http') > -1
+ } else {
+ // 不包含
+ return false;
+ }
+}
+
/**
* 加载外部资源
* @param url 地址 例如 https://xx.com/xx.js
diff --git a/themes/example/components/BlogListGroupByDate.js b/themes/example/components/BlogListGroupByDate.js
index 29598f0b..7a8fe083 100644
--- a/themes/example/components/BlogListGroupByDate.js
+++ b/themes/example/components/BlogListGroupByDate.js
@@ -1,4 +1,5 @@
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
import Link from 'next/link'
/**
@@ -14,8 +15,10 @@ export default function BlogListGroupByDate({ archiveTitle, archivePosts }) {
- {archivePosts[archiveTitle].map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -24,12 +27,12 @@ export default function BlogListGroupByDate({ archiveTitle, archivePosts }) {
{post?.publishDay}
{' '}
-
+
{post.title}
- ))}
+ })}
}
diff --git a/themes/example/components/BlogPostCard.js b/themes/example/components/BlogPostCard.js
index cd330a83..a8783f8c 100644
--- a/themes/example/components/BlogPostCard.js
+++ b/themes/example/components/BlogPostCard.js
@@ -3,9 +3,11 @@ import CONFIG from '../config'
import Link from 'next/link'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ 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
@@ -41,7 +43,7 @@ const BlogPostCard = ({ post }) => {
{/* 图片封面 */}
{showPageCover && (
-
+
diff --git a/themes/fukasawa/components/AsideLeft.js b/themes/fukasawa/components/AsideLeft.js
index 955cc628..5083269b 100644
--- a/themes/fukasawa/components/AsideLeft.js
+++ b/themes/fukasawa/components/AsideLeft.js
@@ -9,11 +9,14 @@ import Announcement from './Announcement'
import { useRouter } from 'next/router'
import DarkModeButton from '@/components/DarkModeButton'
import SocialButton from './SocialButton'
-import { useFukasawaGlobal } from '..'
import CONFIG from '@/themes/fukasawa/config'
import { AdSlot } from '@/components/GoogleAdsense'
import { siteConfig } from '@/lib/config'
import MailChimpForm from './MailChimpForm'
+import { useGlobal } from '@/lib/global'
+import { useEffect, useState } from 'react'
+import { isBrowser } from '@/lib/utils'
+import { debounce } from 'lodash'
/**
* 侧边栏
@@ -23,39 +26,59 @@ import MailChimpForm from './MailChimpForm'
function AsideLeft(props) {
const { tagOptions, currentTag, categoryOptions, currentCategory, post, slot, notice } = props
const router = useRouter()
- const { isCollapsed, setIsCollapse } = useFukasawaGlobal()
+ const { fullWidth } = useGlobal()
+
+ const FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT = fullWidth || siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG)
+
+ // 侧边栏折叠从 本地存储中获取 open 状态的初始值
+ const [isCollapsed, setIsCollapse] = useState(() => {
+ if (typeof window !== 'undefined') {
+ return localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT
+ }
+ return FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT
+ })
+
+ // 在组件卸载时保存 open 状态到本地存储中
+ useEffect(() => {
+ if (isBrowser) {
+ localStorage.setItem('fukasawa-sidebar-collapse', isCollapsed)
+ }
+ }, [isCollapsed])
+
// 折叠侧边栏
const toggleOpen = () => {
setIsCollapse(!isCollapsed)
}
// 自动折叠侧边栏 onResize 窗口宽度小于1366 || 滚动条滚动至页面的300px时 ; 将open设置为false
- // useEffect(() => {
- // const handleResize = debounce(() => {
- // if (window.innerWidth < 1366 || window.scrollY >= 100) {
- // setIsCollapse(true)
- // } else {
- // setIsCollapse(false)
- // }
- // }, 100)
+ useEffect(() => {
+ if (!siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL', false, CONFIG)) {
+ return
+ }
+ const handleResize = debounce(() => {
+ if (window.innerWidth < 1366 || window.scrollY >= 1366) {
+ setIsCollapse(true)
+ } else {
+ setIsCollapse(false)
+ }
+ }, 100)
- // console.log('router', router)
- // if (router.pathname === '/[...slug]') {
- // window.addEventListener('resize', handleResize)
- // window.addEventListener('scroll', handleResize, { passive: true })
- // }
+ if (post) {
+ window.addEventListener('resize', handleResize)
+ window.addEventListener('scroll', handleResize, { passive: true })
+ }
- // return () => {
- // if (router.pathname === '/[...slug]') {
- // window.removeEventListener('resize', handleResize)
- // window.removeEventListener('scroll', handleResize, { passive: true })
- // }
- // }
- // }, [])
+ return () => {
+ if (post) {
+ window.removeEventListener('resize', handleResize)
+ window.removeEventListener('scroll', handleResize, { passive: true })
+ }
+ }
+ }, [])
- return
+ return
{/* 折叠按钮 */}
- {siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_BUTTON', null, CONFIG) &&
+ {siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_BUTTON', null, CONFIG) &&
{isCollapsed ? : }
}
diff --git a/themes/fukasawa/components/BlogCard.js b/themes/fukasawa/components/BlogCard.js
index e0cd66a9..6c85bfc8 100644
--- a/themes/fukasawa/components/BlogCard.js
+++ b/themes/fukasawa/components/BlogCard.js
@@ -3,7 +3,13 @@ import Link from 'next/link'
import TagItemMini from './TagItemMini'
import CONFIG from '../config'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
+/**
+ * 文章列表卡片
+ * @param {*} param0
+ * @returns
+ */
const BlogCard = ({ index, post, showSummary, siteInfo }) => {
const showPreview = siteConfig('FUKASAWA_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
// fukasawa 强制显示图片
@@ -11,22 +17,29 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
post.pageCoverThumbnail = siteInfo?.pageCover
}
const showPageCover = siteConfig('FUKASAWA_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail
- const SUB_PATH = siteConfig('SUB_PATH', '')
+ const FUKASAWA_POST_LIST_ANIMATION = siteConfig('FUKASAWA_POST_LIST_ANIMATION', null, CONFIG)
+
+ // 动画样式 首屏卡片不用,后面翻出来的加动画
+ const aosProps = FUKASAWA_POST_LIST_ANIMATION
+ ? {
+ 'data-aos': 'fade-up',
+ 'data-aos-duration': '300',
+ 'data-aos-once': 'true',
+ 'data-aos-anchor-placement': 'top-bottom'
+ }
+ : {}
+
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
-
{/* 封面图 */}
{showPageCover && (
-
+
{
{/* 文字部分 */}
-
{post.title}
diff --git a/themes/fukasawa/components/BlogPostArchive.js b/themes/fukasawa/components/BlogPostArchive.js
index c1a77718..300098d4 100644
--- a/themes/fukasawa/components/BlogPostArchive.js
+++ b/themes/fukasawa/components/BlogPostArchive.js
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 博客归档
@@ -21,8 +22,9 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => {
{archiveTitle}
- {posts?.map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+ return
-
@@ -30,7 +32,7 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => {
{post.date?.start_date}{' '}
@@ -39,7 +41,7 @@ const BlogArchiveItem = ({ posts = [], archiveTitle }) => {
- ))}
+ })}
)
diff --git a/themes/fukasawa/components/MenuItemCollapse.js b/themes/fukasawa/components/MenuItemCollapse.js
index f854c16f..8251f3c7 100644
--- a/themes/fukasawa/components/MenuItemCollapse.js
+++ b/themes/fukasawa/components/MenuItemCollapse.js
@@ -44,7 +44,7 @@ export const MenuItemCollapse = (props) => {
}
-
+
f
{/* 折叠子菜单 */}
{hasSubMenu &&
diff --git a/themes/fukasawa/config.js b/themes/fukasawa/config.js
index 462c54ca..c5e06801 100644
--- a/themes/fukasawa/config.js
+++ b/themes/fukasawa/config.js
@@ -4,6 +4,7 @@ const CONFIG = {
FUKASAWA_POST_LIST_COVER: true, // 文章列表显示图片封面
FUKASAWA_POST_LIST_COVER_FORCE: false, // 即使没有封面也将站点背景图设置为封面
FUKASAWA_POST_LIST_PREVIEW: false, // 显示文章预览
+ FUKASAWA_POST_LIST_ANIMATION: false, // 博客列表淡入动画
// 菜单
FUKASAWA_MENU_CATEGORY: true, // 显示分类
@@ -12,7 +13,8 @@ const CONFIG = {
FUKASAWA_MENU_SEARCH: false, // 显示搜索
FUKASAWA_SIDEBAR_COLLAPSE_BUTTON: true, // 侧边栏折叠按钮
- FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT: false // 侧边栏默认折叠收起
+ FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT: false, // 侧边栏默认折叠收起
+ FUKASAWA_SIDEBAR_COLLAPSE_ON_SCROLL: false // 侧边栏滚动时折叠 仅文章阅读页有效
}
export default CONFIG
diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js
index 8587daad..ed742c1c 100644
--- a/themes/fukasawa/index.js
+++ b/themes/fukasawa/index.js
@@ -12,7 +12,7 @@ import ArticleDetail from './components/ArticleDetail'
import ArticleLock from './components/ArticleLock'
import TagItemMini from './components/TagItemMini'
import { useRouter } from 'next/router'
-import { createContext, useContext, useEffect, useState } from 'react'
+import { createContext, useContext, useEffect } from 'react'
import Link from 'next/link'
import { Transition } from '@headlessui/react'
import dynamic from 'next/dynamic'
@@ -48,25 +48,8 @@ const LayoutBase = (props) => {
const leftAreaSlot =
const { onLoading, fullWidth } = useGlobal()
- const FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT = fullWidth || siteConfig('FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT', null, CONFIG)
-
- // 侧边栏折叠从 本地存储中获取 open 状态的初始值
- const [isCollapsed, setIsCollapse] = useState(() => {
- if (typeof window !== 'undefined') {
- return localStorage.getItem('fukasawa-sidebar-collapse') === 'true' || FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT
- }
- return FUKASAWA_SIDEBAR_COLLAPSE_SATUS_DEFAULT
- })
-
- // 在组件卸载时保存 open 状态到本地存储中
- useEffect(() => {
- if (isBrowser) {
- localStorage.setItem('fukasawa-sidebar-collapse', isCollapsed)
- }
- }, [isCollapsed])
-
return (
-
+
{/* SEO信息 */}
diff --git a/themes/gitbook/components/BlogArchiveItem.js b/themes/gitbook/components/BlogArchiveItem.js
index efd67565..ad9ac831 100644
--- a/themes/gitbook/components/BlogArchiveItem.js
+++ b/themes/gitbook/components/BlogArchiveItem.js
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 归档分组
@@ -13,8 +14,10 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{archiveTitle}
- {archivePosts[archiveTitle]?.map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -23,13 +26,13 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{' '}
-
{post.title}
- ))}
+ })}
)
diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js
index 04cf47c0..a177b700 100644
--- a/themes/gitbook/components/BlogPostCard.js
+++ b/themes/gitbook/components/BlogPostCard.js
@@ -1,12 +1,14 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
import { useRouter } from 'next/router'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
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 (
-
+
{post.title}
diff --git a/themes/heo/components/ArticleRecommend.js b/themes/heo/components/ArticleRecommend.js
index 02fa0b7f..9ffcadbb 100644
--- a/themes/heo/components/ArticleRecommend.js
+++ b/themes/heo/components/ArticleRecommend.js
@@ -3,6 +3,7 @@ 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'
/**
* 关联推荐文章
@@ -38,12 +39,13 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
const headerImage = post?.pageCoverThumbnail
? post.pageCoverThumbnail
: siteInfo?.pageCover
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
(
diff --git a/themes/heo/components/BlogPostArchive.js b/themes/heo/components/BlogPostArchive.js
index 7a285d6d..eda2f777 100644
--- a/themes/heo/components/BlogPostArchive.js
+++ b/themes/heo/components/BlogPostArchive.js
@@ -3,6 +3,8 @@ import CONFIG from '../config'
import TagItemMini from './TagItemMini'
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
+
/**
* 博客归档列表
* @param posts 所有文章
@@ -24,6 +26,8 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => {
{posts?.map(post => {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
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
@@ -34,7 +38,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => {
{/* 图片封面 */}
{showPageCover && (
-
+
@@ -53,7 +57,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => {
{/* 标题 */}
{post.title}
diff --git a/themes/heo/components/BlogPostCard.js b/themes/heo/components/BlogPostCard.js
index f88aabbe..fa16fc25 100644
--- a/themes/heo/components/BlogPostCard.js
+++ b/themes/heo/components/BlogPostCard.js
@@ -3,6 +3,7 @@ import CONFIG from '../config'
import TagItemMini from './TagItemMini'
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
const showPreview = siteConfig('HEO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
@@ -10,6 +11,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
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}`
return (
@@ -22,7 +24,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
{/* 图片封面 */}
{showPageCover && (
-
+
@@ -42,7 +44,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
{/* 标题 */}
{post.title}
diff --git a/themes/heo/components/LatestPostsGroup.js b/themes/heo/components/LatestPostsGroup.js
index 7dc0ae01..5727e9e0 100644
--- a/themes/heo/components/LatestPostsGroup.js
+++ b/themes/heo/components/LatestPostsGroup.js
@@ -1,6 +1,7 @@
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 最新文章列表
@@ -18,11 +19,12 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
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 (
(
diff --git a/themes/heo/components/LatestPostsGroupMini.js b/themes/heo/components/LatestPostsGroupMini.js
index ea45d3cb..70a9b761 100644
--- a/themes/heo/components/LatestPostsGroupMini.js
+++ b/themes/heo/components/LatestPostsGroupMini.js
@@ -4,6 +4,7 @@ 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'
/**
* 最新文章列表
@@ -29,14 +30,14 @@ export default function LatestPostsGroupMini ({ latestPosts, siteInfo }) {
{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}`
return (
(
diff --git a/themes/hexo/components/ArticleRecommend.js b/themes/hexo/components/ArticleRecommend.js
index e773db4e..a3a40b7d 100644
--- a/themes/hexo/components/ArticleRecommend.js
+++ b/themes/hexo/components/ArticleRecommend.js
@@ -3,6 +3,7 @@ import CONFIG from '../config'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 关联推荐文章
@@ -33,12 +34,13 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
const headerImage = post?.pageCoverThumbnail
? post.pageCoverThumbnail
: siteInfo?.pageCover
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
(
diff --git a/themes/hexo/components/BlogPostArchive.js b/themes/hexo/components/BlogPostArchive.js
index 0eec29f5..e9bf4f22 100644
--- a/themes/hexo/components/BlogPostArchive.js
+++ b/themes/hexo/components/BlogPostArchive.js
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 博客归档列表
@@ -21,8 +22,9 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
{archiveTitle}
- {posts?.map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+ return
-
@@ -30,7 +32,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
{post.date?.start_date}{' '}
@@ -39,7 +41,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
- ))}
+ })}
)
diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js
index ee21c056..af682d02 100644
--- a/themes/hexo/components/BlogPostCard.js
+++ b/themes/hexo/components/BlogPostCard.js
@@ -3,7 +3,7 @@ import CONFIG from '../config'
import { BlogPostCardInfo } from './BlogPostCardInfo'
import { siteConfig } from '@/lib/config'
import LazyImage from '@/components/LazyImage'
-// import Image from 'next/image'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
const showPreview = siteConfig('HEXO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
@@ -12,6 +12,7 @@ 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 (
@@ -32,7 +33,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
{/* 图片封面 */}
{showPageCover && (
-
+
diff --git a/themes/hexo/components/BlogPostCardInfo.js b/themes/hexo/components/BlogPostCardInfo.js
index e7636de9..890952d5 100644
--- a/themes/hexo/components/BlogPostCardInfo.js
+++ b/themes/hexo/components/BlogPostCardInfo.js
@@ -4,6 +4,7 @@ import TagItemMini from './TagItemMini'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { siteConfig } from '@/lib/config'
import { formatDateFmt } from '@/lib/formatDate'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 博客列表的文字内容
@@ -11,11 +12,12 @@ import { formatDateFmt } from '@/lib/formatDate'
* @returns
*/
export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary }) => {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return
{/* 标题 */}
diff --git a/themes/hexo/components/LatestPostsGroup.js b/themes/hexo/components/LatestPostsGroup.js
index f9ac9026..e8dc4140 100644
--- a/themes/hexo/components/LatestPostsGroup.js
+++ b/themes/hexo/components/LatestPostsGroup.js
@@ -4,6 +4,7 @@ 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'
/**
* 最新文章列表
@@ -28,15 +29,15 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
{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}`
+ const selected = currentPath === url
return (
(
diff --git a/themes/matery/components/ArticleRecommend.js b/themes/matery/components/ArticleRecommend.js
index 0751fbaf..ec0517d3 100644
--- a/themes/matery/components/ArticleRecommend.js
+++ b/themes/matery/components/ArticleRecommend.js
@@ -3,6 +3,7 @@ import CONFIG from '../config'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 关联推荐文章
@@ -33,12 +34,13 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
const headerImage = post?.pageCoverThumbnail
? post.pageCoverThumbnail
: siteInfo?.pageCover
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
(
diff --git a/themes/matery/components/BlogPostArchive.js b/themes/matery/components/BlogPostArchive.js
index 0eec29f5..0cfff1ac 100644
--- a/themes/matery/components/BlogPostArchive.js
+++ b/themes/matery/components/BlogPostArchive.js
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 博客归档列表
@@ -21,17 +22,17 @@ const BlogPostArchive = ({ posts = [], 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}
@@ -39,7 +40,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
- ))}
+ })}
)
diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js
index 13aef2e0..7700957d 100644
--- a/themes/matery/components/BlogPostCard.js
+++ b/themes/matery/components/BlogPostCard.js
@@ -5,7 +5,7 @@ import CONFIG from '../config'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import LazyImage from '@/components/LazyImage'
import { formatDateFmt } from '@/lib/formatDate'
-// import Image from 'next/image'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
const showPreview = siteConfig('MATERY_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
@@ -15,6 +15,8 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
}
const showPageCover = 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 && (
-
+
)
diff --git a/themes/medium/components/BlogPostCard.js b/themes/medium/components/BlogPostCard.js
index 5473a04c..a3e9e6bf 100644
--- a/themes/medium/components/BlogPostCard.js
+++ b/themes/medium/components/BlogPostCard.js
@@ -7,10 +7,12 @@ import CategoryItem from './CategoryItem'
import TagItemMini from './TagItemMini'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ post, showSummary }) => {
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 (
{
{
diff --git a/themes/nav/components/BlogArchiveItem.js b/themes/nav/components/BlogArchiveItem.js
index efd67565..ad9ac831 100755
--- a/themes/nav/components/BlogArchiveItem.js
+++ b/themes/nav/components/BlogArchiveItem.js
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 归档分组
@@ -13,8 +14,10 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{archiveTitle}
- {archivePosts[archiveTitle]?.map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -23,13 +26,13 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{' '}
-
{post.title}
- ))}
+ })}
)
diff --git a/themes/nav/components/BlogPostCard.js b/themes/nav/components/BlogPostCard.js
index cc3934e0..92c5fe2b 100755
--- a/themes/nav/components/BlogPostCard.js
+++ b/themes/nav/components/BlogPostCard.js
@@ -2,6 +2,7 @@ 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'
const BlogPostCard = ({ post, className }) => {
const router = useRouter()
@@ -22,30 +23,6 @@ const BlogPostCard = ({ post, className }) => {
)
-
- // 检查连接是否是外链
- function sliceUrlFromHttp(str) {
- // 检查字符串是否包含http
- if (str.includes('http')) {
- // 如果包含,找到http的位置
- const index = str.indexOf('http');
- // 返回http之后的部分
- return str.slice(index, str.length);
- } else {
- // 如果不包含,返回原字符串
- return str;
- }
- }
- function checkContainHttp(str) {
- // 检查字符串是否包含http
- if (str.includes('http')) {
- // 如果包含,找到http的位置
- return str.indexOf('http') > -1
- } else {
- // 不包含
- return false;
- }
- }
}
export default BlogPostCard
diff --git a/themes/next/components/BlogPostArchive.js b/themes/next/components/BlogPostArchive.js
index 91e98a70..2b09e868 100644
--- a/themes/next/components/BlogPostArchive.js
+++ b/themes/next/components/BlogPostArchive.js
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 博客归档列表
@@ -21,8 +22,10 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
{archiveTitle}
- {posts?.map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -30,7 +33,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
{post.date?.start_date}{' '}
@@ -39,7 +42,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
- ))}
+ })}
)
diff --git a/themes/next/components/BlogPostCard.js b/themes/next/components/BlogPostCard.js
index 51e31578..53cc4ee3 100644
--- a/themes/next/components/BlogPostCard.js
+++ b/themes/next/components/BlogPostCard.js
@@ -9,6 +9,7 @@ import NotionIcon from '@/components/NotionIcon'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPostCard = ({ post, index, showSummary }) => {
const { locale } = useGlobal()
@@ -22,6 +23,7 @@ const BlogPostCard = ({ post, index, showSummary }) => {
'data-aos-anchor-placement': 'top-bottom'
}
: {}
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
@@ -34,7 +36,7 @@ const BlogPostCard = ({ post, index, showSummary }) => {
{/* 文章标题 */}
@@ -99,7 +101,7 @@ const BlogPostCard = ({ post, index, showSummary }) => {
{locale.COMMON.ARTICLE_DETAIL}
@@ -110,7 +112,7 @@ const BlogPostCard = ({ post, index, showSummary }) => {
{siteConfig('NEXT_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && (
-
+
{
{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 (
(
diff --git a/themes/nobelium/components/BlogArchiveItem.js b/themes/nobelium/components/BlogArchiveItem.js
index 809ac6d8..ac1c2522 100644
--- a/themes/nobelium/components/BlogArchiveItem.js
+++ b/themes/nobelium/components/BlogArchiveItem.js
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 归档分组文章
@@ -14,8 +15,10 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- {archivePosts[archiveTitle].map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -25,7 +28,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{' '}
@@ -34,7 +37,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- ))}
+ })}
)
diff --git a/themes/nobelium/components/BlogPost.js b/themes/nobelium/components/BlogPost.js
index 1d641975..8af88325 100644
--- a/themes/nobelium/components/BlogPost.js
+++ b/themes/nobelium/components/BlogPost.js
@@ -1,9 +1,12 @@
import Link from 'next/link'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
const BlogPost = ({ post }) => {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
return (
- (
+ (
diff --git a/themes/plog/components/BlogArchiveItem.js b/themes/plog/components/BlogArchiveItem.js
index 4d3f3d02..47127415 100644
--- a/themes/plog/components/BlogArchiveItem.js
+++ b/themes/plog/components/BlogArchiveItem.js
@@ -1,5 +1,6 @@
import Link from 'next/link'
import { siteConfig } from '@/lib/config'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 归档分组文章
@@ -14,8 +15,10 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- {archivePosts[archiveTitle].map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+
+ return
-
@@ -25,7 +28,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{' '}
@@ -34,7 +37,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- ))}
+ })}
)
diff --git a/themes/plog/components/BlogPost.js b/themes/plog/components/BlogPost.js
index a75fa8d5..66811a80 100644
--- a/themes/plog/components/BlogPost.js
+++ b/themes/plog/components/BlogPost.js
@@ -11,7 +11,7 @@ import LazyImage from '@/components/LazyImage'
*/
const BlogPost = (props) => {
const { post, index, siteInfo } = props
- const pageThumbnail = compressImage(post?.pageCoverThumbnail || siteInfo?.pageCover, 800, 80)
+ const pageThumbnail = compressImage(post?.pageCoverThumbnail || siteInfo?.pageCover)
const { setModalContent, setShowModal } = usePlogGlobal()
const handleClick = () => {
setShowModal(true)
diff --git a/themes/plog/index.js b/themes/plog/index.js
index 80bad683..017417d1 100644
--- a/themes/plog/index.js
+++ b/themes/plog/index.js
@@ -41,7 +41,7 @@ const LayoutBase = props => {
// 页面切换关闭遮罩
const router = useRouter()
- const closeModal = ()=>{
+ const closeModal = () => {
setShowModal(false)
}
@@ -52,7 +52,6 @@ const LayoutBase = props => {
}
}, [router.events])
-
return (
diff --git a/themes/simple/components/BlogArchiveItem.js b/themes/simple/components/BlogArchiveItem.js
index 809ac6d8..270dc90c 100644
--- a/themes/simple/components/BlogArchiveItem.js
+++ b/themes/simple/components/BlogArchiveItem.js
@@ -1,5 +1,6 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
/**
* 归档分组文章
@@ -14,8 +15,9 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- {archivePosts[archiveTitle].map(post => (
- - {
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
+ return
-
@@ -25,7 +27,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
{' '}
@@ -34,7 +36,7 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
- ))}
+ })}
)
diff --git a/themes/simple/components/BlogItem.js b/themes/simple/components/BlogItem.js
index 8d682e11..625435af 100644
--- a/themes/simple/components/BlogItem.js
+++ b/themes/simple/components/BlogItem.js
@@ -4,10 +4,12 @@ import TwikooCommentCount from '@/components/TwikooCommentCount'
import { formatDateFmt } from '@/lib/formatDate'
import { siteConfig } from '@/lib/config'
import LazyImage from '@/components/LazyImage'
+import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
export const BlogItem = props => {
const { post } = props
const showPageCover = siteConfig('SIMPLE_POST_COVER_ENABLE', false, CONFIG)
+ const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
return
{/* 文章标题 */}
@@ -17,7 +19,7 @@ export const BlogItem = props => {
{/* 图片封面 */}
{showPageCover && (
-
+
@@ -27,7 +29,7 @@ export const BlogItem = props => {
{post.title}
@@ -60,7 +62,7 @@ export const BlogItem = props => {
-
+
Continue Reading
diff --git a/themes/simple/components/Header.js b/themes/simple/components/Header.js
index 96f504cf..f2b359ad 100644
--- a/themes/simple/components/Header.js
+++ b/themes/simple/components/Header.js
@@ -3,7 +3,6 @@ import Link from 'next/link'
import CONFIG from '../config'
import SocialButton from './SocialButton'
import { siteConfig } from '@/lib/config'
-import { compressImage } from '@/lib/notion/mapImage'
/**
* 网站顶部
@@ -11,7 +10,6 @@ import { compressImage } from '@/lib/notion/mapImage'
*/
export default function Header (props) {
const { siteInfo } = props
- const avatar = compressImage(siteInfo?.icon || siteConfig('AVATAR'), 200)
return (
@@ -20,7 +18,7 @@ export default function Header (props) {
{/* 可使用一张单图作为logo */}