封装isBroswer()

This commit is contained in:
tlyong1992
2022-05-24 17:01:42 +08:00
parent a324cc127c
commit 8c19d88630
29 changed files with 110 additions and 114 deletions

View File

@@ -5,6 +5,7 @@ import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes'
import React from 'react'
import { useRouter } from 'next/router'
import { isBrowser } from '@/lib/utils'
/**
* 根据notion的slug访问页面针对类型为Page的页面
@@ -20,7 +21,7 @@ const Slug = props => {
changeLoadingState(true)
const router = useRouter()
setTimeout(() => {
if (typeof document !== 'undefined') {
if (isBrowser()) {
const article = document.getElementById('container')
if (!article) {
router.push('/404').then(() => {

View File

@@ -6,6 +6,7 @@ import * as ThemeMap from '@/themes'
import React from 'react'
import { idToUuid } from 'notion-utils'
import { useRouter } from 'next/router'
import { isBrowser } from '@/lib/utils'
/**
* 根据notion的slug访问页面
@@ -21,7 +22,7 @@ const Slug = props => {
changeLoadingState(true)
const router = useRouter()
setTimeout(() => {
if (typeof document !== 'undefined') {
if (isBrowser()) {
const article = document.getElementById('container')
if (!article) {
router.push('/404').then(() => {

View File

@@ -27,7 +27,7 @@ export async function getStaticProps() {
if (BLOG.POST_LIST_STYLE !== 'page') {
postsToShow = Array.from(allPosts)
} else {
postsToShow = allPosts.slice(
postsToShow = allPosts?.slice(
BLOG.POSTS_PER_PAGE * (page - 1),
BLOG.POSTS_PER_PAGE * page
)