API
useThemeConfig 钩子
useThemeConfig 钩子返回你的
主题配置 的值,并用于
动态配置你的项目。
import { useThemeConfig } from 'nextra-theme-docs'A subset of your theme configuration context.
| Name | Type |
|---|---|
copyPageButton | boolean |
darkMode | boolean |
docsRepositoryBase | string |
editLink | string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null |
feedback.link | string | undefined |
feedback.content | string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null |
feedback.labels | string |
i18n | { locale: string; name: string; }[] |
lastUpdated | ReactElement<unknown, string | JSXElementConstructor<any>> |
navigation | boolean | { next: boolean; prev: boolean; } |
search | string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null |
sidebar.autoCollapse | boolean | undefined |
sidebar.defaultMenuCollapseLevel | number |
sidebar.defaultOpen | boolean |
sidebar.toggleButton | boolean |
themeSwitch.dark | string |
themeSwitch.light | string |
themeSwitch.system | string |
toc.extraContent | ReactNode |
toc.backToTop | string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null |
toc.float | boolean |
toc.title | string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null |
useConfig 钩子
import { useConfig } from 'nextra-theme-docs'useConfig 钩子返回当前页面上下文的数据。
An object containing the normalizePagesResult and a hideSidebar value.
| Name | Type |
|---|---|
normalizePagesResult.activeType | "doc" | "page" | "menu"Active type for current page, used to determine layout in theme. |
normalizePagesResult.activeIndex | numberActive index for current page, used for pagination in combination with |
normalizePagesResult.activeThemeContext.breadcrumb | boolean | undefined |
normalizePagesResult.activeThemeContext.collapsed | boolean | undefined |
normalizePagesResult.activeThemeContext.footer | boolean | undefined |
normalizePagesResult.activeThemeContext.layout | "default" | "full" | undefined |
normalizePagesResult.activeThemeContext.navbar | boolean | undefined |
normalizePagesResult.activeThemeContext.pagination | boolean | undefined |
normalizePagesResult.activeThemeContext.sidebar | boolean | undefined |
normalizePagesResult.activeThemeContext.timestamp | boolean | undefined |
normalizePagesResult.activeThemeContext.toc | boolean | undefined |
normalizePagesResult.activeThemeContext.typesetting | "default" | "article" | undefined |
normalizePagesResult.activeThemeContext.copyPage | boolean |
normalizePagesResult.activeMetadata | FrontMatterParsed front matter or exported Metadata from page. |
normalizePagesResult.activePath | Item[]Active path for current page, used for breadcrumb navigation. |
normalizePagesResult.directories | Item[]All directories in the tree structure. |
normalizePagesResult.docsDirectories | DocsItem[]Directories with |
normalizePagesResult.flatDocsDirectories | DocsItem[]Flattened directories with |
normalizePagesResult.topLevelNavbarItems | (PageItem | MenuItem)[]Navbar items, items which have |
hideSidebar | booleanWhether the sidebar is shown. If |