Skip to content
Permalink
Browse files

Add customized single layout to linkify headings

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
  • Loading branch information
msfjarvis committed Jan 8, 2020
1 parent 55eddf2 commit 5447bb36258934d6a5bc86be99ef91a9eeb9eb17
Showing with 18 additions and 0 deletions.
  1. +18 −0 layouts/_default/single.html
@@ -0,0 +1,18 @@
{{ define "main" -}}
<div class="post">
<h1>{{ .Title }}</h1>
<p class="post-date"><time datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "January 2, 2006" }}</time> | ~{{ .ReadingTime }} min read |
{{ range .Params.tags }}
<span class="tag"><a class="tag" href="{{ "tags/" | absLangURL }}{{ . | urlize }}">#{{.}}</a> </span>
{{ end }}
</p>
{{- with .Content -}}
{{ . | replaceRE "(<h[1-9] id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1}<a href="#${2}" class="hanchor" ariaLabel="Anchor"> 🔗&#xFE0E;</a> ${3}` | safeHTML }}
{{- end -}}
</div>

{{ if .Site.DisqusShortname -}}
<h2>Comments</h2>
{{ template "_internal/disqus.html" . }}
{{- end }}
{{- end }}

0 comments on commit 5447bb3

Please sign in to comment.
You can’t perform that action at this time.