Skip to content

Commit

Permalink
feat: update single page
Browse files Browse the repository at this point in the history
  • Loading branch information
nodejh committed Feb 27, 2021
1 parent 4389d68 commit 52d788b
Show file tree
Hide file tree
Showing 9 changed files with 243 additions and 176 deletions.
1 change: 1 addition & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} <a href="#{{ .Anchor | safeURL }}" class="anchor">🔗</a></h{{ .Level }}>
4 changes: 4 additions & 0 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<p class="markdown-image">
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
</p>
1 change: 1 addition & 0 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener"{{ end }}>{{ .Text | safeHTML }}</a>
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
{{ block "main" . }}{{ end }}
</main>

{{ block "footer" . }}{{ end }}
{{ partial "footer.html" . }}
</body>
</html>
55 changes: 55 additions & 0 deletions layouts/_default/single copy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{ partial "head.html" . }}
<body>
{{ partial "navigation.html" . }}

<section id="wrapper" class="post">
<article>
<header>
<h1>
{{ .Title }}
</h1>
<h2 class="headline">
{{ .Date.Format "Jan 2, 2006 15:04" }}
· {{ if lt 1 .WordCount }}{{ .WordCount }} words{{ else }}{{ .WordCount }} word{{ end }}
· {{ .ReadingTime }} minute read
<span class="tags">
{{ with .Params.tags }}
{{ if ge (len .) 1 }}
{{ range . }}
<a href="{{ $.Site.BaseURL }}tags/{{ . | urlize }}">{{ . }}</a>
{{ end }}
{{ end }}
{{ end}}
</span>
</h2>
</header>
{{ if .Site.Params.enableToc }}
{{ if .TableOfContents }}
<div id="toc">
{{ .TableOfContents }}
</div>
{{ end }}
{{ end }}
<section id="post-body">
{{ .Content }}
</section>
</article>

{{ if .Site.Params.enableShare }}
{{ partial "share.html" . }}
{{ end }}

{{ if .Site.Params.enableDisqus }}
{{ partial "disqus.html" . }}
{{ end }}

{{ if .Site.Params.showLatestPosts }}
{{ partial "latest-posts.html" . }}
{{ end }}

{{ partial "footer.html" . }}
</section>

{{ partial "js.html" . }}
</body>
</html>
85 changes: 37 additions & 48 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,55 +1,44 @@
{{ partial "head.html" . }}
<body>
{{ partial "navigation.html" . }}
{{ define "main" }}

<section id="wrapper" class="post">
<article>
<header>
<h1>
{{ .Title }}
</h1>
<h2 class="headline">
{{ .Date.Format "Jan 2, 2006 15:04" }}
· {{ if lt 1 .WordCount }}{{ .WordCount }} words{{ else }}{{ .WordCount }} word{{ end }}
· {{ .ReadingTime }} minute read
<span class="tags">
{{ with .Params.tags }}
{{ if ge (len .) 1 }}
{{ range . }}
<a href="{{ $.Site.BaseURL }}tags/{{ . | urlize }}">{{ . }}</a>
{{ end }}
{{ end }}
{{ end}}
</span>
</h2>
</header>
{{ if .Site.Params.enableToc }}
{{ if .TableOfContents }}
<div id="toc">
{{ .TableOfContents }}
</div>
{{ end }}
{{ end }}
<section id="post-body">
{{ .Content }}
</section>
</article>
<section id="single">
<h1 class="title">{{ .Title }}</h1>

{{ if .Site.Params.enableShare }}
{{ partial "share.html" . }}
{{ end }}
<div class="tip">
<span>
{{ .Date.Format "Jan 2, 2006 15:04" }}
</span>
<span class="split">
·
</span>
<span>
{{ if lt 1 .WordCount }}
{{ .WordCount }} words
{{ else }}
{{ .WordCount }} word
{{ end }}
</span>
<span class="split">
·
</span>
<span>
{{ .ReadingTime }} minute read
</span>
</div>

{{ if .Site.Params.enableDisqus }}
{{ partial "disqus.html" . }}
{{ end }}
<div class="content">
{{ .Content }}
</div>

{{ if .Site.Params.showLatestPosts }}
{{ partial "latest-posts.html" . }}
{{ with .Params.tags }}
<div class="tags">
{{ range . }}
<a href="{{ "tags/" | absURL }}{{ . | urlize }}">{{ . }}</a>
{{ end }}
</div>
{{ end}}

{{ partial "comment.html" . }}
</section>

{{ partial "footer.html" . }}
</section>
{{ end }}

{{ partial "js.html" . }}
</body>
</html>
4 changes: 4 additions & 0 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div id="comment">
<!-- https://gohugo.io/templates/internal/#use-the-disqus-template -->
{{ template "_internal/disqus.html" . }}
</div>
1 change: 1 addition & 0 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{ if .Site.Social }}
{{ partial "social.html" . }}
{{ end }}

<p class="small">
{{ with .Site.Params.copyright }}
{{ . | markdownify }}
Expand Down
Loading

0 comments on commit 52d788b

Please sign in to comment.