commit 4b467bcddae039c04dd9b9adadb95d1044d6e45e parent e83d4a43eb5763545d66a8c81ea3cb9fad4aaef5 Author: Yohanes Bandung <bandungpenting@gmail.com> Date: Mon, 4 May 2020 05:05:35 +0700 refactor: modify notes single page Diffstat:
| M | layouts/_default/single.html | | | 62 | ++++++++++++++++++++++++++++++++++---------------------------- |
| M | layouts/partials/head/twitter-card-metas.html | | | 7 | +++++-- |
2 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/layouts/_default/single.html b/layouts/_default/single.html @@ -1,34 +1,40 @@ {{ define "main" }} - <article class="content h-entry"> - <h1 class="p-name">{{ .Title }}</h1> - <div id="h-card" class="hcard"> - <img class="u-photo" src={{ "logo.png" | absURL }} alt="Weird photo of yohanes bandung" /> - <a class="p-author h-card" href={{ .Site.Params.MainSiteURL }} rel="author">{{ substr .Site.Params.Author 0 20 }}.</a> - <br> - <a class="u-email" href="mailto:{{ .Site.Params.Email }}">{{ .Site.Params.Email }}</a> - <br> - <a rel="syndication" class="u-syndication" href={{ .Permalink }}>{{ .Title }}</a> + {{ if eq .Type "notes" }} + <article> + {{- partial "post/notes-item.html" . -}} + </article> + {{ else }} + <article class="content h-entry"> + <h1 class="p-name">{{ .Title }}</h1> + <div id="h-card" class="hcard"> + <img class="u-photo" src={{ "logo.png" | absURL }} alt="Weird photo of yohanes bandung" /> + <a class="p-author h-card" href={{ .Site.Params.MainSiteURL }} rel="author">{{ substr .Site.Params.Author 0 20 }}.</a> + <br> + <a class="u-email" href="mailto:{{ .Site.Params.Email }}">{{ .Site.Params.Email }}</a> + <br> + <a rel="syndication" class="u-syndication" href={{ .Permalink }}>{{ .Title }}</a> + <br> + <span class="p-locality">Jakarta</span>, <span class="p-country-name">Indonesia</span> + <br> + {{ with .Params.tags }} + {{ range . }} + <a class="p-category" href={{ (printf "tags/%s" .) | urlize | absURL }}>{{ . }}</a> + {{ end }} + {{ end }} + </div> + <div class="e-content"> + {{ partial "components/headline-hash.html" .Content }} + </div> <br> - <span class="p-locality">Jakarta</span>, <span class="p-country-name">Indonesia</span> <br> + <p {{ if eq .Type "page" }}class="hcard"{{ end }}><a class="u-url link-white" href={{ .Permalink }}>Published</a> on <time class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05" }}+07:00">{{ .Date.Format "02 January 2006" }}</time>, for stories like this:</p> {{ with .Params.tags }} - {{ range . }} - <a class="p-category" href={{ (printf "tags/%s" .) | urlize | absURL }}>{{ . }}</a> - {{ end }} + <p class="taglist"> + {{ range . }} + {{- partial "components/tagitem.html" . -}} + {{ end }} + </p> {{ end }} - </div> - <div class="e-content"> - {{ partial "components/headline-hash.html" .Content }} - </div> - <br> - <br> - <p {{ if eq .Type "page" }}class="hcard"{{ end }}><a class="u-url link-white" href={{ .Permalink }}>Published</a> on <time class="dt-published" datetime="{{ .Date.Format "2006-01-02T15:04:05" }}+07:00">{{ .Date.Format "02 January 2006" }}</time>, for stories like this:</p> - {{ with .Params.tags }} - <p class="taglist"> - {{ range . }} - {{- partial "components/tagitem.html" . -}} - {{ end }} - </p> - {{ end }} - </article> + </article> + {{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/partials/head/twitter-card-metas.html b/layouts/partials/head/twitter-card-metas.html @@ -1,12 +1,15 @@ <meta name="twitter:card" content="{{ cond (or (isset .Params.Twitter "image") (isset .Params.Image "src")) "summary_large_image" "summary"}}"> {{ $titleHome := (printf "%s :: %s" .Site.Title .Site.Params.Author) }} -{{ $titleRest := (printf "%s :: %s" .Title .Site.Title ) }} +{{ $titleRest := (printf "%s %s %s" (cond (eq .Type "notes") .Site.Title .Title) (cond (eq .Type "notes") "wrote" "::") (cond (eq .Type "notes") "a note:" .Site.Title) ) }} {{ $defaultDesc := cond (isset .Site "description") .Description (printf "%s by %s" .Site.Params.Description .Site.Params.Author) }} {{ $dateformat := .Params.Date.Format "2006-01-02 15:04" }} {{ $idslug := (print "date-" $dateformat "-") | urlize }} +{{ $lastUrlElement := index (last 1 (split (delimit (split .URL "/") "," "") ",")) 0 }} + <meta name="twitter:title" content="{{ cond .IsHome $titleHome $titleRest }}"> <meta name="twitter:url" content="{{ cond (eq .Type "notes") ( (print .Site.BaseURL "notes#" $idslug)) .Permalink }}"> -<meta name="twitter:description" content="{{ cond .IsHome .Site.Params.Description (.Params.Twitter.Description | default $defaultDesc) }}"> +<meta name="twitter:description" content="{{ cond .IsHome .Site.Params.Description (cond (and (eq .Type "notes") (ne .Summary "")) .Summary (.Params.Twitter.Description | default $defaultDesc)) }}"> <meta name="twitter:image" content="{{ .Params.Twitter.Image | (cond (isset .Params.Image "src") (printf "%s%s" .Permalink .Params.Image.Src) nil) | default "logo.png" | absURL }}"> +<meta name="twitter:image:alt" content="{{ cond .IsHome $titleHome $titleRest }}"> <meta name="twitter:site" content="@{{ .Params.Twitter.Site | default .Site.Params.twitter }}"> <meta name="twitter:creator" content="@{{ .Params.Twitter.Site | default .Site.Params.twitter }}">