Merge branch 'main' into pr/noeFly/3223

This commit is contained in:
tangly1024
2025-04-11 18:18:17 +08:00
17 changed files with 243 additions and 106 deletions

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,20 +1,18 @@
import { idToUuid } from 'notion-utils'
import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
import { getCurrentLang } from '@/lib/lang'
import BLOG from '@/blog.config'
/**
* 处理页面内连接跳转:
* 1.若是本站域名,则在当前窗口打开、不开新窗口
* 2.url是notion-id转成站内文章链接
*/
export const convertInnerUrl = ({allPages,lang}) => {
export const convertInnerUrl = ({ allPages, lang }) => {
if (!isBrowser) {
return
}
const allAnchorTags = document
?.getElementById('notion-article')
?.querySelectorAll('a.notion-link')
?.querySelectorAll('a.notion-link, a.notion-collection-card')
if (!allAnchorTags) {
return
@@ -49,5 +47,19 @@ export const convertInnerUrl = ({allPages,lang}) => {
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,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,