mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-21 15:09:43 +00:00
Merge branch 'main' into feat/algolia
This commit is contained in:
@@ -21,24 +21,11 @@ export function GlobalContextProvider({ children }) {
|
||||
const [theme, setTheme] = useState(BLOG.THEME) // 默认博客主题
|
||||
const [isDarkMode, updateDarkMode] = useState(BLOG.APPEARANCE === 'dark') // 默认深色模式
|
||||
const [onLoading, setOnLoading] = useState(false) // 抓取文章数据
|
||||
// const [onReading, setOnReading] = useState(false) // 网页资源加载
|
||||
|
||||
useEffect(() => {
|
||||
initLocale(lang, locale, updateLang, updateLocale)
|
||||
initDarkMode(isDarkMode, updateDarkMode)
|
||||
initTheme()
|
||||
if (isBrowser()) {
|
||||
// 监听用户刷新页面
|
||||
const handleBeforeUnload = (event) => {
|
||||
// setOnReading(true)
|
||||
}
|
||||
// 监听页面元素加载完
|
||||
// setOnReading(false)
|
||||
window.addEventListener('beforeunload', handleBeforeUnload)
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', handleBeforeUnload)
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -72,7 +59,8 @@ export function GlobalContextProvider({ children }) {
|
||||
const currentIndex = THEMES.indexOf(theme)
|
||||
const newIndex = currentIndex < THEMES.length - 1 ? currentIndex + 1 : 0
|
||||
const newTheme = THEMES[newIndex]
|
||||
const query = { ...router.query, theme: newTheme }
|
||||
const query = router.query
|
||||
query.theme = newTheme
|
||||
router.push({ pathname: router.pathname, query })
|
||||
return newTheme
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
export default {
|
||||
LOCALE: 'en-US',
|
||||
MENU: {
|
||||
WALK_AROUND: 'Walk Around',
|
||||
CATEGORY: 'Category',
|
||||
TAGS: 'Tags',
|
||||
COPY_URL: 'Copy URL',
|
||||
DARK_MODE: 'Dark Mode',
|
||||
LIGHT_MODE: 'Light Mode',
|
||||
THEME_SWITCH: 'Theme Switch'
|
||||
},
|
||||
NAV: {
|
||||
INDEX: 'Blog',
|
||||
INDEX: 'Home',
|
||||
RSS: 'RSS',
|
||||
SEARCH: 'Search',
|
||||
ABOUT: 'About',
|
||||
@@ -35,6 +44,7 @@ export default {
|
||||
SUBMIT: 'Submit',
|
||||
POST_TIME: 'Post on',
|
||||
LAST_EDITED_TIME: 'Last edited',
|
||||
COMMENTS: 'Comments',
|
||||
RECENT_COMMENTS: 'Recent Comments',
|
||||
DEBUG_OPEN: 'Debug',
|
||||
DEBUG_CLOSE: 'Close',
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
export default {
|
||||
LOCALE: 'zh-CN',
|
||||
MENU: {
|
||||
WALK_AROUND: '随便逛逛',
|
||||
CATEGORY: '博客分类',
|
||||
TAGS: '博客标签',
|
||||
COPY_URL: '复制地址',
|
||||
DARK_MODE: '深色模式',
|
||||
LIGHT_MODE: '浅色模式',
|
||||
THEME_SWITCH: '主题切换'
|
||||
},
|
||||
NAV: {
|
||||
INDEX: '首页',
|
||||
RSS: '订阅',
|
||||
@@ -12,7 +21,7 @@ export default {
|
||||
COMMON: {
|
||||
MORE: '更多',
|
||||
NO_MORE: '没有更多了',
|
||||
LATEST_POSTS: '最新文章',
|
||||
LATEST_POSTS: '最新发布',
|
||||
TAGS: '标签',
|
||||
NO_TAG: 'NoTag',
|
||||
CATEGORY: '分类',
|
||||
@@ -37,6 +46,7 @@ export default {
|
||||
SUBMIT: '提交',
|
||||
POST_TIME: '发布于',
|
||||
LAST_EDITED_TIME: '最后更新',
|
||||
COMMENTS: '评论',
|
||||
RECENT_COMMENTS: '最新评论',
|
||||
DEBUG_OPEN: '开启调试',
|
||||
DEBUG_CLOSE: '关闭调试',
|
||||
@@ -47,8 +57,8 @@ export default {
|
||||
WORD_COUNT: '字数'
|
||||
},
|
||||
PAGINATION: {
|
||||
PREV: '上一页',
|
||||
NEXT: '下一页'
|
||||
PREV: '上页',
|
||||
NEXT: '下页'
|
||||
},
|
||||
SEARCH: {
|
||||
ARTICLES: '搜索文章',
|
||||
|
||||
@@ -309,7 +309,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
const customNav = getCustomNav({ allPages: collectionData.filter(post => post?.type === 'Page' && post.status === 'Published') })
|
||||
// 新的菜单
|
||||
const customMenu = await getCustomMenu({ collectionData })
|
||||
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 })
|
||||
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 6 })
|
||||
const allNavPages = getNavPages({ allPages })
|
||||
|
||||
return {
|
||||
|
||||
@@ -100,7 +100,6 @@ export default async function getPageProperties(id, block, schema, authToken, ta
|
||||
properties.to = properties.slug ?? null
|
||||
properties.name = properties.title ?? ''
|
||||
}
|
||||
properties.password = properties.password ? md5(properties.slug + properties.password) : ''
|
||||
|
||||
// 开启伪静态路径
|
||||
if (JSON.parse(BLOG.PSEUDO_STATIC)) {
|
||||
@@ -108,6 +107,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta
|
||||
properties.slug += '.html'
|
||||
}
|
||||
}
|
||||
properties.password = properties.password ? md5(properties.slug + properties.password) : ''
|
||||
return properties
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ export async function generateSitemapXml({ allPages }) {
|
||||
changefreq: 'daily'
|
||||
}]
|
||||
|
||||
// 循环页面生成
|
||||
allPages?.forEach(post => {
|
||||
const slugWithoutLeadingSlash = post?.slug?.startsWith('/') ? post?.slug?.slice(1) : post.slug
|
||||
urls.push({
|
||||
loc: `${BLOG.LINK}/${post.slug}`,
|
||||
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
|
||||
lastmod: new Date(post?.publishTime).toISOString().split('T')[0],
|
||||
changefreq: 'daily'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user