Skip to content

Commit

Permalink
Hugo: add tag shortcode
Browse files Browse the repository at this point in the history
- Added example page for tag shortcode (/examples/shortcodes/tag/)
- Added link to example page on example overview page
- Fix color for lilac tag
- Added styling for tag shortcode
- Added html for tag shortcode

Testing: check out the example page: /examples/shortcodes/tag/

For https://linear.app/usmedia/issue/CUE-327

Closes #437 as merged as of commit 2d69208.

Signed-off-by: Anne van Gorkom <[email protected]>
Change-Id: Id6634349f008d84477a444b1315611cc86c1eb81
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1172235
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
  • Loading branch information
anne-usmedia authored and jpluscplusm committed Nov 16, 2023
1 parent 3da5049 commit c1c463f
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 15 deletions.
15 changes: 10 additions & 5 deletions content/examples/_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ <h1 class="section__title">Examples</h1>
<span class="nav__text">Sidenote</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/search/">
<span class="nav__text">Search</span>
</a>
</li>
</ul>
</div>

<div class="index__nav nav nav--index">
<p class="nav__title">Shortcodes</p>

<ul class="nav__list">
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/search/">
<span class="nav__text">Search</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/spinner/">
<span class="nav__text">Spinner</span>
Expand All @@ -162,6 +162,11 @@ <h1 class="section__title">Examples</h1>
<span class="nav__text">Tabs</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/tag">
<span class="nav__text">Tag</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/todo/">
<span class="nav__text">Todo</span>
Expand Down
40 changes: 40 additions & 0 deletions content/examples/shortcodes/tag/en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Tag
weight: 33
---

To use tags inline use the `{{</* tag */>}}` shortcode. Just add the tag name to the shortcode.
Use quotes around the tag name if it contains a space. Only the tags added to the site Params will work.
If a new tag is needed, also add that one to the params.toml.

## Examples

```
Ecosystem: {{</* tag ecosystem */>}}
Encodings: {{</* tag encodings */>}}
Cue command: {{</* tag "cue command" */>}}
Language: {{</* tag language */>}}
Validation: {{</* tag validation */>}}
Tooling: {{</* tag tooling */>}}
Commented Cue: {{</* tag "commented cue" */>}}
```

Ecosystem: {{< tag ecosystem >}}

Encodings: {{< tag encodings >}}

Cue command: {{< tag "cue command" >}}

Language: {{< tag language >}}

Validation: {{< tag validation >}}

Tooling: {{< tag tooling >}}

Commented Cue: {{< tag "commented cue" >}}
3 changes: 3 additions & 0 deletions content/examples/shortcodes/tag/page.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package site

content: examples: shortcodes: "tag": {}
4 changes: 2 additions & 2 deletions hugo/assets/scss/components/filter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@
--filter-color: #{ $c-filter-purple };
}

&--lila {
--filter-color: #{ $c-filter-lila };
&--lilac {
--filter-color: #{ $c-filter-lilac };
}

&--blue {
Expand Down
8 changes: 6 additions & 2 deletions hugo/assets/scss/components/tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
width: 0.75rem;
}

&--inline {
display: inline-flex;
}

&--red {
--tag-color: #{ $c-filter-red };
}
Expand All @@ -51,8 +55,8 @@
--tag-color: #{ $c-filter-purple };
}

&--lila {
--tag-color: #{ $c-filter-lila };
&--lilac {
--tag-color: #{ $c-filter-lilac };
}

&--blue {
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scss/config/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $c-filter-orange: #fcc199;
$c-filter-green: #cbdaaa;
$c-filter-pink: #fc97c3;
$c-filter-purple: #d6a0de;
$c-filter-lila: #9fb8de;
$c-filter-lilac: #9fb8de;
$c-filter-blue: #97d8fe;
$c-filter-lavender: #97b9fe;

Expand Down
15 changes: 10 additions & 5 deletions hugo/content/en/examples/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ <h1 class="section__title">Examples</h1>
<span class="nav__text">Sidenote</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/search/">
<span class="nav__text">Search</span>
</a>
</li>
</ul>
</div>

<div class="index__nav nav nav--index">
<p class="nav__title">Shortcodes</p>

<ul class="nav__list">
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/search/">
<span class="nav__text">Search</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/spinner/">
<span class="nav__text">Spinner</span>
Expand All @@ -162,6 +162,11 @@ <h1 class="section__title">Examples</h1>
<span class="nav__text">Tabs</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/tag">
<span class="nav__text">Tag</span>
</a>
</li>
<li class="nav__item">
<a class="nav__link" href="/examples/shortcodes/todo/">
<span class="nav__text">Todo</span>
Expand Down
40 changes: 40 additions & 0 deletions hugo/content/en/examples/shortcodes/tag/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Tag
weight: 33
---

To use tags inline use the `{{</* tag */>}}` shortcode. Just add the tag name to the shortcode.
Use quotes around the tag name if it contains a space. Only the tags added to the site Params will work.
If a new tag is needed, also add that one to the params.toml.

## Examples

```
Ecosystem: {{</* tag ecosystem */>}}
Encodings: {{</* tag encodings */>}}
Cue command: {{</* tag "cue command" */>}}
Language: {{</* tag language */>}}
Validation: {{</* tag validation */>}}
Tooling: {{</* tag tooling */>}}
Commented Cue: {{</* tag "commented cue" */>}}
```

Ecosystem: {{< tag ecosystem >}}

Encodings: {{< tag encodings >}}

Cue command: {{< tag "cue command" >}}

Language: {{< tag language >}}

Validation: {{< tag validation >}}

Tooling: {{< tag tooling >}}

Commented Cue: {{< tag "commented cue" >}}
13 changes: 13 additions & 0 deletions hugo/layouts/shortcodes/tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- $tagName := .Get 0 | default "" -}}
{{- $tagMap := where .Site.Params.tags "name" "eq" $tagName | first 1 -}}

{{- if $tagMap -}}
{{- range $tag := $tagMap -}}
{{- $tagValue:= cond (strings.Contains $tag.name " ") (printf "\"%s\"" $tag.name) $tag.name -}}

<a href="/search?q=tag:{{ $tagValue }}"
class="tag tag--inline{{ if $tag.color }} tag--{{ $tag.color }}{{ end }}">
{{ $tag.name }}
</a>
{{- end -}}
{{- end -}}

0 comments on commit c1c463f

Please sign in to comment.