移动端平滑滚动;
顶部菜单微调
This commit is contained in:
tangly1024
2021-12-16 13:13:29 +08:00
parent 71cc59f0d1
commit abea65474d
9 changed files with 40 additions and 87 deletions

View File

@@ -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

View File

@@ -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 '>

View File

@@ -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