From c2ca2e15beeb72795a6294cc94edc1f20c374f6d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sat, 2 Sep 2023 12:48:42 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=9B=BE=E5=BA=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapImage.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 951f5d2a223..8d7f9fba7a7 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -61,7 +61,9 @@ const mapImgUrl = (img, block, type = 'block', from) => { } // Notion 图床转换为永久地址 - if (ret.indexOf('secure.notion-static.com') > 0 && (BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block')) { + const isNotionImg = ret.indexOf('secure.notion-static.com') > 0 || ret.indexOf('prod-files-secure') > 0 + const isImgBlock = BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block' + if (isNotionImg && isImgBlock) { ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id } From 5b271365216bbd443a2dada090a6af25ec72e053 Mon Sep 17 00:00:00 2001 From: Femoon <839242981@qq.com> Date: Sun, 28 Apr 2024 16:44:37 +0800 Subject: [PATCH 02/13] fix: medium theme page refresh causing the catalog loss, phone style optimization --- themes/medium/components/BottomMenuBar.js | 8 ++++---- themes/medium/index.js | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/themes/medium/components/BottomMenuBar.js b/themes/medium/components/BottomMenuBar.js index fee36eb2ed5..23979d9efa1 100644 --- a/themes/medium/components/BottomMenuBar.js +++ b/themes/medium/components/BottomMenuBar.js @@ -4,7 +4,7 @@ import JumpToTopButton from './JumpToTopButton' export default function BottomMenuBar ({ post, className }) { const { tocVisible, changeTocVisible } = useMediumGlobal() - const showTocBotton = post?.toc?.length > 0 + const showTocButton = post?.toc?.length > 0 const toggleToc = () => { changeTocVisible(!tocVisible) @@ -18,13 +18,13 @@ export default function BottomMenuBar ({ post, className }) { -
+
- {showTocBotton &&
+ {showTocButton &&
} - { !showTocBotton && + { !showTocButton &&
diff --git a/themes/medium/index.js b/themes/medium/index.js index 1e3f365d038..e35cdc28e93 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -51,12 +51,20 @@ const LayoutBase = props => { const router = useRouter() const [tocVisible, changeTocVisible] = useState(false) const { onLoading, fullWidth } = useGlobal() + const [slotRight, setSlotRight] = useState(null); + + useEffect(()=> { + if (post?.toc?.length > 0) { + setSlotRight( +
+ +
+ ); + } else { + setSlotRight(null); + } + },[post]) - const slotRight = post?.toc?.length > 0 && ( -
- -
- ) const slotTop = return ( @@ -178,7 +186,7 @@ const LayoutSlug = props => { }, [post]) return ( -
+
{/* 文章锁 */} {lock && } From 055236d941a521ba7201951a59ed8c70169b976f Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 10:08:39 +0800 Subject: [PATCH 03/13] =?UTF-8?q?matery=20=E4=B8=BB=E9=A2=98=E4=B8=80?= =?UTF-8?q?=E9=97=AA=E8=80=8C=E8=BF=87=E7=9A=84title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/matery/components/Hero.js | 6 +++--- themes/matery/components/Logo.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/themes/matery/components/Hero.js b/themes/matery/components/Hero.js index 35260f9acc0..65975a0fce1 100644 --- a/themes/matery/components/Hero.js +++ b/themes/matery/components/Hero.js @@ -9,7 +9,8 @@ import CONFIG from '../config' let wrapperTop = 0 /** - * + * 首页英雄区 + * 是一张大图,带个居中按钮 * @returns 头图 */ const Hero = props => { @@ -17,7 +18,6 @@ const Hero = props => { const { siteInfo } = props const { locale } = useGlobal() const GREETING_WORDS = siteConfig('GREETING_WORDS').split(',') - useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { @@ -61,7 +61,7 @@ const Hero = props => {
{/* 站点标题 */}
- {siteConfig('TITLE')} + {siteInfo?.title || siteConfig('TITLE')}
{/* 站点欢迎语 */}
diff --git a/themes/matery/components/Logo.js b/themes/matery/components/Logo.js index 3e6542f4ebc..a1082ae3a89 100644 --- a/themes/matery/components/Logo.js +++ b/themes/matery/components/Logo.js @@ -1,11 +1,20 @@ import { siteConfig } from '@/lib/config' import Link from 'next/link' - +/** + * 站点logo + * 这里默认只支持纯文字 + * @param {*} props + * @returns + */ const Logo = props => { + const { siteInfo } = props return (
-
{siteConfig('TITLE') }
+
+ {' '} + {siteInfo?.title || siteConfig('TITLE')} +
) From d68a97bc9b2dae3e251aa5c9e838423f68e323b5 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 10:10:09 +0800 Subject: [PATCH 04/13] =?UTF-8?q?hexo=20=E4=B8=BB=E9=A2=98=E4=B8=80?= =?UTF-8?q?=E9=97=AA=E8=80=8C=E8=BF=87=E7=9A=84title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/Hero.js | 2 +- themes/hexo/components/Logo.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/themes/hexo/components/Hero.js b/themes/hexo/components/Hero.js index 67ae346847e..91059205ea7 100644 --- a/themes/hexo/components/Hero.js +++ b/themes/hexo/components/Hero.js @@ -66,7 +66,7 @@ const Hero = props => {
{/* 站点标题 */}
- {siteConfig('TITLE')} + {siteInfo?.title || siteConfig('TITLE')}
{/* 站点欢迎语 */}
diff --git a/themes/hexo/components/Logo.js b/themes/hexo/components/Logo.js index 30054acc39f..2279834ce67 100644 --- a/themes/hexo/components/Logo.js +++ b/themes/hexo/components/Logo.js @@ -1,11 +1,20 @@ import { siteConfig } from '@/lib/config' import Link from 'next/link' - +/** + * Logo + * 实际值支持文字 + * @param {*} props + * @returns + */ const Logo = props => { + const { siteInfo } = props return (
-
{siteConfig('TITLE') }
+
+ {' '} + {siteInfo?.title || siteConfig('TITLE')} +
) From a81c1426b534f0bb4dd3bcac3558e5fcdb4492ba Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 10:22:19 +0800 Subject: [PATCH 05/13] =?UTF-8?q?hexo=20=E4=B8=BB=E9=A2=98=20=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/MenuItemCollapse.js | 6 +-- themes/hexo/components/MenuItemDrop.js | 10 +++-- themes/hexo/components/MenuListSide.js | 48 +++++++++++++++++----- themes/hexo/components/SideBar.js | 37 +++++++++++------ themes/matery/components/MenuItemDrop.js | 7 +++- themes/matery/components/MenuListTop.js | 43 +++++++++++++++---- 6 files changed, 111 insertions(+), 40 deletions(-) diff --git a/themes/hexo/components/MenuItemCollapse.js b/themes/hexo/components/MenuItemCollapse.js index 828079c7fda..1782ce52182 100644 --- a/themes/hexo/components/MenuItemCollapse.js +++ b/themes/hexo/components/MenuItemCollapse.js @@ -29,13 +29,13 @@ export const MenuItemCollapse = props => { return ( <>
{!hasSubMenu && ( + className=' font-extralight flex justify-between pl-2 pr-4 dark:text-gray-200 no-underline tracking-widest pb-1'> {link?.icon && } {link?.name} @@ -63,7 +63,7 @@ export const MenuItemCollapse = props => { return (
+ className='dark:hover:bg-indigo-500 hover:bg-indigo-500 hover:text-white dark:bg-black dark:text-gray-200 text-left px-10 justify-start bg-gray-50 tracking-widest transition-all duration-200 py-3 pr-6'> {link?.icon && }{' '} diff --git a/themes/hexo/components/MenuItemDrop.js b/themes/hexo/components/MenuItemDrop.js index b74d7a8f056..18ea74b698c 100644 --- a/themes/hexo/components/MenuItemDrop.js +++ b/themes/hexo/components/MenuItemDrop.js @@ -1,6 +1,10 @@ import Link from 'next/link' import { useState } from 'react' - +/** + * 支持二级展开的菜单 + * @param {*} param0 + * @returns + */ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -25,7 +29,7 @@ export const MenuItemDrop = ({ link }) => { {hasSubMenu && ( <> -
+
{link?.icon && } {link?.name} @@ -42,7 +46,7 @@ export const MenuItemDrop = ({ link }) => { return (
  • + className='cursor-pointer hover:bg-indigo-500 hover:text-white tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'> {link?.icon &&   } diff --git a/themes/hexo/components/MenuListSide.js b/themes/hexo/components/MenuListSide.js index 3a146d430c8..ab0b4278471 100644 --- a/themes/hexo/components/MenuListSide.js +++ b/themes/hexo/components/MenuListSide.js @@ -1,17 +1,41 @@ -import { useGlobal } from '@/lib/global' import { siteConfig } from '@/lib/config' -import { MenuItemCollapse } from './MenuItemCollapse' +import { useGlobal } from '@/lib/global' import CONFIG from '../config' - -export const MenuListSide = (props) => { +import { MenuItemCollapse } from './MenuItemCollapse' +/** + * 侧拉抽屉菜单 + * @param {*} props + * @returns + */ +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('HEXO_MENU_ARCHIVE', null, CONFIG) }, - { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) }, - { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: siteConfig('HEXO_MENU_TAG', null, CONFIG) } + { + icon: 'fas fa-archive', + name: locale.NAV.ARCHIVE, + to: '/archive', + show: siteConfig('HEXO_MENU_ARCHIVE', null, CONFIG) + }, + { + icon: 'fas fa-search', + name: locale.NAV.SEARCH, + to: '/search', + show: siteConfig('HEXO_MENU_SEARCH', null, CONFIG) + }, + { + icon: 'fas fa-folder', + name: locale.COMMON.CATEGORY, + to: '/category', + show: siteConfig('HEXO_MENU_CATEGORY', null, CONFIG) + }, + { + icon: 'fas fa-tag', + name: locale.COMMON.TAGS, + to: '/tag', + show: siteConfig('HEXO_MENU_TAG', null, CONFIG) + } ] if (customNav) { @@ -34,8 +58,10 @@ export const MenuListSide = (props) => { } return ( - + ) } diff --git a/themes/hexo/components/SideBar.js b/themes/hexo/components/SideBar.js index 913ce0a9273..64def6ec6c6 100644 --- a/themes/hexo/components/SideBar.js +++ b/themes/hexo/components/SideBar.js @@ -1,5 +1,5 @@ -import { siteConfig } from '@/lib/config' import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' import { useRouter } from 'next/router' import MenuGroupCard from './MenuGroupCard' import { MenuListSide } from './MenuListSide' @@ -11,22 +11,33 @@ import { MenuListSide } from './MenuListSide' * @returns {JSX.Element} * @constructor */ -const SideBar = (props) => { +const SideBar = props => { const { siteInfo } = props const router = useRouter() return ( -
  • + className='cursor-pointer hover:bg-indigo-500 text-gray-900 hover:text-white tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'> {link?.icon &&   } diff --git a/themes/matery/components/MenuListTop.js b/themes/matery/components/MenuListTop.js index 506f9c59167..04897f7ba4f 100644 --- a/themes/matery/components/MenuListTop.js +++ b/themes/matery/components/MenuListTop.js @@ -1,17 +1,42 @@ +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import CONFIG from '../config' import { MenuItemDrop } from './MenuItemDrop' -import { siteConfig } from '@/lib/config' - -export const MenuListTop = (props) => { +/** + * 菜单列表 + * 顶部导航栏用 + * @param {*} props + * @returns + */ +export const MenuListTop = props => { const { customNav, customMenu } = props const { locale } = useGlobal() let links = [ - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', 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-folder', 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', + 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-folder', + 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) + } ] if (customNav) { @@ -29,7 +54,9 @@ export const MenuListTop = (props) => { return ( ) } From 4811cb7319d8bf1313b24c934190d464040edd90 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 10:25:49 +0800 Subject: [PATCH 06/13] =?UTF-8?q?matery=20=E8=8F=9C=E5=8D=95=E5=BE=AE?= =?UTF-8?q?=E8=B0=83=EF=BC=9B=E5=8A=A0=E5=85=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/matery/components/MenuItemCollapse.js | 2 +- themes/matery/style.js | 55 +++++++++++++++----- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/themes/matery/components/MenuItemCollapse.js b/themes/matery/components/MenuItemCollapse.js index 6cd373f6d9b..0094fa86a59 100644 --- a/themes/matery/components/MenuItemCollapse.js +++ b/themes/matery/components/MenuItemCollapse.js @@ -72,7 +72,7 @@ export const MenuItemCollapse = ({ link }) => { return (
    + className='cursor-pointer whitespace-nowrap dark:text-gray-200 w-full font-extralight dark:bg-black text-left px-5 justify-start bg-gray-100 hover:bg-indigo-500 dark:hover:bg-indigo-500 hover:text-white tracking-widest transition-all duration-200 border-b dark:border-gray-800 py-3 pr-6'> diff --git a/themes/matery/style.js b/themes/matery/style.js index 711670c9174..32918e9219b 100644 --- a/themes/matery/style.js +++ b/themes/matery/style.js @@ -5,27 +5,54 @@ * @returns */ const Style = () => { - return + background: linear-gradient( + to bottom, + rgba(0, 0, 0, 0.5) 0%, + rgba(0, 0, 0, 0.2) 10%, + rgba(0, 0, 0, 0) 25%, + rgba(0, 0, 0, 0.2) 75%, + rgba(0, 0, 0, 0.5) 100% + ); + } + + // 自定义滚动条 + ::-webkit-scrollbar { + width: 5px; + height: 5px; + } + + ::-webkit-scrollbar-track { + background: transparent; + } + + ::-webkit-scrollbar-thumb { + background-color: #4338ca; + } + + * { + scrollbar-width: thin; + scrollbar-color: #4338ca transparent; + } + `} + ) } export { Style } From 9f64302ab69945da82a3f322437634c9bc5a5b5f Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 13:55:30 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapImage.js | 2 +- next.config.js | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index e0d92f83d5e..dba99d5cefa 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -60,7 +60,7 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // 图片url优化,确保每一篇文章的图片url唯一 - if (ret && ret.length > 4) { + if (ret && !ret.includes('https://www.notion.so/images/')) { // 图片接口拼接唯一识别参数,防止请求的图片被缓,而导致随机结果相同 const separator = ret.includes('?') ? '&' : '?' ret = `${ret.trim()}${separator}t=${block.id}` diff --git a/next.config.js b/next.config.js index f4352e6e9dd..5c1ba810dc9 100644 --- a/next.config.js +++ b/next.config.js @@ -54,21 +54,6 @@ function scanSubdirectories(directory) { } const nextConfig = { - images: { - // 图片压缩 - formats: ['image/avif', 'image/webp'], - // 允许next/image加载的图片 域名 - domains: [ - 'gravatar.com', - 'www.notion.so', - 'avatars.githubusercontent.com', - 'images.unsplash.com', - 'source.unsplash.com', - 'p1.qhimg.com', - 'webmention.io', - 'ko-fi.com' - ] - }, // 默认将feed重定向至 /public/rss/feed.xml async redirects() { return [ From 324516bef38a211802e436c0b34b9010b285a035 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 14:21:58 +0800 Subject: [PATCH 08/13] =?UTF-8?q?Notion=20bookmark=E5=9B=BE=E5=BA=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/getPageProperties.js | 7 +----- lib/notion/mapImage.js | 40 +++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 765521a9507..fefdad4d196 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -105,12 +105,7 @@ export default async function getPageProperties( properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? '' properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? '' properties.pageCoverThumbnail = - mapImgUrl( - value?.format?.page_cover, - value, - 'block', - 'pageCoverThumbnail' - ) ?? '' + mapImgUrl(value?.format?.page_cover, value, 'block') ?? '' properties.ext = converToJSON(properties?.ext) properties.content = value.content ?? [] properties.tagItems = diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index dba99d5cefa..92e430fd8c8 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -3,16 +3,18 @@ import { siteConfig } from '../config' /** * 图片映射 - * 1. 如果是 /xx.xx 相对路径格式,则转化为 完整notion域名图片 - * 2. 如果是 bookmark类型的block 图片封面无需处理 - * @param {*} img - * @param {*} value + * + * @param {*} img 图片地址,可能是相对路径,可能是外链 + * @param {*} block 数据块,可能是单个内容块,可能是Page + * @param {*} type block 单个内容块 ; collection 集合列表 + * @param {*} from 来自 * @returns */ -const mapImgUrl = (img, block, type = 'block', from = 'post') => { +const mapImgUrl = (img, block, type = 'block', needCompress = true) => { if (!img) { return null } + let ret = null // 相对目录,则视为notion的自带图片 if (img.startsWith('/')) { @@ -22,17 +24,21 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // Notion 图床转换为永久地址 - const isNotionSignImg = - ret.indexOf('https://www.notion.so/image') !== 0 && + const hasConverted = ret.indexOf('https://www.notion.so/image') === 0 + // 需要转化的URL ; 识别aws图床地址,或者bookmark类型的外链图片 + const needConvert = + !hasConverted && (ret.indexOf('secure.notion-static.com') > 0 || - ret.indexOf('prod-files-secure') > 0) - const isImgBlock = BLOG.IMG_URL_TYPE === 'Notion' || type !== 'block' - if (isNotionSignImg && isImgBlock) { + ret.indexOf('prod-files-secure') > 0 || + block.type === 'bookmark') + + // 使用Notion图传 + if (needConvert) { ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + - '?table=' + + '?table=block' + type + '&id=' + block.id @@ -60,7 +66,11 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // 图片url优化,确保每一篇文章的图片url唯一 - if (ret && !ret.includes('https://www.notion.so/images/')) { + if ( + ret && + ret.length > 4 && + !ret.includes('https://www.notion.so/images/') + ) { // 图片接口拼接唯一识别参数,防止请求的图片被缓,而导致随机结果相同 const separator = ret.includes('?') ? '&' : '?' ret = `${ret.trim()}${separator}t=${block.id}` @@ -68,11 +78,7 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // 统一压缩图片 - if ( - from === 'pageCoverThumbnail' || - block?.type === 'image' || - block?.type === 'page' - ) { + if (needCompress) { const width = block?.format?.block_width ret = compressImage(ret, width) } From 16c77377489924ec0c87baeb34d0ed8ea1af9a4b Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 14:27:27 +0800 Subject: [PATCH 09/13] img-url hotfix --- lib/notion/mapImage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 92e430fd8c8..1df9f9115e1 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -38,7 +38,7 @@ const mapImgUrl = (img, block, type = 'block', needCompress = true) => { BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + - '?table=block' + + '?table=' + type + '&id=' + block.id From 60a3650b60be1f922709fe850aedfa61c5f45505 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 14:41:17 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/next.config.js b/next.config.js index 5c1ba810dc9..bda40204ccd 100644 --- a/next.config.js +++ b/next.config.js @@ -54,6 +54,22 @@ function scanSubdirectories(directory) { } const nextConfig = { + images: { + // 图片压缩 + formats: ['image/avif', 'image/webp', 'image/png'], + // 允许next/image加载的图片 域名 + domains: [ + 'gravatar.com', + 'www.notion.so', + 'avatars.githubusercontent.com', + 'images.unsplash.com', + 'source.unsplash.com', + 'p1.qhimg.com', + 'webmention.io', + 'ko-fi.com' + ] + }, + // 默认将feed重定向至 /public/rss/feed.xml async redirects() { return [ From 61c6e0d321050f0a872a087ed32e9686d4a98986 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 14:42:11 +0800 Subject: [PATCH 11/13] image hotfix --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index bda40204ccd..d8a6c2baadc 100644 --- a/next.config.js +++ b/next.config.js @@ -56,7 +56,7 @@ function scanSubdirectories(directory) { const nextConfig = { images: { // 图片压缩 - formats: ['image/avif', 'image/webp', 'image/png'], + formats: ['image/avif', 'image/webp'], // 允许next/image加载的图片 域名 domains: [ 'gravatar.com', From f83514cd2c2f3feaa44ce740289e9063c8dcca4d Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 14:57:29 +0800 Subject: [PATCH 12/13] =?UTF-8?q?matery=20-=20image=20=E9=81=AE=E7=BD=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/matery/components/BlogPostCard.js | 184 ++++++++++++----------- 1 file changed, 99 insertions(+), 85 deletions(-) diff --git a/themes/matery/components/BlogPostCard.js b/themes/matery/components/BlogPostCard.js index d9a9c79fd2e..656e6ebf3f3 100644 --- a/themes/matery/components/BlogPostCard.js +++ b/themes/matery/components/BlogPostCard.js @@ -1,104 +1,118 @@ +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 TagItemMini from './TagItemMini' import CONFIG from '../config' -import TwikooCommentCount from '@/components/TwikooCommentCount' -import LazyImage from '@/components/LazyImage' -import { formatDateFmt } from '@/lib/utils/formatDate' -import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' -import NotionIcon from '@/components/NotionIcon' +import TagItemMini from './TagItemMini' +/** + * 博客列表:文章卡牌 + * @param {*} param0 + * @returns + */ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { - const showPreview = siteConfig('MATERY_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + const showPreview = + siteConfig('MATERY_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap // matery 主题默认强制显示图片 if (post && !post.pageCoverThumbnail) { post.pageCoverThumbnail = siteInfo?.pageCover } - const showPageCover = siteConfig('MATERY_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail + 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}` + const url = checkContainHttp(post.slug) + ? sliceUrlFromHttp(post.slug) + : `${siteConfig('SUB_PATH', '')}/${post.slug}` return ( -
    - - {/* 固定高度 ,空白用图片拉升填充 */} -
    - - {/* 头部图片 填充卡片 */} - {showPageCover && ( - -
    - -

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

    -
    - +
    + {/* 固定高度 ,空白用图片拉升填充 */} +
    + {/* 头部图片 填充卡片 */} + {showPageCover && ( + +
    + +

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

    + {/* 放在图片的阴影遮罩,便于突出文字 */} +
    +
    +
    +
    + + )} - {/* 文字描述 */} -
    - {/* 描述 */} -
    - - {(!showPreview || showSummary) && post.summary && ( -

    - {post.summary} -

    - )} - -
    -
    - - - - {post.date?.start_date || post.lastEditedDay} - - - -
    - - - - {post.category} - - -
    -
    + {/* 文字描述 */} +
    + {/* 描述 */} +
    + {(!showPreview || showSummary) && post.summary && ( +

    + {post.summary} +

    + )} - {post?.tagItems && post?.tagItems.length > 0 && (<> -
    -
    -
    -
    - {' '} - {post.tagItems.map(tag => ( - - ))} -
    -
    -
    - )} -
    -
    +
    +
    + + + {post.date?.start_date || post.lastEditedDay} + + +
    + + + {post.category} + +
    +
    -
    + {post?.tagItems && post?.tagItems.length > 0 && ( + <> +
    +
    +
    +
    + {' '} + {post.tagItems.map(tag => ( + + ))} +
    +
    +
    + + )} + + +
    ) } From 3d678679cf03e644ccbefc260ddfb0b0d0f74f7a Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 29 Apr 2024 16:18:53 +0800 Subject: [PATCH 13/13] =?UTF-8?q?nobelium=20=E9=A1=B6=E9=83=A8=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/nobelium/components/Nav.js | 187 ++++++++++++++++++++---------- themes/nobelium/config.js | 4 +- 2 files changed, 125 insertions(+), 66 deletions(-) diff --git a/themes/nobelium/components/Nav.js b/themes/nobelium/components/Nav.js index 38253b43ac7..a30618ed4a0 100644 --- a/themes/nobelium/components/Nav.js +++ b/themes/nobelium/components/Nav.js @@ -1,24 +1,31 @@ -import { useEffect, useRef, useState } from 'react' -import Link from 'next/link' +import Collapse from '@/components/Collapse' +import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' +import Link from 'next/link' +import { useEffect, useRef, useState } from 'react' import CONFIG from '../config' -import { SvgIcon } from './SvgIcon' -import { MenuItemDrop } from './MenuItemDrop' -import Collapse from '@/components/Collapse' import { MenuItemCollapse } from './MenuItemCollapse' -import LazyImage from '@/components/LazyImage' +import { MenuItemDrop } from './MenuItemDrop' import RandomPostButton from './RandomPostButton' import SearchButton from './SearchButton' -import { siteConfig } from '@/lib/config' - +import { SvgIcon } from './SvgIcon' +/** + * 顶部导航 + */ const Nav = props => { const { navBarTitle, fullWidth, siteInfo } = props - const useSticky = !JSON.parse(siteConfig('NOBELIUM_AUTO_COLLAPSE_NAV_BAR', true)) + const autoCollapseNavBar = siteConfig( + 'NOBELIUM_AUTO_COLLAPSE_NAV_BAR', + true, + CONFIG + ) + const navRef = useRef(null) const sentinalRef = useRef([]) const handler = ([entry]) => { - if (navRef && navRef.current && useSticky) { - if (!entry.isIntersecting && entry !== undefined) { + if (navRef && navRef.current && autoCollapseNavBar) { + if (!entry?.isIntersecting) { navRef.current?.classList.add('sticky-nav-full') } else { navRef.current?.classList.remove('sticky-nav-full') @@ -34,42 +41,46 @@ const Nav = props => { if (sentinalRef.current) obvserver.unobserve(sentinalRef.current) } }, [sentinalRef]) - return <> -
    -