Skip to content

Commit

Permalink
theme(feat): add configuration shortcode (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsneighbour committed Oct 15, 2024
1 parent 1cfc726 commit 3946ef1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion content/slash/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ unsplash:
imageid: yLVPQvU2KEc
---

{{< configuration >}}
{{< configuration config="params.dnb.hooks" >}}
48 changes: 37 additions & 11 deletions layouts/shortcodes/configuration.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
<div class="input-group mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search for configuration items">
<button class="btn btn-secondary" type="button" onclick="scrollToRow()">Search</button>
</div>
<div id="configuration">
{{ partial "inline/table.html" (dict "value" site.Data.dnb.kollitsch.config) }}
{{- $config := .Get "config" | default "full" -}}
{{- $config = strings.Split $config "." -}}
{{- $options := site.Data.dnb.kollitsch.config -}}
{{- if ne "full" $config -}}
{{- $options = collections.Index site.Data.dnb.kollitsch.config $config -}}
{{- end -}}

<style>
#configsearch {
position:sticky;
top: 55px;
}
#configcontainer {
max-height: 100%;
}
</style>

<div id="configcontainer">
<div id="configsearch" class="input-group mb-3">
<input type="text" class="form-control form-control-lg" id="searchInput"
placeholder="Search for configuration items">
<button class="btn btn-secondary" type="button" onclick="scrollToRow()">Search</button>
</div>
<div id="configuration">
{{ partials.Include "inline/table.html" (collections.Dictionary "value" $options) }}
</div>
</div>

{{ define "partials/inline/table.html" }}
<table class="w-100 mb-0">
{{ range $key, $value := .value}}
<table>
{{- range $key, $value := .value -}}
<tr>
<td>{{ $key }}</td>
<td>{{- $key -}}</td>
{{ if reflect.IsMap $value }}
<td>
{{ partial "inline/table.html" (dict "value" $value) }}
{{ partials.Include "inline/table.html" (collections.Dictionary "value" $value) }}
</td>
{{ else if reflect.IsSlice $value}}
<td>
{{ range $value }}
{{ partials.Include "inline/table.html" (collections.Dictionary "value" $value) }}
{{ end }}
</td>
{{ else }}
<td>
{{ $value }}
</td>
{{ end }}
</tr>
{{ end }}
{{- end -}}
</table>
{{ end }}

Expand Down

0 comments on commit 3946ef1

Please sign in to comment.