docs: improved glossary feature (#4819)

This commit is contained in:
Shahed Nasser
2023-08-21 12:31:16 +03:00
committed by GitHub
parent f11375a686
commit 740a3c6e18
11 changed files with 107 additions and 9 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ import SearchMetadata from "@theme/SearchMetadata"
import type { Props } from "@theme/DocPage"
import LearningPathProvider from "@site/src/providers/LearningPath"
import SidebarProvider from "@site/src/providers/Sidebar"
import NotificationProvider from "@site/src/providers/NotificationProvider"
import NotificationProvider from "@site/src/providers/Notification"
import UserProvider from "@site/src/providers/User"
import ModalProvider from "../../providers/Modal"
+5 -3
View File
@@ -1,4 +1,4 @@
import React from "react"
import React, { useMemo } from "react"
import type { Props } from "@theme/MDXComponents/A"
import { getGlossaryByPath } from "../../utils/glossary"
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"
@@ -14,10 +14,12 @@ const MDXA = (props: Props) => {
} = useDocusaurusContext() as MedusaDocusaurusContext
// check if a glossary exists for href
const glossary =
(typeof children === "string" && href.startsWith("/")) || href.includes(url)
const glossary = useMemo(() => {
return (typeof children === "string" && href.startsWith("/")) ||
href.includes(url)
? getGlossaryByPath(children as string)
: null
}, [href, children])
if (!glossary) {
return <Link {...props} />