mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-23 21:02:09 +00:00
Render webmentions whose targets have fragments
If a target URL has a fragment, it should match against the page URL even without the fragment.
This commit is contained in:
parent
6391da4aa7
commit
6fc55df736
1 changed files with 15 additions and 1 deletions
|
@ -17,7 +17,21 @@
|
|||
{{- $oldTarget := $target | replaceRE "/posts" "" | replaceRE "/$" ".html" -}}
|
||||
{{ $targets = (slice $target $oldTarget) }}
|
||||
{{- end -}}
|
||||
{{- $webmentions := where $allMentions "target" "in" $targets -}}
|
||||
{{- /* We can't just use a simple "where" function because we need to ignore URL anchors when making a comparison: https://discourse.gohugo.io/t/add-like-comparison-operator-to-the-where-function/42013/4 */ -}}
|
||||
{{- $webmentions := slice -}}
|
||||
{{- range $allMentions -}}
|
||||
{{- if in $targets .target -}}
|
||||
{{ $webmentions = $webmentions | append . }}
|
||||
{{- else -}}
|
||||
{{- $fragment := printf `#%s` (urls.Parse .target).Fragment -}}
|
||||
{{- if gt (len $fragment) 1 -}}
|
||||
{{- $trimmedTarget := strings.TrimSuffix $fragment .target -}}
|
||||
{{- if in $targets $trimmedTarget -}}
|
||||
{{ $webmentions = $webmentions | append . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- /* Render webmentions if they exist */ -}}
|
||||
{{- $count := (len $webmentions) -}}
|
||||
{{- if gt $count 0 -}}
|
||||
|
|
Loading…
Reference in a new issue