previewLine设置

This commit is contained in:
tangly1024
2022-01-25 17:44:49 +08:00
parent 13f53b2bad
commit ddd38a6745
10 changed files with 30 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { LayoutIndex } from '@/themes'
import { LayoutIndex, THEME_CONFIG } from '@/themes'
const Index = (props) => {
return <LayoutIndex {...props}/>
@@ -26,11 +26,14 @@ export async function getStaticProps () {
BLOG.POSTS_PER_PAGE * (page - 1),
BLOG.POSTS_PER_PAGE * page
)
for (const i in postsToShow) {
const post = postsToShow[i]
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
if (blockMap) {
post.blockMap = blockMap
if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) {
console.log('加载预览')
for (const i in postsToShow) {
const post = postsToShow[i]
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
if (blockMap) {
post.blockMap = blockMap
}
}
}
}

View File

@@ -1,7 +1,7 @@
import BLOG from '@/blog.config'
import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { LayoutPage } from '@/themes'
import { LayoutPage, THEME_CONFIG } from '@/themes'
import Custom404 from '@/pages/404'
const Page = (props) => {
@@ -42,12 +42,15 @@ export async function getStaticProps ({ params: { page } }) {
BLOG.POSTS_PER_PAGE * (page - 1),
BLOG.POSTS_PER_PAGE * page
)
for (const i in postsToShow) {
const post = postsToShow[i]
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
if (blockMap) {
post.blockMap = blockMap
// 加载预览
if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) {
console.log('加载预览')
for (const i in postsToShow) {
const post = postsToShow[i]
const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES)
if (blockMap) {
post.blockMap = blockMap
}
}
}