mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
多语言微调
This commit is contained in:
@@ -8,8 +8,15 @@ import { checkStrIsNotionId, getLastPartOfUrl, isBrowser } from '../utils'
|
||||
*/
|
||||
export const convertInnerUrl = allPages => {
|
||||
if (isBrowser) {
|
||||
const allAnchorTags = document
|
||||
?.getElementById('notion-article')
|
||||
?.getElementsByTagName('a')
|
||||
|
||||
if (!allAnchorTags) {
|
||||
return
|
||||
}
|
||||
const currentURL = window.location.origin + window.location.pathname
|
||||
const allAnchorTags = document.getElementsByTagName('a') // 或者使用 document.querySelectorAll('a') 获取 NodeList
|
||||
// url替换成slug
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
// 检查url
|
||||
if (anchorTag?.href) {
|
||||
@@ -24,20 +31,19 @@ export const convertInnerUrl = allPages => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
if (anchorTag?.target === '_blank') {
|
||||
const hrefWithoutQueryHash = anchorTag.href
|
||||
.split('?')[0]
|
||||
.split('#')[0]
|
||||
const hrefWithRelativeHash =
|
||||
currentURL.split('#')[0] || '' + anchorTag.href.split('#')[1] || ''
|
||||
if (
|
||||
currentURL === hrefWithoutQueryHash ||
|
||||
currentURL === hrefWithRelativeHash
|
||||
) {
|
||||
anchorTag.target = '_self'
|
||||
}
|
||||
// 链接在当前页面打开
|
||||
for (const anchorTag of allAnchorTags) {
|
||||
if (anchorTag?.target === '_blank') {
|
||||
const hrefWithoutQueryHash = anchorTag.href.split('?')[0].split('#')[0]
|
||||
const hrefWithRelativeHash =
|
||||
currentURL.split('#')[0] || '' + anchorTag.href.split('#')[1] || ''
|
||||
if (
|
||||
currentURL === hrefWithoutQueryHash ||
|
||||
currentURL === hrefWithRelativeHash
|
||||
) {
|
||||
anchorTag.target = '_self'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ export const MenuItemDrop = ({ link }) => {
|
||||
<div
|
||||
onMouseOver={() => changeShow(true)}
|
||||
onMouseOut={() => changeShow(false)}>
|
||||
{' '}
|
||||
menu-link pl-2 pr-4 no-underline tracking-widest pb-1
|
||||
{/* 不含子菜单 */}
|
||||
{!hasSubMenu && (
|
||||
<Link
|
||||
@@ -22,7 +24,6 @@ export const MenuItemDrop = ({ link }) => {
|
||||
{link?.icon && <i className={link?.icon} />} {link?.name}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{/* 含子菜单的按钮 */}
|
||||
{hasSubMenu && (
|
||||
<>
|
||||
@@ -31,7 +32,6 @@ export const MenuItemDrop = ({ link }) => {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 子菜单 */}
|
||||
{hasSubMenu && (
|
||||
<ul
|
||||
|
||||
Reference in New Issue
Block a user