Skip to content

Commit

Permalink
add support for matching pages when the page title changes (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
plumbis committed Oct 31, 2023
1 parent 41baf7a commit 76d7828
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 18 additions & 3 deletions content/contribute/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Clone the documentation and use [Hugo](https://gohugo.io/) to
build the Crossplane documentation site locally for development and testing.

### Clone the docs repository
Clone the [Crossplane docs
repository](https://github.com/crossplane/docs) with
Clone the
[Crossplane docs repository](https://github.com/crossplane/docs) with

```command
git clone https://github.com/crossplane/docs.git
Expand Down Expand Up @@ -142,4 +142,19 @@ more.
### Hiding pages
To hide a page from the left-hand navigation use `tocHidden: true` in the front
matter of the page. The docs website skips pages with `tocHidden:true` when
building the menu.
building the menu.

### Changing page titles

The version dropdown list that links the same page in different versions
together looks for pages with a matching title.

If a page title changes use the front matter value `matchTitle:` and a value of
the old page title.

For example, if an older title was "Original Title" the new page would use:

```yaml
title: New Title
matchTitle: Original Title
```
6 changes: 5 additions & 1 deletion themes/geekboot/layouts/partials/version-dropdown-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@
{{ $master_url := replaceRE "v[0-9].[0-9]" "master" .Permalink }}
{{/* Iterate over the ordered list of available versions. */}}
{{ range $sorted_list }}
{{ $matchingTitle := $.Title }}
{{ if $.Params.matchTitle }}
{{ $matchingTitle = $.Params.matchTitle }}
{{ end }}
{{/* For a version, see if there is a page with an identical title to the page we're on. If not use the page at /content/v<version> */}}
{{ $versionPage := index (where (where $.Site.Pages "Title" $.Title) ".Page.Params.version" .) 0 | default ($.Site.GetPage (printf "v%s" .)) }}
{{ $versionPage := index (where (where $.Site.Pages "Title" $matchingTitle) ".Page.Params.version" .) 0 | default ($.Site.GetPage (printf "v%s" .)) }}
{{/* If the version is master get the master page since "vmaster" doesn't exist */}}
{{ if not $versionPage }}
{{ $versionPage = $.Site.GetPage "master" }}
Expand Down

0 comments on commit 76d7828

Please sign in to comment.