Attempt to implement a feature flag to toggle CSS layers on and off
This commit is contained in:
parent
4f63fab916
commit
4cedd992b8
4 changed files with 29 additions and 9 deletions
|
@ -2,3 +2,6 @@ twitter: erynofwales
|
|||
github: erynofwales
|
||||
instagram: erynofwales
|
||||
description: Home page of Eryn Rachel Wells
|
||||
|
||||
flags:
|
||||
cssLayers: development
|
||||
|
|
4
layouts/partials/css/layer.html
Normal file
4
layouts/partials/css/layer.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
{{- $enabled := partial "flag_is_enabled.html" "cssLayers" -}}
|
||||
{{ if $enabled -}}{{ printf "@layer %s {" . }}{{- end }}
|
||||
{{ .Inner }}
|
||||
{{ if $enabled -}}{{ `}` }}{{- end }}
|
|
@ -17,15 +17,17 @@
|
|||
</tbody>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ if gt (len site.Params.flags) 0 -}}
|
||||
<h4>Flags</h4>
|
||||
<table>
|
||||
<tbody>
|
||||
{{ range $flag, $value := site.Params.flags }}
|
||||
<tr><td>{{ $flag }}</td><td>{{ $value }}</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ with site.Params.flag -}}
|
||||
{{- if gt (len .) 0 -}}
|
||||
<h4>Flags</h4>
|
||||
<table>
|
||||
<tbody>
|
||||
{{ range $flag, $value := site.Params.flags }}
|
||||
<tr><td>{{ $flag }}</td><td>{{ $value }}</td></tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
</details>
|
||||
</div>
|
||||
|
|
11
layouts/partials/flag_is_enabled.html
Normal file
11
layouts/partials/flag_is_enabled.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{ $result := false }}
|
||||
|
||||
{{ with $flag := index . site.Params.flags }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $result = in (slice "yes" "true" "production" "development") $flag }}
|
||||
{{ else }}
|
||||
{{ $result = in (slice "yes" "true" "development") $flag }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $result }}
|
Loading…
Add table
Add a link
Reference in a new issue