Skip to Content
🎉 Nextra 4.0 已发布。dimaMachina 正在 寻找新工作或咨询机会 

API

useThemeConfig 钩子

useThemeConfig 钩子返回你的 主题配置 的值,并用于 动态配置你的项目。

import { useThemeConfig } from 'nextra-theme-docs'
Parameters:
This function does not accept any parameters.
Returns:

A subset of your theme configuration context.

NameType
copyPageButtonboolean
darkModeboolean
docsRepositoryBasestring
feedback.contentstring | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null
feedback.labelsstring
i18n{ locale: string; name: string; }[]
lastUpdatedReactElement<unknown, string | JSXElementConstructor<any>>
sidebar.autoCollapseboolean | undefined
sidebar.defaultMenuCollapseLevelnumber
sidebar.defaultOpenboolean
sidebar.toggleButtonboolean
themeSwitch.darkstring
themeSwitch.lightstring
themeSwitch.systemstring
toc.extraContentReactNode
toc.backToTopstring | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null
toc.floatboolean
toc.titlestring | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<...> | null

useConfig 钩子

import { useConfig } from 'nextra-theme-docs'

useConfig 钩子返回当前页面上下文的数据。

Parameters:
This function does not accept any parameters.
Returns:

An object containing the normalizePagesResult and a hideSidebar value.

NameType
normalizePagesResult.activeType"doc" | "page" | "menu"

Active type for current page, used to determine layout in theme.

normalizePagesResult.activeIndexnumber

Active index for current page, used for pagination in combination with flatDocsDirectories items.

normalizePagesResult.activeThemeContext.breadcrumbboolean | undefined
normalizePagesResult.activeThemeContext.collapsedboolean | undefined
normalizePagesResult.activeThemeContext.footerboolean | undefined
normalizePagesResult.activeThemeContext.layout"default" | "full" | undefined
normalizePagesResult.activeThemeContext.navbarboolean | undefined
normalizePagesResult.activeThemeContext.paginationboolean | undefined
normalizePagesResult.activeThemeContext.sidebarboolean | undefined
normalizePagesResult.activeThemeContext.timestampboolean | undefined
normalizePagesResult.activeThemeContext.tocboolean | undefined
normalizePagesResult.activeThemeContext.typesetting"default" | "article" | undefined
normalizePagesResult.activeThemeContext.copyPageboolean
normalizePagesResult.activeMetadataFrontMatter

Parsed front matter  or exported Metadata  from page.

normalizePagesResult.activePathItem[]

Active path for current page, used for breadcrumb navigation.

normalizePagesResult.directoriesItem[]

All directories in the tree structure.

normalizePagesResult.docsDirectoriesDocsItem[]

Directories with type: 'doc' in _meta file.

normalizePagesResult.flatDocsDirectoriesDocsItem[]

Flattened directories with type: 'doc' in _meta file.

normalizePagesResult.topLevelNavbarItems(PageItem | MenuItem)[]

Navbar items, items which have type: 'page' in _meta file.

hideSidebarboolean

Whether the sidebar is shown. If false, the theme and locale switchers are displayed in the <Footer>.

Last updated on