Add photos to notes

This commit is contained in:
Pranav Karawale 2022-10-15 14:50:51 +05:30
parent 553dced539
commit aad43efe3e
Signed by: pranav
GPG Key ID: 1A551FFE981F09AB
4 changed files with 51 additions and 27 deletions

View File

@ -5,6 +5,11 @@ title = 'Pranav Karawale'
[taxonomies]
tag = 'tags'
[Params]
# This should be the same as baseURL. This is used in some places because
# during development using `hugo server`, the baseURL changes to localhost.
realBaseURL = 'https://karawale.in/staging'
[Params.indieweb]
micropub = 'https://karawale.in/lilac/micropub'
authorization_endpoint = 'https://indieauth.com/auth'

View File

@ -0,0 +1,5 @@
{{- define "main" }}
{{ partial "post-start" . }}
<section class="e-content">{{ .Content }}</section>
{{ partial "post-end" . }}
{{- end }}

View File

@ -1,10 +1,24 @@
{{- /* Continued from post-start.html */ -}}
<a href="{{ .Permalink }}">
Published on <time datetime="{{ .Date.Format "2006-01-02T15:04:05Z" }}">
{{ if .Param "photo" }}
{{ range $photo := .Param "photo" }}
{{ $image := resources.Get (strings.TrimPrefix $.Site.Params.RealBaseURL $photo.value) }}
{{ if eq $image nil }}
{{ $image = resources.GetRemote $photo.value }}
{{ end }}
{{ $image := $image.Fit "800x600" }}
<a href="{{ $photo.value }}">
<img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ $photo.alt }}"
class="u-photo" />
</a>
{{ end }}
{{ end }}
<a class="u-url" href="{{ .Permalink }}">
Published on <time class="dt-published" datetime="{{ .Date.Format " 2006-01-02T15:04:05Z" }}">
{{ .Date.Format "02 January, 2006" }}
</time>
{{ if .Lastmod | and (.Lastmod.After .Date) }}
, edited <time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z" }}">
, edited <time class="dt-updated" datetime="{{ .Lastmod.Format " 2006-01-02T15:04:05Z" }}">
{{ .Lastmod.Format "02 January, 2006" }}
</time>
{{ end }}
@ -18,4 +32,4 @@
</li>
{{ end }}
</ul>
</div>
</article>

View File

@ -1,10 +1,10 @@
{{- $me := .Site.Params.Me -}}
<div class="h-entry">
<div class="h-card">
<img src="{{ $me.photo }}" height="48" width="48" alt="A close-up photo of my face.">
<article class="h-entry">
<section class="h-card">
<img class="u-photo" src="{{ $me.photo }}" height="48" width="48" alt="A close-up photo of my face." />
<a href="{{ .Site.BaseURL }}" class="u-name u-url">
{{ $me.Name }}
</a>
</div>
</section>
{{- /* Continued in ./post-end.html */ -}}