Merge branch 'main' into fix/hexo_404

This commit is contained in:
tangly1024
2025-04-11 22:34:59 +08:00
committed by GitHub
42 changed files with 1455 additions and 1142 deletions

View File

@@ -245,7 +245,7 @@ async function convertNotionToSiteDate(pageId, from, pageRecordMap) {
})
// Sort by date
if (siteConfig('POSTS_SORT_BY', '', NOTION_CONFIG) === 'date') {
if (siteConfig('POSTS_SORT_BY', null, NOTION_CONFIG) === 'date') {
allPages.sort((a, b) => {
return b?.publishDate - a?.publishDate
})

View File

@@ -17,7 +17,9 @@ export default {
NAVIGATOR: 'NAV',
ABOUT: 'About',
MAIL: 'E-Mail',
ARCHIVE: 'Archive'
ARCHIVE: 'Archive',
PAGE_NOT_FOUND: 'Page Not Found',
PAGE_NOT_FOUND_REDIRECT: 'Page Not Found, Redirecting to Home Page...'
},
COMMON: {
THEME: 'Theme',

View File

@@ -17,7 +17,9 @@ export default {
ABOUT: '关于',
NAVIGATOR: '导航',
MAIL: '邮箱',
ARCHIVE: '归档'
ARCHIVE: '归档',
PAGE_NOT_FOUND: '页面找不到啦',
PAGE_NOT_FOUND_REDIRECT: '页面无法加载,即将返回首页'
},
COMMON: {
THEME: 'Theme',

View File

@@ -1,6 +1,6 @@
import { loadLangFromLocalStorage } from '@/lib/lang'
import { idToUuid } from 'notion-utils'
import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
import { loadLangFromLocalStorage } from '@/lib/lang'
/**
* 处理页面内连接跳转:
@@ -13,12 +13,13 @@ export const convertInnerUrl = allPages => {
}
const allAnchorTags = document
?.getElementById('notion-article')
?.querySelectorAll('a.notion-link')
?.querySelectorAll('a.notion-link, a.notion-collection-card')
if (!allAnchorTags) {
return
}
const { origin, pathname } = window.location;
const { origin, pathname } = window.location
const currentURL = origin + pathname
const currentPathLang = pathname.split('/').filter(Boolean)[0]
const lang = loadLangFromLocalStorage().split(/[-_]/)[0]
@@ -49,5 +50,18 @@ export const convertInnerUrl = allPages => {
anchorTag.target = '_self'
}
}
// 如果链接以#号结尾,则强制在新窗口打开
if (anchorTag.href.endsWith('#')) {
anchorTag.target = '_blank'
}
}
}
for (const anchorTag of allAnchorTags) {
const slug = getLastPartOfUrl(anchorTag.href)
const slugPage = allPages?.find(page => {
return page.slug.indexOf(slug) >= 0
})
if (slugPage) {
}
}
}

View File

@@ -1,5 +1,9 @@
import BLOG from '@/blog.config'
import { getDataFromCache, getOrSetDataWithCache, setDataToCache } from '@/lib/cache/cache_manager'
import {
getDataFromCache,
getOrSetDataWithCache,
setDataToCache
} from '@/lib/cache/cache_manager'
import { deepClone, delay } from '../utils'
import notionAPI from '@/lib/notion/getNotionAPI'
@@ -139,8 +143,7 @@ function convertNotionBlocksToPost(id, blockMap, slice) {
b?.value?.type === 'pdf' ||
b?.value?.type === 'video' ||
b?.value?.type === 'audio') &&
b?.value?.properties?.source?.[0][0] &&
b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0
b?.value?.properties?.source?.[0][0]
) {
const oldUrl = b?.value?.properties?.source?.[0][0]
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`

View File

@@ -1,5 +1,6 @@
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
export const pageview = (url, ANALYTICS_GOOGLE_ID) => {
if (window.gtag === undefined) { return }
window.gtag('config', ANALYTICS_GOOGLE_ID, {
page_path: url
})
@@ -7,6 +8,7 @@ export const pageview = (url, ANALYTICS_GOOGLE_ID) => {
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
export const event = ({ action, category, label, value }) => {
if (window.gtag === undefined) { return }
window.gtag('event', action, {
event_category: category,
event_label: label,

View File

@@ -6,7 +6,11 @@ import { siteConfig } from './config'
* @param {*} param0
*/
export async function generateSitemapXml({ allPages, NOTION_CONFIG }) {
const link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG)
let link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG)
// 确保链接不以斜杠结尾
if (link && link.endsWith('/')) {
link = link.slice(0, -1)
}
const urls = [
{
loc: `${link}`,