mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-04 15:10:23 +00:00
多语言的小调整
This commit is contained in:
@@ -31,7 +31,7 @@ const NotionPage = ({ post, className }) => {
|
|||||||
// 页面首次打开时执行的勾子
|
// 页面首次打开时执行的勾子
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 检测当前的url并自动滚动到对应目标
|
// 检测当前的url并自动滚动到对应目标
|
||||||
autoScrollToTarget()
|
autoScrollToHash()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 页面文章发生变化时会执行的勾子
|
// 页面文章发生变化时会执行的勾子
|
||||||
@@ -144,9 +144,9 @@ const processGalleryImg = zoom => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据url参数自动滚动到指定区域
|
* 根据url参数自动滚动到锚位置
|
||||||
*/
|
*/
|
||||||
const autoScrollToTarget = () => {
|
const autoScrollToHash = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 跳转到指定标题
|
// 跳转到指定标题
|
||||||
const needToJumpToTitle = window.location.hash
|
const needToJumpToTitle = window.location.hash
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ import { siteConfig } from '../config'
|
|||||||
import {
|
import {
|
||||||
checkStartWithHttp,
|
checkStartWithHttp,
|
||||||
convertUrlStartWithOneSlash,
|
convertUrlStartWithOneSlash,
|
||||||
|
getLastSegmentFromUrl,
|
||||||
sliceUrlFromHttp
|
sliceUrlFromHttp
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
import { extractLangPrefix } from '../utils/pageId'
|
||||||
import { mapImgUrl } from './mapImage'
|
import { mapImgUrl } from './mapImage'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,6 +210,18 @@ export function adjustPageProperties(properties, NOTION_CONFIG) {
|
|||||||
properties.target = '_self'
|
properties.target = '_self'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果跳转链接是多语言,则在新窗口打开
|
||||||
|
if (BLOG.NOTION_PAGE_ID.indexOf(',') > 0) {
|
||||||
|
const siteIds = BLOG.NOTION_PAGE_ID.split(',')
|
||||||
|
for (let index = 0; index < siteIds.length; index++) {
|
||||||
|
const siteId = siteIds[index]
|
||||||
|
const prefix = extractLangPrefix(siteId)
|
||||||
|
if (getLastSegmentFromUrl(properties.href) === prefix) {
|
||||||
|
properties.target = '_blank'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 密码字段md5
|
// 密码字段md5
|
||||||
properties.password = properties.password
|
properties.password = properties.password
|
||||||
? md5(properties.slug + properties.password)
|
? md5(properties.slug + properties.password)
|
||||||
|
|||||||
@@ -367,3 +367,16 @@ export const scanAndConvertToLinks = node => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取url最后一个斜杆后面的内容
|
||||||
|
* @param {*} url
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getLastSegmentFromUrl(url) {
|
||||||
|
// 去掉 URL 中的查询参数部分
|
||||||
|
let trimmedUrl = url.split('?')[0]
|
||||||
|
// 获取最后一个斜杠后面的内容
|
||||||
|
let segments = trimmedUrl.split('/')
|
||||||
|
return segments[segments.length - 1]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user