|
| 1 | +--- |
| 2 | +title: Pages |
| 3 | +summary: Metadata configuration |
| 4 | +show_datetime: true |
| 5 | +--- |
| 6 | + |
| 7 | +Like this page, you can define its title (and subtitle) through front-matter configuration. |
| 8 | + |
| 9 | +```yaml |
| 10 | +title: Pages # title |
| 11 | +summary: Metadata configuration # subtitle |
| 12 | +``` |
| 13 | +
|
| 14 | +You can also define your page title directly with `# Page title` in the markdown content. |
| 15 | + |
| 16 | +## Navigation |
| 17 | + |
| 18 | +The navigation follows bare mkdocs. You should just notice that folders will create categories in the sidebar (or in the top bar when `topbar_sections: true`). |
| 19 | +To sort the sections, you can use the common `00_section_title/` hack. The first numbers sort the folders in the filesystem (so the sections). They are removed by the theme at compile time. |
| 20 | + |
| 21 | +!!! warning "Important" |
| 22 | + `mkdocs-shadcn` has not been extensively tested with highly nested documentation (`d>2`, i.e. `root / folder / folder`). When subfolders are used, we may recommend to activate the [`topbar_sections`](./get_started.md#topbar_sections-bool) option in the theme configuration. This will display the top level sections in the top bar. |
| 23 | + |
| 24 | +In addition, two other attributes may help to configure pages within the sidebar. |
| 25 | + |
| 26 | +```yaml |
| 27 | +order: 2 |
| 28 | +sidebar_title: Navigation title |
| 29 | +``` |
| 30 | + |
| 31 | +The `order` attribute may help to change the rank of the page in the sidebar (without setting the `nav` setting in `mkdocs.yml`). By default, mkdocs ranks pages through alphabetical order. We keep this behavior if `order` is not set. Let us take this example: |
| 32 | + |
| 33 | +```ini |
| 34 | +| a.md ; order not set |
| 35 | +| b.md ; order: 42 |
| 36 | +| c.md ; order: 0 |
| 37 | +| d.md ; order not set |
| 38 | +``` |
| 39 | + |
| 40 | +After a first pass we will have |
| 41 | + |
| 42 | +```ini |
| 43 | +| a.md ; order: 0 |
| 44 | +| b.md ; order: 42 |
| 45 | +| c.md ; order: 0 |
| 46 | +| d.md ; order: 1 |
| 47 | +``` |
| 48 | + |
| 49 | +So in the sidebar we will get `a.md`, `c.md`, `d.md` and `b.md`. |
| 50 | + |
| 51 | +!!! danger "Caveat" |
| 52 | + The sidebar order does not change the internal navigation order. It implies that `previous` and `next` pages are unlikely to match a custom order. To prevent that, either use the classical `00_page.md`, `01_page.md`, `02_page.md` ... file pattern in your folder or set the navigation in `mkdocs.yml`. |
| 53 | + |
| 54 | +## External links |
| 55 | + |
| 56 | +You can add external links (like "API Reference") in the page header. This is done through the `external_links` attribute in the front-matter. |
| 57 | + |
| 58 | +```yaml |
| 59 | +external_links: |
| 60 | + "API Reference": https://ui.shadcn.com/docs/components |
| 61 | + GitHub: https://github.com/asiffer/mkdocs-shadcn |
| 62 | +``` |
| 63 | + |
| 64 | +## SEO |
| 65 | + |
| 66 | +The following attributes are supported for SEO (`<meta>` attributes in the `<head>`). |
| 67 | + |
| 68 | +```yaml |
| 69 | +description: Extra page description |
| 70 | +keywords: mkdocs,shadcn |
| 71 | +author: asiffer |
| 72 | +image: https://raw.githubusercontent.com/asiffer/mkdocs-shadcn/refs/heads/master/.github/assets/logo.svg |
| 73 | +``` |
| 74 | + |
| 75 | +## Extra |
| 76 | + |
| 77 | +As we may find in [shadcn/ui](https://ui.shadcn.com/docs), we can add a `NEW` tag in the sidebar |
| 78 | +(`Alpha` and `Beta` are also available). |
| 79 | + |
| 80 | +```yaml |
| 81 | +new: true |
| 82 | +# beta: true |
| 83 | +# alpha: true |
| 84 | +``` |
| 85 | + |
| 86 | +The [`show_datetime` theme option](./get_started.md#show_datetime-bool) can be overriden per page |
| 87 | +if you want to show/hide the last update date for a specific page. |
| 88 | + |
| 89 | +```yaml |
| 90 | +show_datetime: true |
| 91 | +``` |
| 92 | + |
| 93 | + |
| 94 | +Finally you an also load per-page CSS and JS files. This is done through the `extra_css` and `extra_javascript` attributes. |
| 95 | + |
| 96 | +```yaml |
| 97 | +extra_css: |
| 98 | + - css/custom.css |
| 99 | +extra_javascript: |
| 100 | + - js/custom.js |
| 101 | +``` |
| 102 | + |
| 103 | +## Example |
| 104 | + |
| 105 | +```yaml |
| 106 | +title: Demo page |
| 107 | +summary: Example page for mkdocs-shadcn users |
| 108 | +new: true |
| 109 | +description: Example page for mkdocs-shadcn users |
| 110 | +keywords: mkdocs,shadcn,demo |
| 111 | +author: asiffer |
| 112 | +image: https://raw.githubusercontent.com/asiffer/mkdocs-shadcn/refs/heads/master/.github/assets/logo.svg |
| 113 | +order: 5 |
| 114 | +sidebar_title: Demo |
| 115 | +show_datetime: false |
| 116 | +external_links: |
| 117 | + "API Reference": https://ui.shadcn.com/docs/components |
| 118 | + GitHub: "https://github.com/asiffer/mkdocs-shadcn" |
| 119 | +extra_css: |
| 120 | + - css/custom-style.css |
| 121 | +extra_javascript: |
| 122 | + - js/custom-script.js |
| 123 | +``` |
0 commit comments