mirror of https://github.com/lxndrblz/anatole.git

google-labs-jules[bot]
3 hours ago 731cc69cb8fc3ea1de8efc6ab2c57f2f4c68f297
🧹 [Code Health] Extract author name logic to a partial

Extract the common logic for determining the author name from a map or string to a new `author.html` partial, and use it across `rss.xml`, `schema.html`, `footer.html`, and `head.html`.

Co-authored-by: KarelZe <12801659+KarelZe@users.noreply.github.com>
4 files modified
1 files added
55 ■■■■■ changed files
layouts/_default/rss.xml 11 ●●●●● patch | view | raw | blame | history
layouts/partials/author.html 11 ●●●●● patch | view | raw | blame | history
layouts/partials/footer.html 11 ●●●●● patch | view | raw | blame | history
layouts/partials/head.html 11 ●●●●● patch | view | raw | blame | history
layouts/partials/schema.html 11 ●●●●● patch | view | raw | blame | history
layouts/_default/rss.xml
@@ -6,16 +6,7 @@
    {{- end -}}
  {{- end -}}
{{- end -}}
{{- $authorName := "" -}}
{{- with site.Params.author -}}
  {{- if reflect.IsMap . -}}
    {{- with .name -}}
      {{- $authorName = . -}}
    {{- end -}}
  {{- else -}}
    {{- $authorName = . -}}
  {{- end -}}
{{- end -}}
{{- $authorName := partial "author.html" site.Params.author -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
layouts/partials/author.html
New file
@@ -0,0 +1,11 @@
{{- $authorName := "" -}}
{{- with . -}}
  {{- if reflect.IsMap . -}}
    {{- with .name -}}
      {{- $authorName = . -}}
    {{- end -}}
  {{- else -}}
    {{- $authorName = . -}}
  {{- end -}}
{{- end -}}
{{- return $authorName -}}
layouts/partials/footer.html
@@ -1,13 +1,4 @@
{{- $authorName := "" -}}
{{- with .context.Site.Params.author -}}
  {{- if reflect.IsMap . -}}
    {{- with .name -}}
      {{- $authorName = . -}}
    {{- end -}}
  {{- else -}}
    {{- $authorName = . -}}
  {{- end -}}
{{- end -}}
{{- $authorName := partial "author.html" .context.Site.Params.author -}}
<footer class="footer footer__{{ .footerClassModifier }}">
  <ul
    class="footer__list {{ with .context.Site.Params.doNotLoadAnimations }}
layouts/partials/head.html
@@ -1,15 +1,6 @@
<head>
  <meta charset="utf-8" />
  {{- $authorName := "" -}}
  {{- with .Site.Params.author -}}
    {{- if reflect.IsMap . -}}
      {{- with .name -}}
        {{- $authorName = . -}}
      {{- end -}}
    {{- else -}}
      {{- $authorName = . -}}
    {{- end -}}
  {{- end -}}
  {{- $authorName := partial "author.html" .Site.Params.author -}}
  <title>
    {{ if (eq .Site.Params.reversepagetitle true) }}
      {{ with .Title }}
layouts/partials/schema.html
@@ -15,16 +15,7 @@
    }
  </script>
{{ else if .IsPage }}
  {{- $author := "" -}}
  {{- with or (.Params.author) (.Site.Params.author) -}}
    {{- if reflect.IsMap . -}}
      {{- with .name -}}
        {{- $author = . -}}
      {{- end -}}
    {{- else -}}
      {{- $author = . -}}
    {{- end -}}
  {{- end -}}
  {{- $author := partial "author.html" (or (.Params.author) (.Site.Params.author)) -}}
  {{ $favicon := .Site.Params.favicon | absURL }}
  <script type="application/ld+json">
    {