Skip to content

Commit

Permalink
feat: Hide lang button with single lang mode (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris authored May 8, 2021
1 parent f4cf568 commit da8f1de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Hugo IRIS Theme
- [Maintainer](#maintainer)
- [Contributing](#contributing)
- [License](#license)
- [Development](#development)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -392,6 +393,12 @@ You can find more detail in our [Contributing Guide].



## Development

```sh
{{ partial "console-log" $hoge }}
```

---

<div align="right"><a href="#table-of-contents">Back to TOC ☝️</a></div>
Expand Down
13 changes: 11 additions & 2 deletions layouts/partials/lang-button.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ define "button" }}

<div class="dropdown" id="langDrop">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu" onclick="toggleDropdownActive();">
Expand All @@ -7,8 +9,8 @@
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
{{ $langPage := cond (gt (len .Translations) 0) . .Site.Home }}
{{ partial "console-log" $langPage }}
{{ partial "console-log" (len .Translations) }}
{{/* partial "console-log" $langPage */}}
{{/* partial "console-log" (len .Translations) */}}
{{ range $langPage.Translations }}
<a href="{{ .RelPermalink }}" class="dropdown-item normal-link">{{ .Language.LanguageName }}</a>
{{ end }}
Expand All @@ -21,3 +23,10 @@
obj.classList.toggle("is-active");
}
</script>

{{ end }}

{{ if gt (len .Translations) 0 }}
{{ block "button" . }}
{{ end }}
{{ end }}

0 comments on commit da8f1de

Please sign in to comment.