From 16a9dcf9310f16966d6f94639d10966811962f29 Mon Sep 17 00:00:00 2001 From: ihavecoke Date: Wed, 19 Jun 2024 10:04:00 +0800 Subject: [PATCH] Fixed highlight words not show in article title --- docusaurus.config.ts | 2 ++ src/theme/DocRoot/Layout/Main/index.tsx | 30 ++++++++++++++++--------- src/utils/highlight.ts | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 06477654e..b415e3f62 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -19,6 +19,7 @@ const ossEnv = isDev ? "/" : proxy; const targetPortalPath = proxy === "canary" ? "https://m.longbridge.xyz" : "https://m.lbkrs.com"; const localAPIProxyPath = "/dev-proxy"; const apiProxyUrl = `${isDev ? localAPIProxyPath : targetPortalPath}/api/forward`; +const portAIProxyUrl = isDev ? 'http://localhost:4040/dev-proxy' : undefined; const config: Config = { title: "LongPort wiki", @@ -34,6 +35,7 @@ const config: Config = { favicon: "https://pub.lbkrs.com/static/offline/202211/qohHsXzN9qtQ23ox/longport_favicon.png", customFields: { isDev, + portAIProxyUrl, apiProxyUrl }, headTags: [ diff --git a/src/theme/DocRoot/Layout/Main/index.tsx b/src/theme/DocRoot/Layout/Main/index.tsx index 6152d9e41..ec7db554e 100644 --- a/src/theme/DocRoot/Layout/Main/index.tsx +++ b/src/theme/DocRoot/Layout/Main/index.tsx @@ -5,30 +5,40 @@ * LICENSE file in the root directory of this source tree. */ -import React from 'react'; -import clsx from 'clsx'; -import {useDocsSidebar} from '@docusaurus/theme-common/internal'; -import type {Props} from '@theme/DocRoot/Layout/Main'; +import React from "react"; +import clsx from "clsx"; +import { useDocsSidebar } from "@docusaurus/theme-common/internal"; +import type { Props } from "@theme/DocRoot/Layout/Main"; -import styles from './styles.module.css'; +import styles from "./styles.module.css"; +import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; export default function DocRootLayoutMain({ hiddenSidebarContainer, children, }: Props): JSX.Element { const sidebar = useDocsSidebar(); + const { + siteConfig: { + customFields: { portAIProxyUrl }, + }, + } = useDocusaurusContext(); + return (
+ (hiddenSidebarContainer || !sidebar) && styles.docMainContainerEnhanced + )} + >
+ hiddenSidebarContainer && styles.docItemWrapperEnhanced + )} + data-proxy={portAIProxyUrl} + > {children}
diff --git a/src/utils/highlight.ts b/src/utils/highlight.ts index 2f0e144e3..ed6a22321 100644 --- a/src/utils/highlight.ts +++ b/src/utils/highlight.ts @@ -12,7 +12,7 @@ export const loadScript = (src) => { let highlightIsLoaded = false export const loadHighlight = async () => { if (!highlightIsLoaded) { - await loadScript('https://assets.lbkrs.com/uploads/e6eebe73-a777-4dc5-b682-a80db1af5554/highlight.js') + await loadScript('https://assets.lbkrs.com/uploads/c6e6f6e9-78ab-42f1-942d-111bdb58d758/index.umd.js') } highlightIsLoaded = true const xHighlights = document.querySelectorAll('.doc-highlight')