Skip to content

Commit 7459b2a

Browse files
Merge pull request #7303 from AdrianRomanski/docs/use-content-use-case
Document more thoroughly the use case for useContent with current page's headings
1 parent 5661cf0 commit 7459b2a

File tree

1 file changed

+14
-0
lines changed
  • packages/docs/src/routes/docs/(qwikcity)/guides/mdx

1 file changed

+14
-0
lines changed

packages/docs/src/routes/docs/(qwikcity)/guides/mdx/index.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,18 @@ export const Tags = component$(() => {
195195
</ul>
196196
);
197197
});
198+
199+
## `useContent()`
200+
201+
The [`useContent()`](/docs/(qwikcity)/api/index.mdx#usecontent) function retrieves the nearest content information for the current route. The returned object includes:
202+
203+
```ts
204+
headings: ContentHeading[] | undefined;
205+
menu: ContentMenu | undefined;
206+
```
207+
208+
The `headings` array includes data about a markdown file's `<h1>` to `<h6>` [html heading elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements).
209+
210+
Menus are contextual data declared with `menu.md` files. See [menus file definition](/docs/(qwikcity)/advanced/menu/index.mdx) for more information on the file format and location.
211+
198212
```

0 commit comments

Comments
 (0)