From eda370334a3798070c2f79ec38021edb3b33a84f Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Fri, 1 Jul 2022 11:27:50 -0700 Subject: [PATCH] fix: image scaling for md-style links (closes #155) --- content/notes/hosting.md | 2 +- layouts/_default/_markup/render-image.html | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/content/notes/hosting.md b/content/notes/hosting.md index 70f9d04..fffcd65 100644 --- a/content/notes/hosting.md +++ b/content/notes/hosting.md @@ -66,7 +66,7 @@ Please note that the `cname` field should *not* have any path `e.g. end with /qu [Reference `deploy.yaml` here](https://github.com/jackyzha0/quartz/blob/hugo/.github/workflows/deploy.yaml) -```yaml +```yaml {title=".github/workflows/deploy.yaml"} - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 8dda6a8..dbcf732 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,8 +1,9 @@ {{$src := .Destination | safeURL }} +{{$width := index (split .Text "|") 1 | default "auto" }} {{$external := strings.HasPrefix $src "http" }} {{- if $external -}} -{{ .Text }} +{{ .Text }} {{- else -}} {{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}} -{{ .Text }} +{{ .Text }} {{- end -}}