fix: [template] Change default hugo template to generate markdown - to

fix the issue with media description containing new-lines.

Ref: https://codeberg.org/ggpsv/mastodon-markdown-archive/issues/1
This commit is contained in:
Alexandre Dulaunoy 2024-09-01 17:05:14 +02:00
parent d18757447e
commit fc4484b10d
Signed by: adulau
GPG key ID: 09E2CD4944E6CBCD

View file

@ -1,44 +1,46 @@
--- ---
date: {{ .Post.CreatedAt }} date: {{ .Post.CreatedAt }}
{{- if .Post.InReplyToId }} {{- if .Post.InReplyToId }}
in_reply_to: {{ .Post.InReplyToId }} in_reply_to: {{ .Post.InReplyToId }}
{{- end }} {{- end }}
post_uri: {{ .Post.URI }} post_uri: {{ .Post.URI }}
post_id: {{ .Post.Id }} post_id: {{ .Post.Id }}
{{- if len .Post.AllTags }} {{- if len .Post.AllTags }}
tags: tags:
{{- range .Post.AllTags }} {{- range .Post.AllTags }}
- {{ .Name }} - {{ .Name }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if len .Post.Descendants }} {{- if len .Post.Descendants }}
descendants: descendants:
{{- range .Post.Descendants }} {{- range .Post.Descendants }}
- {{ .Id }} - {{ .Id }}
{{- end }} {{- end }}
{{- end }} {{- end }}
--- layout: page
{{ .Post.Content | toMarkdown }} title: paperbay.org Mastodon - {{ .Post.URI }}
---
{{ range .Post.MediaAttachments }} {{ .Post.Content | toMarkdown }}
{{- if eq .Type "image" }}
{{- if .Path }} {{ range .Post.MediaAttachments }}
![{{ .Description }}]({{ osBase .Path }}) {{- if eq .Type "image" }}
{{- else }} {{- if .Path }}
![{{ .Description }}]({{ .URL }}) ![{{ .Description | replace "\n" "" }}]({{ osBase .Path }})
{{- end }} {{- else }}
{{ end }} ![{{ .Description | replace "\n" "" }}]({{ .URL }})
{{- end -}} {{- end }}
{{ end }}
{{ range .Post.Descendants }} {{- end -}}
{{ .Content | toMarkdown }}
{{ range .MediaAttachments }} {{ range .Post.Descendants }}
{{- if eq .Type "image" }} {{ .Content | toMarkdown }}
{{- if .Path }} {{ range .MediaAttachments }}
![{{ .Description }}]({{ osBase .Path }}) {{- if eq .Type "image" }}
{{- else }} {{- if .Path }}
![{{ .Description }}]({{ .URL }}) ![{{ .Description | replace "\n" ""}}]({{ osBase .Path }})
{{- end }} {{- else }}
{{- end }} ![{{ .Description | replace "\n" ""}}]({{ .URL }})
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }}
{{- end }}