Attempt to implement a feature flag to toggle CSS layers on and off

This commit is contained in:
Eryn Wells 2023-05-20 08:30:35 -07:00
parent 4f63fab916
commit 4cedd992b8
4 changed files with 29 additions and 9 deletions

View file

@ -2,3 +2,6 @@ twitter: erynofwales
github: erynofwales
instagram: erynofwales
description: Home page of Eryn Rachel Wells
flags:
cssLayers: development

View file

@ -0,0 +1,4 @@
{{- $enabled := partial "flag_is_enabled.html" "cssLayers" -}}
{{ if $enabled -}}{{ printf "@layer %s {" . }}{{- end }}
{{ .Inner }}
{{ if $enabled -}}{{ `}` }}{{- end }}

View file

@ -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>

View 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 }}