Skip to content

Commit 74f49f2

Browse files
Introduce a convenience shortcode to link to keywords (#288)
Signed-off-by: Agnivesh Chaubey <agniveshvapi@gmail.com>
1 parent a598d0b commit 74f49f2

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

content/2020-12/applicator/allOf.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ related:
2828
keyword: not
2929
---
3030

31-
The `allOf` keyword is used to specify that a given instance must validate against all of the subschemas provided within an array. It's essentially a logical "AND" operation where all conditions must be met for validation to pass.
31+
The {{<link keyword="allOf" vocabulary="applicator">}} keyword is used to specify that a given instance must validate against all of the subschemas provided within an array. It's essentially a logical "AND" operation where all conditions must be met for validation to pass.
3232

3333
## Examples
3434

@@ -129,7 +129,7 @@ The `allOf` keyword is used to specify that a given instance must validate again
129129
{{<instance-fail `An instance conforming to the second subschema of 'allOf' is also invalid`>}}
130130
{ "foo": "foo" }
131131
{{</instance-fail>}}
132-
* _Remember, if any subschema within the `allOf` keyword fails validation or has a boolean `false` value, the entire validation will always fail._
132+
* _Remember, if any subschema within the {{<link keyword="allOf" vocabulary="applicator">}} keyword fails validation or has a boolean `false` value, the entire validation will always fail._
133133

134134
{{<schema `Schema with nested 'allOf'`>}}
135135
{

layouts/shortcodes/link.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- $dialect := .Get "dialect" | default .Page.Section -}}
2+
{{- $vocabulary := .Get "vocabulary" | default .Page.Parent.Params.title -}}
3+
{{- $keyword := .Get "keyword" -}}
4+
5+
{{- if (not $keyword) -}}
6+
{{- errorf "keyword parameter is required for this shortcode." -}}
7+
{{- end -}}
8+
9+
{{ $vocabularyURL := $vocabulary | lower | printf "%s/%s" $dialect }}
10+
{{ $keywordURL := (replace $keyword "$" "") | lower | printf "/%s/%s" $vocabularyURL }}
11+
12+
<a class="font-monospace" href="{{ ref $ $keywordURL }}" data-bs-toggle="tooltip" data-bs-title="Vocabulary: {{ title $vocabulary }}">{{ $keyword }}</a>

0 commit comments

Comments
 (0)