docs: improvements to API reference intro sections (#9397)

- Improve intro sections of API reference to utilize divided columns
- Improve the content of the intro sections
- Add a new Workflows section to explain the workflows badge and how to use it
- Fixes to headings and add anchor for copying the link to a section
- Fixes responsiveness of intro sections on mobile devices
- Other: fix loading not showing when a sidebar category is opened.

Closes DOCS-932, DOCS-934, DOCS-937

Preview: https://api-reference-v2-git-docs-api-ref-intro-fixes-medusajs.vercel.app/v2/api/store
This commit is contained in:
Shahed Nasser
2024-10-06 16:51:08 +00:00
committed by GitHub
parent d6b452b734
commit 522d3ce764
27 changed files with 1138 additions and 284 deletions
@@ -14,12 +14,14 @@ export type UseActiveOnScrollProps = {
rootElm?: Document | HTMLElement
enable?: boolean
useDefaultIfNoActive?: boolean
maxLevel?: number
}
export const useActiveOnScroll = ({
rootElm,
enable = true,
useDefaultIfNoActive = true,
maxLevel = 3,
}: UseActiveOnScrollProps) => {
const [items, setItems] = useState<ActiveOnScrollItem[]>([])
const [activeItemId, setActiveItemId] = useState("")
@@ -40,12 +42,23 @@ export const useActiveOnScroll = ({
return document
}, [rootElm, isBrowser, enable])
const querySelector = useMemo(() => {
let selector = ""
for (let i = 2; i <= maxLevel; i++) {
if (i > 2) {
selector += `,`
}
selector += `h${i}`
}
return selector
}, [maxLevel])
const getHeadingsInElm = useCallback(() => {
if (!isBrowser || !enable) {
return []
}
return root?.querySelectorAll("h2,h3")
return root?.querySelectorAll(querySelector)
}, [isBrowser, pathname, root, enable])
const setHeadingItems = useCallback(() => {
if (!enable) {