Skip to content

Commit

Permalink
fix: missing <p> tag when content has one line
Browse files Browse the repository at this point in the history
fixed #49
  • Loading branch information
reuixiy committed Jan 9, 2020
1 parent 01039b7 commit d7f4b8f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{{- partial "components/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<summary type="html"><![CDATA[%s]]></summary>` ($summary | htmlUnescape) | safeHTML }}
{{ if $.Site.Params.includeContent }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{{- partial "components/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<description><![CDATA[%s]]></description>` ($summary | htmlUnescape) | safeHTML }}
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/components/content.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $Deliver := . -}}
{{- $raw := .RawContent -}}
{{- partial "components/markdownify.html" (dict "Deliver" . "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" . "raw" $raw "isContent" true) -}}

<!-- Link Headings to TOC -->
{{- $Content := .Scratch.Get "Content" -}}
Expand Down
7 changes: 7 additions & 0 deletions layouts/partials/components/markdownify.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
{{- $Content := $Content | markdownify -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}

<!-- https://github.com/reuixiy/hugo-theme-meme/issues/49 -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if and (not (strings.HasPrefix $Content "<p>")) $isContent -}}
{{- $Content := (printf `<p>%s</p>` $Content) | safeHTML -}}
{{- $Deliver.Scratch.Set "Content" $Content -}}
{{- end -}}

<!-- External Links -->
{{- $Content := $Deliver.Scratch.Get "Content" -}}
{{- if $Deliver.Site.Params.hrefTargetBlank -}}
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@

{{- if .Site.Params.displayPoweredBy }}
{{- $raw := `Powered by [Hugo](https://github.com/gohugoio/hugo) | Theme is [MemE](https://github.com/reuixiy/hugo-theme-meme)` -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := .Scratch.Get "Content" -}}
<div class="powered-by">{{ $Content | safeHTML }}</div>
{{- end }}

{{- if .Site.Params.displaySiteCopyright }}
{{- $raw := .Site.Copyright -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := .Scratch.Get "Content" -}}
<div class="site-copyright">{{ $Content | safeHTML }}</div>
{{- end }}

{{- with .Site.Params.customFooter }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="custom-footer">{{ $Content | safeHTML }}</div>
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/page/home-poetry.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="poetry">
{{ range .Site.Params.homePoetry }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<p>{{ $Content | safeHTML }}</p>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/post-copyright.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{ end }}
{{ with $author.copyright }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<li class="copyright-item license">{{ printf `%s%s` (i18n "copyrightLicense") $Content | safeHTML }}</li>
{{ end }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ <h1 class="post-title">{{ .Title }}</h1>

{{ with .Params.subtitle }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="post-subtitle">{{ $Content | safeHTML }}</div>
{{ end }}

{{ if .Site.Params.displayPostDescription }}
{{ with .Params.description }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw) -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="post-description">{{ $Content | safeHTML }}</div>
{{ end }}
Expand Down

0 comments on commit d7f4b8f

Please sign in to comment.