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 e0d92f83d5e..1df9f9115e1 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,12 +24,16 @@ 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/' + @@ -60,7 +66,11 @@ const mapImgUrl = (img, block, type = 'block', from = 'post') => { } // 图片url优化,确保每一篇文章的图片url唯一 - if (ret && ret.length > 4) { + 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) } diff --git a/next.config.js b/next.config.js index f4352e6e9dd..d8a6c2baadc 100644 --- a/next.config.js +++ b/next.config.js @@ -69,6 +69,7 @@ const nextConfig = { 'ko-fi.com' ] }, + // 默认将feed重定向至 /public/rss/feed.xml async redirects() { return [ 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')} +
) 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 ( - ) } 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')} +
    ) 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/components/MenuItemDrop.js b/themes/matery/components/MenuItemDrop.js index f7373f7c328..93dfe7c6d2b 100644 --- a/themes/matery/components/MenuItemDrop.js +++ b/themes/matery/components/MenuItemDrop.js @@ -1,6 +1,9 @@ import Link from 'next/link' import { useState } from 'react' - +/** + * 菜单 + * 支持二级展开的菜单 + */ export const MenuItemDrop = ({ link }) => { const [show, changeShow] = useState(false) const hasSubMenu = link?.subMenus?.length > 0 @@ -42,7 +45,7 @@ export const MenuItemDrop = ({ link }) => { 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 ( ) } 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 } 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 && } 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 <> -
    -