You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/src/routes/docs/(qwikcity)/guides/mdx/index.mdx
+166Lines changed: 166 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -210,3 +210,169 @@ The `headings` array includes data about a markdown file's `<h1>` to `<h6>` [htm
210
210
211
211
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.
212
212
213
+
# Dynamic Page Navigation with MDX
214
+
215
+
When working with documentation or content-heavy pages in Qwik City, you often need to generate a table of contents or sidebar navigation based on the page's content. Qwik City provides a built-in solution for this through the `useContent()` hook, which can automatically extract headings from your MDX files.
216
+
217
+
## Using `useContent()` for Page Navigation
218
+
219
+
The `useContent()` hook allows you to access metadata about your current MDX page, including all its headings. This is particularly useful for:
220
+
221
+
- Creating a table of contents for long articles
222
+
- Building dynamic sidebar navigation
223
+
- Implementing "jump to section" functionality
224
+
- Generating progress indicators for article sections
225
+
226
+
Here's a complete example of how to create a dynamic table of contents:
0 commit comments