Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to sub navigation layout to choose from which page to show navigation items below #229

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/layouts/sub-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ title: Page title
Page content
```

Use [common front matter options](/layouts#common-front-matter-options) to customise which items and content appear within a page.
In addition to [common front matter options](/layouts#common-front-matter-options), this layout also accepts the following options:

| Name | Type | Description |
| :------------- | :----- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **sectionKey** | string | Parent navigation key (usually a page title) to show items below in the sub navigation. Default is `homeKey` value provided in [plugin options](/options). |
2 changes: 1 addition & 1 deletion layouts/sub-navigation.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-quarter-from-desktop">
{{ xGovukSubNavigation({
items: collections.ordered | eleventyNavigation(options.homeKey) | itemsFromNavigation(page.url, { pathPrefix: options.pathPrefix })
items: collections.ordered | eleventyNavigation(sectionKey or options.homeKey) | itemsFromNavigation(page.url, { pathPrefix: options.pathPrefix })
}) }}
</div>
<div class="govuk-grid-column-three-quarters-from-desktop">
Expand Down