mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 07:26:47 +00:00
NEXT主题-fontawesome改成引用CDN
This commit is contained in:
59
pages/[slug].js
Normal file
59
pages/[slug].js
Normal file
@@ -0,0 +1,59 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { LayoutSlug } from '@/themes'
|
||||
import Custom404 from '@/pages/404'
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面,针对类型为Page的页面
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const Slug = (props) => {
|
||||
if (!props.post) {
|
||||
return <Custom404 {...props} />
|
||||
}
|
||||
return <LayoutSlug {...props} showArticleInfo={false}/>
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
if (!BLOG.isProd) {
|
||||
return {
|
||||
paths: [],
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
const from = 'slug-paths'
|
||||
const { allPosts } = await getGlobalNotionData({ from, pageType: ['Page'] })
|
||||
return {
|
||||
paths: allPosts.map(row => ({ params: { slug: row.slug } })),
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStaticProps ({ params: { slug } }) {
|
||||
const from = `slug-props-${slug}`
|
||||
const { allPosts, categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from, pageType: ['Page'] })
|
||||
|
||||
const post = allPosts.find(p => p.slug === slug)
|
||||
if (!post) {
|
||||
return { props: {}, revalidate: 1 }
|
||||
}
|
||||
|
||||
post.blockMap = await getPostBlocks(post.id, 'slug')
|
||||
|
||||
return {
|
||||
props: {
|
||||
post,
|
||||
tags,
|
||||
categories,
|
||||
postCount,
|
||||
latestPosts,
|
||||
customNav
|
||||
},
|
||||
revalidate: 1
|
||||
}
|
||||
}
|
||||
|
||||
export default Slug
|
||||
@@ -14,9 +14,6 @@ import 'prismjs/themes/prism-okaidia.css'
|
||||
import 'katex/dist/katex.min.css'
|
||||
import dynamic from 'next/dynamic'
|
||||
import { GlobalContextProvider } from '@/lib/global'
|
||||
import { config } from '@fortawesome/fontawesome-svg-core'
|
||||
import '@fortawesome/fontawesome-svg-core/styles.css'
|
||||
config.autoAddCss = false
|
||||
|
||||
const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false })
|
||||
const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false })
|
||||
@@ -30,6 +27,7 @@ const MyApp = ({ Component, pageProps }) => {
|
||||
{BLOG.ANALYTICS_GOOGLE_ID && <Gtag />}
|
||||
{JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && <Busuanzi/>}
|
||||
{BLOG.ADSENSE_GOOGLE_ID && <GoogleAdsense/>}
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossOrigin="anonymous" referrerPolicy="no-referrer" />
|
||||
<Component {...pageProps} />
|
||||
</GlobalContextProvider>
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function getStaticProps () {
|
||||
latestPosts
|
||||
} = await getGlobalNotionData({
|
||||
from,
|
||||
includePage: true
|
||||
pageType: ['Page']
|
||||
})
|
||||
const post = allPosts.find(p => p.slug === 'about')
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const Slug = (props) => {
|
||||
if (!props.post) {
|
||||
return <Custom404 {...props} />
|
||||
}
|
||||
return <LayoutSlug {...props} />
|
||||
return <LayoutSlug {...props} showArticleInfo={true}/>
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
@@ -25,7 +25,7 @@ export async function getStaticPaths () {
|
||||
}
|
||||
|
||||
const from = 'slug-paths'
|
||||
const { allPosts } = await getGlobalNotionData({ from, includePage: true })
|
||||
const { allPosts } = await getGlobalNotionData({ from })
|
||||
return {
|
||||
paths: allPosts.map(row => ({ params: { slug: row.slug } })),
|
||||
fallback: true
|
||||
@@ -34,8 +34,8 @@ export async function getStaticPaths () {
|
||||
|
||||
export async function getStaticProps ({ params: { slug } }) {
|
||||
const from = `slug-props-${slug}`
|
||||
const { allPosts, categories, tags, postCount, latestPosts } =
|
||||
await getGlobalNotionData({ from, includePage: true })
|
||||
const { customNav, allPosts, categories, tags, postCount, latestPosts } =
|
||||
await getGlobalNotionData({ from })
|
||||
|
||||
const post = allPosts.find(p => p.slug === slug)
|
||||
|
||||
@@ -61,7 +61,8 @@ export async function getStaticProps ({ params: { slug } }) {
|
||||
recommendPosts,
|
||||
categories,
|
||||
postCount,
|
||||
latestPosts
|
||||
latestPosts,
|
||||
customNav
|
||||
},
|
||||
revalidate: 1
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const Index = (props) => {
|
||||
|
||||
export async function getStaticProps () {
|
||||
const from = 'index'
|
||||
const { allPosts, latestPosts, categories, tags, postCount } = await getGlobalNotionData({ from })
|
||||
const { allPosts, latestPosts, categories, tags, postCount, customNav } = await getGlobalNotionData({ from, pageType: ['Post'] })
|
||||
const meta = {
|
||||
title: `${BLOG.TITLE}`,
|
||||
description: BLOG.DESCRIPTION,
|
||||
@@ -45,7 +45,8 @@ export async function getStaticProps () {
|
||||
postCount,
|
||||
tags,
|
||||
categories,
|
||||
meta
|
||||
meta,
|
||||
customNav
|
||||
},
|
||||
revalidate: 1
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function getStaticProps () {
|
||||
tags,
|
||||
postCount,
|
||||
latestPosts
|
||||
} = await getGlobalNotionData({ from: 'search-props' })
|
||||
} = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] })
|
||||
return {
|
||||
props: {
|
||||
posts: allPosts,
|
||||
|
||||
@@ -50,10 +50,7 @@ function getTagNames (tags) {
|
||||
|
||||
export async function getStaticPaths () {
|
||||
const from = 'tag-static-path'
|
||||
const { tags } = await getGlobalNotionData({
|
||||
from,
|
||||
tagsCount: 0
|
||||
})
|
||||
const { tags } = await getGlobalNotionData({ from, tagsCount: 0 })
|
||||
const tagNames = getTagNames(tags)
|
||||
|
||||
return {
|
||||
|
||||
@@ -8,16 +8,7 @@ const TagIndex = (props) => {
|
||||
|
||||
export async function getStaticProps () {
|
||||
const from = 'tag-index-props'
|
||||
const {
|
||||
categories,
|
||||
tags,
|
||||
postCount,
|
||||
latestPosts
|
||||
} = await getGlobalNotionData({
|
||||
from,
|
||||
includePage: false,
|
||||
tagsCount: 0
|
||||
})
|
||||
const { categories, tags, postCount, latestPosts } = await getGlobalNotionData({ from, tagsCount: 0 })
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user