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

google-labs-jules[bot]
67 mins ago d20bcba1e0d928abd0bd7650984b4a2b59a75c8d
refactor: extract author name extraction logic to a partial

Extracts duplicated logic for resolving an author's name from a generic author object (which can be a map or a string) into a new reusable partial `layouts/partials/get_author_name.html`. Updates multiple files to use this new partial, improving code maintainability.

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/footer.html 11 ●●●●● patch | view | raw | blame | history
layouts/partials/get_author_name.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 "get_author_name.html" site.Params.author -}}
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
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 "get_author_name.html" .context.Site.Params.author -}}
<footer class="footer footer__{{ .footerClassModifier }}">
  <ul
    class="footer__list {{ with .context.Site.Params.doNotLoadAnimations }}
layouts/partials/get_author_name.html
New file
@@ -0,0 +1,11 @@
{{- $authorName := "" -}}
{{- with . -}}
  {{- if reflect.IsMap . -}}
    {{- with .name -}}
      {{- $authorName = . -}}
    {{- end -}}
  {{- else -}}
    {{- $authorName = . -}}
  {{- end -}}
{{- end -}}
{{- return $authorName -}}
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 "get_author_name.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 "get_author_name.html" (or .Params.author .Site.Params.author) -}}
  {{ $favicon := .Site.Params.favicon | absURL }}
  <script type="application/ld+json">
    {