Skip to content

Commit

Permalink
Center post body horizontally if there is no toc nor related blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiro committed May 28, 2024
1 parent f34c219 commit 49b0fbd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
{{ end }}

{{ define "main" }}
{{- $related_content := .RegularPages.Related . -}}
{{- $needs_aside := or .Params.toc $related_content -}}
{{ $section := .Site.GetPage "section" .Section }}
<article class="flex-l flex-wrap justify-between mw8 center ph3">
<article class="flex-l flex-wrap justify-between {{ if $needs_aside }}mw8{{ else }}mw7{{ end }} center ph3">
<header class="mt4 w-100">
<aside class="instapaper_ignoref b helvetica tracked ttu">
{{/*
Expand All @@ -29,6 +31,7 @@ <h1 class="f1 athelas mt3 mb1">
</strong>
</p>
{{ end }}
{{- end -}}
{{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
{{ if not .Date.IsZero }}
<time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}>
Expand All @@ -47,7 +50,7 @@ <h1 class="f1 athelas mt3 mb1">
<span class="f6 mv4 dib tracked"> - {{ i18n "wordCount" .WordCount }} </span>
{{ end }}
</header>
<div class="nested-copy-line-height lh-copy {{ $.Param "post_content_classes" | default "serif"}} f4 nested-links {{ $.Param "text_color" | default "mid-gray" }} {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl4-l" "pr4-l" }} w-two-thirds-l">
<div class="nested-copy-line-height lh-copy {{ $.Param "post_content_classes" | default "serif"}} f4 nested-links {{ $.Param "text_color" | default "mid-gray" }} {{ cond (eq $.Site.Language.LanguageDirection "rtl") "pl4-l" "pr4-l" }} {{ if $needs_aside }}w-two-thirds-l{{ else }}w-100-l{{ end }}">
{{- .Content -}}
{{- partial "tags.html" . -}}
<div class="mt6 instapaper_ignoref">
Expand All @@ -59,10 +62,11 @@ <h1 class="f1 athelas mt3 mb1">
{{ end }}
</div>
</div>

{{- if $needs_aside -}}
<aside class="w-30-l mt6-l">
{{- partial "menu-contextual.html" . -}}
</aside>
{{- end -}}

</article>
{{ end }}

0 comments on commit 49b0fbd

Please sign in to comment.