add post-description post-nav and related-posts
This commit is contained in:
21
layouts/partials/post-description.html
Normal file
21
layouts/partials/post-description.html
Normal file
@ -0,0 +1,21 @@
|
||||
{{- /* Get post description or generate it from the post content */ -}}
|
||||
{{- $max_length := default 200 .Params.max_length -}}
|
||||
|
||||
{{- $description := "" -}}
|
||||
{{- if .Description -}}
|
||||
{{- $description = .Description -}}
|
||||
{{- else if .Params.description -}}
|
||||
{{- $description = .Params.description -}}
|
||||
{{- else -}}
|
||||
{{- /* Remove the line number of the code snippet */ -}}
|
||||
{{- $content := .Content -}}
|
||||
|
||||
{{- if findRE `<td class="rouge-gutter gl"><pre class="lineno">` $content -}}
|
||||
{{- $content = replace $content `<td class="rouge-gutter gl"><pre class="lineno">` `<!-- <td class="rouge-gutter gl"><pre class="lineno">` -}}
|
||||
{{- $content = replace $content `</td><td class="rouge-code">` `</td> --><td class="rouge-code">` -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $description = $content | markdownify | plainify | replaceRE `\s+` ` ` -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- (trim $description " ") | truncate $max_length | safeHTML -}}
|
Reference in New Issue
Block a user