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
|
github: erynofwales
|
||||||
instagram: erynofwales
|
instagram: erynofwales
|
||||||
description: Home page of Eryn Rachel Wells
|
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>
|
</tbody>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
{{ if gt (len site.Params.flags) 0 -}}
|
{{ with site.Params.flag -}}
|
||||||
<h4>Flags</h4>
|
{{- if gt (len .) 0 -}}
|
||||||
<table>
|
<h4>Flags</h4>
|
||||||
<tbody>
|
<table>
|
||||||
{{ range $flag, $value := site.Params.flags }}
|
<tbody>
|
||||||
<tr><td>{{ $flag }}</td><td>{{ $value }}</td></tr>
|
{{ range $flag, $value := site.Params.flags }}
|
||||||
{{ end }}
|
<tr><td>{{ $flag }}</td><td>{{ $value }}</td></tr>
|
||||||
</tbody>
|
{{ end }}
|
||||||
</table>
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</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