-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds 4 shortcodes that generate consistently formatted links to concept guides, howto guides, references, and tutorials. Their formatted output is intended for use inside pages' Related content sections, with the intention to replace all current manually-formatted links in these sections with uses of these shortcodes, site wide. Preview-Path: /examples/shortcodes/linkto/ Signed-off-by: Jonathan Matthews <[email protected]> Change-Id: Ia74ca0e8eca3c8e1e1d9dc0f35e16ccac87075e2 Dispatch-Trailer: {"type":"trybot","CL":1176797,"patchset":1,"ref":"refs/changes/97/1176797/1","targetBranch":"alpha"}
- Loading branch information
1 parent
baed24e
commit 16bc4e5
Showing
9 changed files
with
139 additions
and
10 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
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,40 @@ | ||
--- | ||
title: linkto | ||
--- | ||
|
||
The `linkto` hierarchy contains convenience shims that generate well-formed and | ||
consistently formatted links to commonly referenced pages. | ||
|
||
### `linkto/related/{concept,howto,reference,tutorial}` | ||
|
||
`linkto/related/` contains 4 shortcodes primarily aimed at generating links to | ||
Tutorials, How-to Guides, Concept Guides, and References. The links contain the | ||
linked-to page's title field. They are intended to be used in a page's "Related | ||
content" section, placed inside a list element. They only generate content | ||
suitable for inclusion in a list, and do not generate self-contained list | ||
elements. | ||
|
||
Only these 4 hierarchies are currently supported as they make up the majority | ||
of related content links, and have reduced implementation complexity (relative | ||
to, say, linking to the Language Guide or the Tour) due to their flat page | ||
hierarchies. | ||
|
||
#### Parameters | ||
|
||
The first positional parameter is the path component of the related page | ||
**within** the relevant hierarchy. I.e. **without** a leading "docs/tutorial/", | ||
"docs/reference/", etc. | ||
|
||
#### Examples | ||
|
||
``` | ||
- {{</* linkto/related/concept "the-logic-of-cue" */>}} | ||
- {{</* linkto/related/howto "use-strings-replace" */>}} | ||
- {{</* linkto/related/reference "modules" */>}} | ||
- {{</* linkto/related/tutorial "working-with-a-custom-module-registry" */>}} | ||
``` | ||
|
||
- {{< linkto/related/concept "the-logic-of-cue" >}} | ||
- {{< linkto/related/howto "use-strings-replace" >}} | ||
- {{< linkto/related/reference "modules" >}} | ||
- {{< linkto/related/tutorial "working-with-a-custom-module-registry" >}} |
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,3 @@ | ||
package site | ||
|
||
content: examples: shortcodes: linkto: {} |
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,40 @@ | ||
--- | ||
title: linkto | ||
--- | ||
|
||
The `linkto` hierarchy contains convenience shims that generate well-formed and | ||
consistently formatted links to commonly referenced pages. | ||
|
||
### `linkto/related/{concept,howto,reference,tutorial}` | ||
|
||
`linkto/related/` contains 4 shortcodes primarily aimed at generating links to | ||
Tutorials, How-to Guides, Concept Guides, and References. The links contain the | ||
linked-to page's title field. They are intended to be used in a page's "Related | ||
content" section, placed inside a list element. They only generate content | ||
suitable for inclusion in a list, and do not generate self-contained list | ||
elements. | ||
|
||
Only these 4 hierarchies are currently supported as they make up the majority | ||
of related content links, and have reduced implementation complexity (relative | ||
to, say, linking to the Language Guide or the Tour) due to their flat page | ||
hierarchies. | ||
|
||
#### Parameters | ||
|
||
The first positional parameter is the path component of the related page | ||
**within** the relevant hierarchy. I.e. **without** a leading "docs/tutorial/", | ||
"docs/reference/", etc. | ||
|
||
#### Examples | ||
|
||
``` | ||
- {{</* linkto/related/concept "the-logic-of-cue" */>}} | ||
- {{</* linkto/related/howto "use-strings-replace" */>}} | ||
- {{</* linkto/related/reference "modules" */>}} | ||
- {{</* linkto/related/tutorial "working-with-a-custom-module-registry" */>}} | ||
``` | ||
|
||
- {{< linkto/related/concept "the-logic-of-cue" >}} | ||
- {{< linkto/related/howto "use-strings-replace" >}} | ||
- {{< linkto/related/reference "modules" >}} | ||
- {{< linkto/related/tutorial "working-with-a-custom-module-registry" >}} |
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 @@ | ||
{{ $relPath := printf "docs/concept/%s" (.Get 0) -}} | ||
{{ $linkToPage := site.GetPage $relPath -}} | ||
{{- if eq (strings.CountRunes $linkToPage.Title) 0 -}} | ||
{{ errorf "[%s] %q: %q not found or has no title" site.Language.Lang .Page.File $relPath }} | ||
{{- end -}} | ||
Concept Guide: {{ with $linkToPage -}} | ||
{{- $opts := dict "path" $relPath -}} | ||
<a href="{{ .RelRef $opts }}">{{ .Title }}</a> | ||
{{- end}} |
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 @@ | ||
{{ $relPath := printf "docs/howto/%s" (.Get 0) -}} | ||
{{ $linkToPage := site.GetPage $relPath -}} | ||
{{- if eq (strings.CountRunes $linkToPage.Title) 0 -}} | ||
{{ errorf "[%s] %q: %q not found or has no title" site.Language.Lang .Page.File $relPath }} | ||
{{- end -}} | ||
How-to Guide: {{ with $linkToPage -}} | ||
{{- $opts := dict "path" $relPath -}} | ||
<a href="{{ .RelRef $opts }}">{{ .Title }}</a> | ||
{{- end}} |
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 @@ | ||
{{ $relPath := printf "docs/reference/%s" (.Get 0) -}} | ||
{{ $linkToPage := site.GetPage $relPath -}} | ||
{{- if eq (strings.CountRunes $linkToPage.Title) 0 -}} | ||
{{ errorf "[%s] %q: %q not found or has no title" site.Language.Lang .Page.File $relPath }} | ||
{{- end -}} | ||
Reference: {{ with $linkToPage -}} | ||
{{- $opts := dict "path" $relPath -}} | ||
<a href="{{ .RelRef $opts }}">{{ .Title }}</a> | ||
{{- end}} |
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 @@ | ||
{{ $relPath := printf "docs/tutorial/%s" (.Get 0) -}} | ||
{{ $linkToPage := site.GetPage $relPath -}} | ||
{{- if eq (strings.CountRunes $linkToPage.Title) 0 -}} | ||
{{ errorf "[%s] %q: %q not found or has no title" site.Language.Lang .Page.File $relPath }} | ||
{{- end -}} | ||
Tutorial: {{ with $linkToPage -}} | ||
{{- $opts := dict "path" $relPath -}} | ||
<a href="{{ .RelRef $opts }}">{{ .Title }}</a> | ||
{{- end}} |