Jacky Zhao
2022-07-01 eda370334a3798070c2f79ec38021edb3b33a84f
fix: image scaling for md-style links (closes #155)
2 files modified
7 ■■■■■ changed files
content/notes/hosting.md 2 ●●● patch | view | raw | blame | history
layouts/_default/_markup/render-image.html 5 ●●●●● patch | view | raw | blame | history
content/notes/hosting.md
@@ -66,7 +66,7 @@
[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:  
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 -}}
<img src="{{ $src }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
<img src="{{ $src }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- else -}}
{{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}}
<img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
<img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- end -}}