mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 23:16:54 +00:00
feature:
移动端平滑滚动; 顶部菜单微调
This commit is contained in:
@@ -7,7 +7,6 @@ import 'katex/dist/katex.min.css'
|
||||
import BLOG from 'blog.config'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { GlobalContextProvider } from '@/lib/global'
|
||||
// 解决React-FontAwesome图标问题
|
||||
import { config } from '@fortawesome/fontawesome-svg-core'
|
||||
import '@fortawesome/fontawesome-svg-core/styles.css'
|
||||
config.autoAddCss = false
|
||||
|
||||
@@ -3,7 +3,7 @@ import BLOG from '@/blog.config'
|
||||
import BaseLayout from '@/layouts/BaseLayout'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
import StickyBar from '@/components/StickyBar'
|
||||
import React from 'react'
|
||||
import React, { useEffect } from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import BlogPostArchive from '@/components/BlogPostArchive'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
@@ -55,6 +55,22 @@ const Index = ({ allPosts, tags, categories }) => {
|
||||
}
|
||||
})
|
||||
|
||||
useEffect(
|
||||
() => {
|
||||
if (window) {
|
||||
const anchor = window.location.hash
|
||||
console.log('滚动', anchor)
|
||||
if (anchor) {
|
||||
setTimeout(() => {
|
||||
const anchorElement = document.getElementById(anchor.substring(1))
|
||||
if (anchorElement) { anchorElement.scrollIntoView({ block: 'start', behavior: 'smooth' }) }
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
return (
|
||||
<BaseLayout meta={meta} tags={tags} categories={categories}>
|
||||
<div className=' pt-16 '>
|
||||
|
||||
@@ -30,10 +30,7 @@ const Slug = ({ post, blockMap, tags, prev, next, allPosts, recommendPosts, cate
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
const posts = []
|
||||
// if (BLOG.isProd) {
|
||||
// posts = await getAllPosts({ from: 'slug - paths', includePage: true })
|
||||
// }
|
||||
const posts = await getAllPosts({ from: 'slug - paths', includePage: true })
|
||||
return {
|
||||
paths: posts.map(row => `${BLOG.path}/article/${row.slug}`),
|
||||
fallback: true
|
||||
|
||||
Reference in New Issue
Block a user