From 73656d16fec7d6e092e23aa510f97ed0207687b2 Mon Sep 17 00:00:00 2001 From: Mercurial Mercenary <119971154+viralgupta@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:09:31 +0530 Subject: [PATCH] FIX: max heading level set to 3/2 for toc (#323) * fix; max heading level set to 2 for toc * fix: fixed toc for pages where heading was greater than 2 --- docs/api/app.md | 1 + docs/api/clipboard.md | 1 + docs/api/computer.md | 1 + docs/api/custom.md | 1 + docs/api/debug.md | 1 + docs/api/error-codes.md | 1 + docs/api/events.md | 1 + docs/api/extensions.md | 1 + docs/api/filesystem.md | 1 + docs/api/global-variables.md | 1 + docs/api/init.md | 1 + docs/api/os.md | 1 + docs/api/overview.md | 1 + docs/api/storage.md | 1 + docs/api/updater.md | 1 + docs/api/window.md | 1 + src/theme/DocItem/TOC/Desktop/index.js | 36 +++++++++++++++----------- 17 files changed, 37 insertions(+), 15 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 48d47581..a346622a 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1,5 +1,6 @@ --- title: Neutralino.app +toc_max_heading_level: 2 --- `Neutralino.app` namespace contains methods related to the current application instance. diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index ab278674..4eeb6776 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -1,5 +1,6 @@ --- title: Neutralino.clipboard +toc_max_heading_level: 2 --- `Neutralino.clipboard` namespace offers functions to access system clipboard. diff --git a/docs/api/computer.md b/docs/api/computer.md index 2affa47e..ec9c7e0a 100644 --- a/docs/api/computer.md +++ b/docs/api/computer.md @@ -1,5 +1,6 @@ --- title: Neutralino.computer +toc_max_heading_level: 2 --- `Neutralino.computer` namespace contains methods related to the user's hardware. diff --git a/docs/api/custom.md b/docs/api/custom.md index 56e35e09..23f467a0 100644 --- a/docs/api/custom.md +++ b/docs/api/custom.md @@ -1,5 +1,6 @@ --- title: Neutralino.custom +toc_max_heading_level: 2 --- Neutralinojs offers the extensions API to write custom backend code with any programming language, diff --git a/docs/api/debug.md b/docs/api/debug.md index 6fe0f19d..19c45d4f 100644 --- a/docs/api/debug.md +++ b/docs/api/debug.md @@ -1,5 +1,6 @@ --- title: Neutralino.debug +toc_max_heading_level: 2 --- `Neutralino.debug` namespace contains application debugging utilities. diff --git a/docs/api/error-codes.md b/docs/api/error-codes.md index 60ea6c29..9122f1ab 100644 --- a/docs/api/error-codes.md +++ b/docs/api/error-codes.md @@ -1,5 +1,6 @@ --- title: Error Codes +toc_max_heading_level: 2 --- If a particular native API call fails, Neutralinojs client library rejects the pending Promise with an error object. diff --git a/docs/api/events.md b/docs/api/events.md index 1f52680c..81b7ea98 100644 --- a/docs/api/events.md +++ b/docs/api/events.md @@ -1,5 +1,6 @@ --- title: Neutralino.events +toc_max_heading_level: 2 --- `Neutralino.events` namespace contains methods related to the native events handling. These events are often initiated diff --git a/docs/api/extensions.md b/docs/api/extensions.md index 1dce7824..a0076656 100644 --- a/docs/api/extensions.md +++ b/docs/api/extensions.md @@ -1,5 +1,6 @@ --- title: Neutralino.extensions +toc_max_heading_level: 2 --- `Neutralino.extensions` namespace contains methods related to Neutralino extensions. Extensions let diff --git a/docs/api/filesystem.md b/docs/api/filesystem.md index f9c173e8..aa8a0b7a 100644 --- a/docs/api/filesystem.md +++ b/docs/api/filesystem.md @@ -1,5 +1,6 @@ --- title: Neutralino.filesystem +toc_max_heading_level: 2 --- `Neutralino.filesystem` namespace contains methods for handling files. diff --git a/docs/api/global-variables.md b/docs/api/global-variables.md index fedbc6b0..4ce77c9b 100644 --- a/docs/api/global-variables.md +++ b/docs/api/global-variables.md @@ -1,5 +1,6 @@ --- title: Global Variables +toc_max_heading_level: 2 --- These JavaScript variables can be used anywhere because these variables are defined in the window scope. diff --git a/docs/api/init.md b/docs/api/init.md index 135ccecf..839246aa 100644 --- a/docs/api/init.md +++ b/docs/api/init.md @@ -1,5 +1,6 @@ --- title: Neutralino.init +toc_max_heading_level: 2 --- `init` is not a namespace, it's a function that initializes a Neutralinojs application. diff --git a/docs/api/os.md b/docs/api/os.md index 08c2b3d1..744b8671 100644 --- a/docs/api/os.md +++ b/docs/api/os.md @@ -1,5 +1,6 @@ --- title: Neutralino.os +toc_max_heading_level: 2 --- `Neutralino.os` namespace contains methods related to the user's operating system. diff --git a/docs/api/overview.md b/docs/api/overview.md index 6d59b8e3..f9caf186 100644 --- a/docs/api/overview.md +++ b/docs/api/overview.md @@ -1,5 +1,6 @@ --- title: Native API Overview +toc_max_heading_level: 2 --- Neutralinojs offers a JavaScript client library (also known as Neutralino.js) for developers to interact diff --git a/docs/api/storage.md b/docs/api/storage.md index 1cadcefa..97516962 100644 --- a/docs/api/storage.md +++ b/docs/api/storage.md @@ -1,5 +1,6 @@ --- title: Neutralino.storage +toc_max_heading_level: 2 --- Neutralinojs has a built-in shared key-value storage. It's like a diff --git a/docs/api/updater.md b/docs/api/updater.md index 6e12538a..17d96eb7 100644 --- a/docs/api/updater.md +++ b/docs/api/updater.md @@ -1,5 +1,6 @@ --- title: Neutralino.updater +toc_max_heading_level: 2 --- `Neutralino.updater` namespace contains methods related to built-in automatic updater. Neutralinojs offers diff --git a/docs/api/window.md b/docs/api/window.md index b86035da..449c96ce 100644 --- a/docs/api/window.md +++ b/docs/api/window.md @@ -1,5 +1,6 @@ --- title: Neutralino.window +toc_max_heading_level: 2 --- The `Neutralino.window` namespace contains methods related to the current native window instance. diff --git a/src/theme/DocItem/TOC/Desktop/index.js b/src/theme/DocItem/TOC/Desktop/index.js index d06757af..15e5bab0 100644 --- a/src/theme/DocItem/TOC/Desktop/index.js +++ b/src/theme/DocItem/TOC/Desktop/index.js @@ -7,11 +7,13 @@ import { useTOCHighlight } from "@docusaurus/theme-common/internal" const LINK_CLASS_NAME = 'table-of-contents__link'; const ACTIVE_LINK_CLASS_NAME = 'table-of-contents__link--active'; const TOP_OFFSET = 100; +const MAX_HEADING_LEVEL = 3; /* eslint-disable jsx-a11y/control-has-associated-label */ function Headings({ toc, isChild, + frontMatter }) { if (!toc) { return null; @@ -21,23 +23,27 @@ function Headings({ className={ isChild ? '' : 'table-of-contents table-of-contents__left-border' }> - {toc.map((heading) => ( -
  • - - -
  • - ))} + {toc.map((heading) => { + const LOCAL_MAX_HEADING_VALUE = frontMatter.toc_max_heading_level ? frontMatter.toc_max_heading_level : MAX_HEADING_LEVEL + if(heading.level > LOCAL_MAX_HEADING_VALUE) return null + return ( +
  • + + +
  • + ) + })} ); } -function CustomTOC({ toc }) { +function CustomTOC({ toc, frontMatter }) { useTOCHighlight({linkClassName: LINK_CLASS_NAME, linkActiveClassName: ACTIVE_LINK_CLASS_NAME, maxHeadingLevel: TOP_OFFSET, minHeadingLevel: 0}); const [isInitialized, setIsInitialized] = useState(false); const [isEthABlocked, setIsEthABlocked] = useState(false) @@ -63,7 +69,7 @@ function CustomTOC({ toc }) { > - + ); } @@ -71,6 +77,6 @@ function CustomTOC({ toc }) { export default function DocItemTOCDesktop() { const {toc, frontMatter} = useDoc(); return ( - + ); }