🐛 Fix extra whitespace added in render hooks

Fixed #679
pull/681/head
James Panther 2023-10-25 09:11:10 +11:00
parent d88f6c49be
commit 7810026589
No known key found for this signature in database
GPG Key ID: D36F789E45745D17
5 changed files with 17 additions and 10 deletions

View File

@ -1,9 +1,11 @@
{
"plugins": ["prettier-plugin-go-template"],
"goTemplateBracketSpacing": true,
"htmlWhitespaceSensitivity": "css",
"printWidth": 100,
"singleQuote": false,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"overrides": [
{

View File

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Fixed
- Extra whitespace added after links ([#679](https://github.com/jpanther/congo/issues/679))
## [2.7.1] - 2023-10-24
### Changed

View File

@ -1,10 +1,11 @@
{{ $link := .Destination }}
{{ $isRemote := strings.HasPrefix $link "http" }}
{{- if not $isRemote -}}
{{ $url := urls.Parse .Destination }}
{{- if $url.Path -}}
{{ $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end }}{{ end -}}
{{- end -}}
<a href="{{ $link | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{ .Text | safeHTML }}</a>
{{- if not $isRemote }}
{{ $url := urls.Parse .Destination }}
{{ if $url.Path }}
{{ $fragment := "" }}
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end -}}
{{ end }}
{{ end -}}
<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>