From 029ec37341968e4ff69456c3f6e82bfbcc5b7513 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Tue, 17 Jun 2025 17:49:39 +0900 Subject: [PATCH 1/3] Remove unnecessary indenting --- src/components/GlossaryInjector.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/GlossaryInjector.tsx b/src/components/GlossaryInjector.tsx index 9778baca..d5fc28d4 100644 --- a/src/components/GlossaryInjector.tsx +++ b/src/components/GlossaryInjector.tsx @@ -89,14 +89,14 @@ const GlossaryInjector: React.FC = ({ children }) => { while ((match = regex.exec(currentText))) { const matchedText = match[0]; // The full matched text (may include plural suffix). - + // Find the base term from the glossary that matches (without plural). const baseTerm = terms.find(term => matchedText.toLowerCase() === term.toLowerCase() || matchedText.toLowerCase() === `${term.toLowerCase()}s` || matchedText.toLowerCase() === `${term.toLowerCase()}es` ); - + if (!baseTerm) { // Skip if no matching base term found. continue; @@ -116,11 +116,11 @@ const GlossaryInjector: React.FC = ({ children }) => { tooltipWrapper.className = 'glossary-term'; const definition = glossary[baseTerm]; - + // Extract the part to underline (the base term) and the suffix (if plural). let textToUnderline = matchedText; let suffix = ''; - + if (matchedText.toLowerCase() !== baseTerm.toLowerCase()) { // This is a plural form - only underline the base part. const baseTermLength = baseTerm.length; From 4574e50466f182151186442b33b4ed8d121dc00b Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Tue, 17 Jun 2025 18:02:40 +0900 Subject: [PATCH 2/3] Hide glossary tooltips on version home pages --- src/components/GlossaryInjector.tsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/GlossaryInjector.tsx b/src/components/GlossaryInjector.tsx index d5fc28d4..475350c5 100644 --- a/src/components/GlossaryInjector.tsx +++ b/src/components/GlossaryInjector.tsx @@ -30,8 +30,33 @@ const GlossaryInjector: React.FC = ({ children }) => { .catch((err) => console.error('Failed to load glossary:', err)); }, []); + // Function to check if the current page is a version index page + const isVersionIndexPage = () => { + if (typeof window !== 'undefined') { + const path = window.location.pathname; + + // Check for various version index patterns + // English versions + if (path.match(/\/docs\/latest\/?$/) || + path.match(/\/docs\/latest\/index(\.html)?/) || + path.match(/\/docs\/[0-9]+\.[0-9]+\/?$/) || + path.match(/\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) { + return true; + } + + // Japanese versions + if (path.match(/\/ja-jp\/docs\/latest\/?$/) || + path.match(/\/ja-jp\/docs\/latest\/index(\.html)?/) || + path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/?$/) || + path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) { + return true; + } + } + return false; + }; + useEffect(() => { - if (Object.keys(glossary).length === 0) return; + if (Object.keys(glossary).length === 0 || isVersionIndexPage()) return; // Sort terms in descending order by length to prioritize multi-word terms. const terms = Object.keys(glossary).sort((a, b) => b.length - a.length); From 7088f0107ce1b1e49bd401eb95b5f8dce3530ed7 Mon Sep 17 00:00:00 2001 From: Josh Wong <23216828+josh-wong@users.noreply.github.com> Date: Tue, 17 Jun 2025 18:48:05 +0900 Subject: [PATCH 3/3] Streamline handling of version home page languages --- src/components/GlossaryInjector.tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/components/GlossaryInjector.tsx b/src/components/GlossaryInjector.tsx index 475350c5..320c3a1c 100644 --- a/src/components/GlossaryInjector.tsx +++ b/src/components/GlossaryInjector.tsx @@ -36,19 +36,11 @@ const GlossaryInjector: React.FC = ({ children }) => { const path = window.location.pathname; // Check for various version index patterns - // English versions - if (path.match(/\/docs\/latest\/?$/) || - path.match(/\/docs\/latest\/index(\.html)?/) || - path.match(/\/docs\/[0-9]+\.[0-9]+\/?$/) || - path.match(/\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) { - return true; - } - - // Japanese versions - if (path.match(/\/ja-jp\/docs\/latest\/?$/) || - path.match(/\/ja-jp\/docs\/latest\/index(\.html)?/) || - path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/?$/) || - path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) { + const localePrefix = '(?:/ja-jp)?'; // Matches either '/ja-jp' or nothing + if (path.match(new RegExp(`${localePrefix}/docs/latest/?$`)) || + path.match(new RegExp(`${localePrefix}/docs/latest/index(\\.html)?`)) || + path.match(new RegExp(`${localePrefix}/docs/[0-9]+\\.[0-9]+/?$`)) || + path.match(new RegExp(`${localePrefix}/docs/[0-9]+\\.[0-9]+/index(\\.html)?`))) { return true; } }