-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
412 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'starlight-sidebar-topics': minor | ||
--- | ||
|
||
Adds a new [`exclude`](https://starlight-sidebar-topics.netlify.app/docs/configuration#exclude) plugin configuration option to exclude pages from any topic. | ||
|
||
This options can be useful for custom pages that use a custom site navigation sidebar which do not belong to any topic. Excluded pages will use the built-in Starlight sidebar and not render a list of topics. | ||
|
||
See the [“Excluded Pages”](https://starlight-sidebar-topics.netlify.app/docs/guides/excluded-pages) guide to learn more about how to exclude content pages from any topic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Excluded with sidebar | ||
pagefind: false | ||
--- | ||
|
||
This page is not listed in any topic sidebar configuration, is not associated any topic through the `topic` frontmatter field, and is also excluded in the plugin configuration. | ||
|
||
See the [“Excluded Pages”](/docs/guides/excluded-pages) guide to learn how to exclude content pages from any topic. | ||
|
||
:::note | ||
This page exists solely for demonstration purposes and contains no useful information. | ||
See the Starlight Sidebar Topics plugin [documentation](/docs/getting-started/) for more information. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Excluded without sidebar | ||
pagefind: false | ||
--- | ||
|
||
This page using the `splash` template is not listed in any topic sidebar configuration, is not associated with any topic through the `topic` frontmatter field, and is also excluded in the plugin configuration. | ||
|
||
:::note | ||
This page exists solely for demonstration purposes and contains no useful information. | ||
See the Starlight Sidebar Topics plugin [documentation](/docs/getting-started/) for more information. | ||
::: |
2 changes: 1 addition & 1 deletion
2
docs/src/content/docs/demo/secrets/page.mdx → docs/src/content/docs/demo/unlisted/page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Secrets with sidebar | ||
title: Unlisted with sidebar | ||
topic: demo | ||
pagefind: false | ||
--- | ||
|
2 changes: 1 addition & 1 deletion
2
.../src/content/docs/demo/secrets/splash.mdx → ...src/content/docs/demo/unlisted/splash.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: Secrets without sidebar | ||
title: Unlisted without sidebar | ||
template: splash | ||
pagefind: false | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: Excluded Pages | ||
description: Learn how to exclude content pages from any topic. | ||
--- | ||
|
||
By default, the Starlight Sidebar Topics plugin expect that every pages in your project is associated with a topic. | ||
This is done by including the page in a [topic sidebar configuration](/docs/configuration#items) or using the `topic` frontmatter field for [unlisted pages](/docs/guides/unlisted-pages/). | ||
|
||
However, there are cases where you may have [custom pages](https://starlight.astro.build/guides/pages/#custom-pages) that use a [custom site navigation sidebar](https://starlight.astro.build/guides/pages/#sidebar) which do not belong to any topic. | ||
Excluding these pages from any topic will prevent the plugin from rendering a list of topics in the sidebar and use the built-in Starlight sidebar instead. | ||
|
||
## Exclude pages | ||
|
||
To exclude some pages from any topic, you can use the [`exclude`](/docs/configuration#exclude) plugin configuration option. | ||
|
||
```js {20} | ||
// astro.config.mjs | ||
// @ts-check | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
import starlightSidebarTopics from 'starlight-sidebar-topics' | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
starlight({ | ||
plugins: [ | ||
starlightSidebarTopics( | ||
[ | ||
{ | ||
label: 'Guides', | ||
link: '/guides/', | ||
items: ['guides/concepts', 'guides/courses'], | ||
}, | ||
], | ||
{ | ||
exclude: ['/changelog', '/changelog/**/*'], | ||
}, | ||
), | ||
], | ||
title: 'My Docs', | ||
}), | ||
], | ||
}) | ||
``` | ||
|
||
For example, given the above configuration and following file structure: | ||
|
||
import { FileTree } from '@astrojs/starlight/components' | ||
|
||
<FileTree> | ||
|
||
- src/ | ||
- content/ | ||
- docs/ | ||
- guides/ | ||
- concepts.md | ||
- courses.md | ||
- pages/ | ||
- changelog.astro | ||
- … | ||
|
||
</FileTree> | ||
|
||
And the `changelog.astro` page content rendering the following custom page with a custom site navigation sidebar: | ||
|
||
```astro title="src/pages/changelog.astro" {3-7} | ||
<StarlightPage | ||
frontmatter={{ title: 'Changelog' }} | ||
sidebar={[ | ||
{ label: 'v3.0.0', link: '/changelog/v3-0-0/' }, | ||
{ label: 'v2.0.0', link: '/changelog/v2-0-0/' }, | ||
{ label: 'v1.0.0', link: '/changelog/v1-0-0/' }, | ||
]} | ||
> | ||
… | ||
</StarlightPage> | ||
``` | ||
|
||
Visiting the `guides/concepts` and `guides/courses` pages will display the sidebar of the "Guides" topic while the `changelog` page will use the custom site navigation sidebar defined in the `changelog.astro` page using the built-in Starlight sidebar. | ||
|
||
- `guides/concepts` and `guides/courses` are explicitly listed in the "Guides" topic sidebar configuration under the [`items`](/docs/configuration#items) key. | ||
- `changelog` is excluded from any topic using the [`exclude`](/docs/configuration#exclude) plugin configuration option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import { Aside } from '@astrojs/starlight/components' | ||
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro' | ||
--- | ||
|
||
<StarlightPage frontmatter={{ title: 'Custom - Excluded without sidebar' }} sidebar={[]} hasSidebar={false}> | ||
<p> | ||
This custom page with <code>hasSidebar</code> set to <code>false</code> is not listed in any topic sidebar configuration, | ||
is not associated with any topic through the <code>topic</code> frontmatter field, and is also excluded in the plugin | ||
configuration. | ||
</p> | ||
<Aside> | ||
This page exists solely for demonstration purposes and contains no useful information. See the Starlight Sidebar | ||
Topics plugin <a href="/docs/getting-started/">documentation</a> for more information. | ||
</Aside> | ||
</StarlightPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
import { Aside } from '@astrojs/starlight/components' | ||
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro' | ||
--- | ||
|
||
<StarlightPage | ||
frontmatter={{ title: 'Custom - Excluded without sidebar' }} | ||
sidebar={[ | ||
{ label: 'Home', link: '/' }, | ||
{ | ||
label: 'Start Here', | ||
items: ['docs/getting-started', 'docs/configuration'], | ||
}, | ||
{ label: 'Demo', link: '/demo/' }, | ||
]} | ||
> | ||
<p> | ||
This custom page with a custom <code>sidebar</code> is not listed in any topic sidebar configuration, is not associated | ||
with any topic through the <code>topic</code> frontmatter field, and is also excluded in the plugin configuration. | ||
</p> | ||
<p> | ||
See the <a href="/docs/guides/excluded-pages/">“Excluded Pages”</a> guide to learn how to exclude content pages from | ||
any topic. | ||
</p> | ||
<Aside> | ||
This page exists solely for demonstration purposes and contains no useful information. See the Starlight Sidebar | ||
Topics plugin <a href="/docs/getting-started/">documentation</a> for more information. | ||
</Aside> | ||
</StarlightPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
import { Aside } from '@astrojs/starlight/components' | ||
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro' | ||
--- | ||
|
||
<StarlightPage frontmatter={{ title: 'Custom - Excluded without sidebar', template: 'splash' }}> | ||
<p> | ||
This custom page using the <code>splash</code> template is not listed in any topic sidebar configuration, is not associated | ||
with any topic through the <code>topic</code> frontmatter field, and is also excluded in the plugin configuration. | ||
</p> | ||
<Aside> | ||
This page exists solely for demonstration purposes and contains no useful information. See the Starlight Sidebar | ||
Topics plugin <a href="/docs/getting-started/">documentation</a> for more information. | ||
</Aside> | ||
</StarlightPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.