aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/function-content.html
diff options
context:
space:
mode:
Diffstat (limited to 'themes/default/layouts/partials/function-content.html')
-rw-r--r--themes/default/layouts/partials/function-content.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/themes/default/layouts/partials/function-content.html b/themes/default/layouts/partials/function-content.html
new file mode 100644
index 0000000..19c15ea
--- /dev/null
+++ b/themes/default/layouts/partials/function-content.html
@@ -0,0 +1,23 @@
+{{- $pageContext := . -}}
+{{- $content := $pageContext.Content -}}
+{{- $expired := and .ExpiryDate (ge now.Unix .ExpiryDate.Unix) -}}
+
+{{- $brokenBlockquotes := findRE `(?sU)</blockquote>\n<p>(&ndash;|&mdash;).*</p>` .Content -}}
+
+{{- range $brokenBlockquote := $brokenBlockquotes -}}
+ {{- $fixedBlockquote := $brokenBlockquote |
+ replaceRE "</blockquote>\n<p>" "<footer><cite>" |
+ replaceRE "</p>" "</cite></footer></blockquote>" |
+ -}}
+ {{- $content = replace $content $brokenBlockquote $fixedBlockquote -}}
+{{- end -}}
+
+{{- if not $content -}}
+ {{- $content = "This message contains no content." -}}
+{{- end -}}
+
+{{- if $expired -}}
+ {{- $content = "This message has expired." -}}
+{{- end -}}
+
+{{- return $content -}}