Skip to content

Commit

Permalink
feat(config-toggle): allow specifying title (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang authored Dec 8, 2023
1 parent 4cee395 commit 980bb9f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions layouts/partials/bootstrap/config-toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
{{- $langs := default (slice "toml" "yaml" "json") site.Params.bootstrap.config_toggle.langs }}
{{- $style := "tabs" }}
{{- $fill := false }}
{{- $title := "" }}
{{- if .IsNamedParams }}
{{- with .Get "filename" }}{{ $filename = . }}{{ end }}
{{- with .Get "langs" }}{{ $langs = split . "," }}{{ end }}
{{- with .Get "style" }}{{ $style = . }}{{ end }}
{{- with .Get "fill" }}{{ $fill = . }}{{ end }}
{{- with .Get "title" }}{{ $title = . }}{{ end }}
{{- else }}
{{- with .Get 0 }}{{ $filename = . }}{{ end }}
{{- with .Get 1 }}{{ $langs = split . "," }}{{ end }}
{{- end }}
{{- $idPrefix := printf "%s-%s" (replaceRE "[\\|/]" "-" $filename) (delimit (shuffle (seq 1 9)) "") -}}
<div class="config-toggle mb-3">
<ul class="nav nav-{{ $style }} mb-1{{ cond $fill ` nav-fill` `` }}" role="tablist">
{{- with $title }}
<li class="nav-item mb-0 flex-grow-0" role="presentation">
<button
class="nav-link fw-bold disabled"
type="button"
role="tab">
{{ . }}
</button>
</li>
{{- end }}
{{- range $i, $lang := $langs -}}
{{- $id := printf "code-toggle-%s-%s" $idPrefix $lang -}}
<li class="nav-item mb-0" role="presentation">
Expand Down

0 comments on commit 980bb9f

Please sign in to comment.