mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
previewLine设置
This commit is contained in:
@@ -19,6 +19,7 @@ const BLOG = {
|
||||
PATH: '', // leave this empty unless you want to deploy in a folder
|
||||
|
||||
POST_LIST_STYLE: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载
|
||||
POST_LIST_PREVIEW: false, // 是否在列表加载文章预览, 会被各主题中的同名配置覆盖,例:/themes/NEXT/config_next.js
|
||||
POST_PREVIEW_LINES: 12, // 预览博客行数
|
||||
POSTS_PER_PAGE: 6, // post counts per page
|
||||
POSTS_SORT_BY: 'notion', // 排序方式 'date'按时间,'notion'由notion控制
|
||||
|
||||
@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
|
||||
import Head from 'next/head'
|
||||
|
||||
const CommonHead = ({ meta }) => {
|
||||
let url = BLOG.PATH.length ? `${BLOG.LINK}/${BLOG.PATH}` : BLOG.LINK
|
||||
let url = BLOG?.PATH?.length ? `${BLOG.LINK}/${BLOG.PATH}` : BLOG.LINK
|
||||
if (meta) {
|
||||
url = `${url}/${meta.slug}`
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ export async function getAllPosts ({ notionPageData, from, includePage = false }
|
||||
|
||||
const data = []
|
||||
const pageIds = getAllPageIds(collectionQuery)
|
||||
if (!pageIds || pageIds.length === 0) {
|
||||
console.warn('页面ID列表为空')
|
||||
}
|
||||
for (let i = 0; i < pageIds.length; i++) {
|
||||
const id = pageIds[i]
|
||||
const properties = (await getPageProperties(id, pageBlock, schema)) || null
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const FUKA_CONFIG = {
|
||||
|
||||
POST_LIST_COVER: true, // 文章列表显示图片封面
|
||||
POST_LIST_PREVIEW: false, // 显示文章预览
|
||||
|
||||
// 菜单
|
||||
MENU_ABOUT: true, // 显示关于
|
||||
@@ -8,5 +9,6 @@ const FUKA_CONFIG = {
|
||||
MENU_TAG: true, // 显示标签
|
||||
MENU_ARCHIVE: true, // 显示归档
|
||||
MENU_SEARCH: true // 显示搜索
|
||||
|
||||
}
|
||||
export default FUKA_CONFIG
|
||||
|
||||
@@ -33,7 +33,7 @@ const BlogPostCard = ({ post, showSummary }) => {
|
||||
{post.summary}
|
||||
</p>}
|
||||
|
||||
{showPreview && post?.blockMap && <div className='overflow-ellipsis truncate'>
|
||||
{showPreview && <div className='overflow-ellipsis truncate'>
|
||||
<NotionRenderer
|
||||
bodyClassName='max-h-full'
|
||||
recordMap={post.blockMap}
|
||||
@@ -61,7 +61,7 @@ const BlogPostCard = ({ post, showSummary }) => {
|
||||
|
||||
</div>
|
||||
|
||||
{CONFIG_HEXO.POST_LIST_COVER && post?.page_cover && (
|
||||
{CONFIG_HEXO.POST_LIST_COVER && !showPreview && post?.page_cover && (
|
||||
<Link href={`${BLOG.PATH}/article/${post.slug}`} passHref>
|
||||
<a className='w-full relative duration-200 rounded-t-xl lg:rounded-r-xl lg:rounded-t-none cursor-pointer transform overflow-hidden'>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
|
||||
@@ -12,7 +12,7 @@ const CONFIG_HEXO = {
|
||||
|
||||
POST_LIST_COVER: true, // 文章封面
|
||||
POST_LIST_SUMMARY: true, // 文章摘要
|
||||
POST_LIST_PREVIEW: false,
|
||||
POST_LIST_PREVIEW: false, // 读取文章预览
|
||||
NAV_TYPE: 'autoCollapse', // ['fixed','autoCollapse','normal'] 分别是固定屏幕顶部、屏幕顶部自动折叠,不固定
|
||||
|
||||
WIDGET_TO_TOP: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import CONFIG_HEXO from './config_hexo'
|
||||
export { LayoutIndex } from './LayoutIndex'
|
||||
export { LayoutSearch } from './LayoutSearch'
|
||||
export { LayoutArchive } from './LayoutArchive'
|
||||
@@ -8,3 +9,4 @@ export { LayoutCategoryIndex } from './LayoutCategoryIndex'
|
||||
export { LayoutPage } from './LayoutPage'
|
||||
export { LayoutTag } from './LayoutTag'
|
||||
export { LayoutTagIndex } from './LayoutTagIndex'
|
||||
export { CONFIG_HEXO as THEME_CONFIG }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import CONFIG_NEXT from './config_next'
|
||||
export { LayoutIndex } from './LayoutIndex'
|
||||
export { LayoutSearch } from './LayoutSearch'
|
||||
export { LayoutArchive } from './LayoutArchive'
|
||||
@@ -8,3 +9,4 @@ export { LayoutCategoryIndex } from './LayoutCategoryIndex'
|
||||
export { LayoutPage } from './LayoutPage'
|
||||
export { LayoutTag } from './LayoutTag'
|
||||
export { LayoutTagIndex } from './LayoutTagIndex'
|
||||
export { CONFIG_NEXT as THEME_CONFIG }
|
||||
|
||||
Reference in New Issue
Block a user