Compare commits

...

6 Commits

Author SHA1 Message Date
Mark Dumay
7413155dea Merge pull request #1108 from gethinode/develop
Fix embedded and anchor links
2024-08-16 11:04:54 +02:00
Mark Dumay
cfd1706f5f Merge branch 'main' into develop 2024-08-16 10:58:37 +02:00
Mark Dumay
5eca63c50d Fix embedded and anchor links 2024-08-16 10:58:05 +02:00
Mark Dumay
d3f471a281 Merge pull request #1107 from gethinode/develop
Use utility function to retrieve the page associated with a card
2024-08-16 10:55:56 +02:00
Mark Dumay
b4acd7aef2 Merge branch 'main' into develop 2024-08-16 10:51:11 +02:00
Mark Dumay
49a3ef3c42 Use utility function to retrieve the page associated with a card 2024-08-16 10:50:36 +02:00
8 changed files with 47 additions and 56 deletions

2
go.mod
View File

@@ -11,7 +11,7 @@ require (
github.com/gethinode/mod-leaflet v1.1.1 // indirect
github.com/gethinode/mod-lottie v1.5.6 // indirect
github.com/gethinode/mod-simple-datatables v1.0.7 // indirect
github.com/gethinode/mod-utils/v2 v2.3.10 // indirect
github.com/gethinode/mod-utils/v2 v2.4.0 // indirect
github.com/nextapps-de/flexsearch v0.0.0-20240501124520-961c3ae84a87 // indirect
github.com/twbs/bootstrap v5.3.3+incompatible // indirect
)

2
go.sum
View File

@@ -258,6 +258,8 @@ github.com/gethinode/mod-utils/v2 v2.3.9 h1:Z9uAr6S0wunlkfKHa2D/U83fBV6Ivtf+7sjB
github.com/gethinode/mod-utils/v2 v2.3.9/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.3.10 h1:+coUXdgAbLEE8Tvb3Rfk/1Nr6oDVreXI2sil0pa/n2Q=
github.com/gethinode/mod-utils/v2 v2.3.10/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.4.0 h1:mmG4hWaeA4krAg933pibH+TrjFmPHkAi/DUbe3SM38I=
github.com/gethinode/mod-utils/v2 v2.4.0/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU=
github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg=

View File

@@ -2,7 +2,6 @@
"htmlElements": {
"tags": [
"a",
"annotation",
"body",
"button",
"div",
@@ -16,29 +15,13 @@
"label",
"li",
"link",
"math",
"meta",
"mfrac",
"mi",
"mn",
"mo",
"mpadded",
"mphantom",
"mrow",
"mspace",
"msqrt",
"mstyle",
"msub",
"msup",
"mtext",
"munder",
"nav",
"noscript",
"ol",
"p",
"path",
"script",
"semantics",
"small",
"span",
"strong",
@@ -76,12 +59,10 @@
"col-6",
"col-lg-2",
"col-lg-8",
"col-md-2",
"col-md-3",
"col-md-4",
"col-md-8",
"col-md-9",
"col-sm-12",
"collapse",
"collapsed",
"container-fluid",
@@ -92,16 +73,14 @@
"d-md-block",
"d-md-none",
"d-none",
"display-1",
"display-4",
"emphasis",
"end-0",
"fa",
"fa-10x",
"fa-2x",
"fa-arrow-left",
"fa-arrow-right",
"fa-book-open",
"fa-ellipsis",
"fa-face-frown",
"fa-facebook",
"fa-fw",
"fa-github",
@@ -137,7 +116,6 @@
"justify-content-center",
"justify-content-end",
"justify-content-start",
"katex",
"label",
"lead",
"link-bg-footer",
@@ -145,7 +123,6 @@
"main-content",
"main-nav-toggler",
"mb-3",
"mb-4",
"mb-5",
"mb-lg-5",
"me-auto",
@@ -172,6 +149,7 @@
"navbar-mode-selector",
"navbar-nav",
"navbar-toggler",
"next",
"no-js",
"offcanvas",
"offcanvas-body",
@@ -186,11 +164,13 @@
"p-2",
"p-3",
"p-4",
"p-auto",
"pb-4",
"pb-5",
"pb-md-0",
"position-fixed",
"position-relative",
"previous",
"ps-1",
"pt-5",
"pt-md-3",
@@ -205,7 +185,6 @@
"row-cols-md-2",
"row-cols-md-3",
"row-cols-sm-2",
"row-cols-sm-3",
"search",
"search-input",
"search-suggestions",
@@ -219,7 +198,6 @@
"text-decoration-none",
"text-end",
"text-muted",
"text-secondary",
"text-sm-start",
"text-start",
"text-uppercase",
@@ -233,7 +211,6 @@
"top-bar"
],
"ids": [
"blogs",
"btn-webshare",
"navbar-0-collapse",
"navbar-mode",

View File

@@ -1,8 +1,10 @@
{{ if gt (findRE `^HAHAHUGO` .Destination 1) 0 }}
{{ errorf "Invalid markdown link destination, use '%s' syntax when using shortcodes as input. See '%s'"
("{{% %}}" | htmlUnescape)
.Page.File.Filename
.Page.File.Path
}}
{{ else if not .Destination }}
{{ errorf "Missing markdown link destination, see '%s'" .Page.File.Path }}
{{ else }}
{{ partial "assets/link.html" (dict
"destination" .Destination
@@ -10,4 +12,4 @@
"text" .Text
"title" .Title
) }}
{{ end }}
{{- end }}

View File

@@ -51,9 +51,13 @@
<!-- Override arguments -->
{{- $page := "" }}
{{- if .path }}
{{- $page = site.GetPage .path }}
{{ $page = partial "utilities/GetPage.html" (dict "url" .path "page" page) }}
{{- if not $page }}
{{- errorf "partial [assets/card.html] - Cannot find page: %s" .path -}}
{{ if page.File }}
{{- errorf "partial [assets/card.html] - Cannot find target page '%s', see '%s'" .path page.File.Path -}}
{{ else }}
{{- errorf "partial [assets/card.html] - Cannot find target page '%s'" .path -}}
{{ end }}
{{- end }}
{{- end }}
{{- with $page -}}

View File

@@ -22,6 +22,7 @@
{{- $cue := .cue | default site.Params.main.externalLinks.cue -}}
{{- $tab := .tab | default site.Params.main.externalLinks.tab -}}
{{- $isExternal := or (ne (urls.Parse (absURL $destination)).Host (urls.Parse site.BaseURL).Host) $external -}}
{{- $isLocal := hasPrefix $destination "#" -}}
{{- $page := .page -}}
{{- $anchor := "" -}}
{{- $text := .text -}}
@@ -54,32 +55,37 @@
{{ end }}
{{ end }}
{{ $ref := partial "utilities/GetPage.html" (dict "url" $destination "page" $page) }}
{{- if not $ref -}}
{{- errorf "partial [assets/link.html] - Cannot find page: %s" $destination -}}
{{- $error = true -}}
{{- else -}}
{{- $destination = $ref.RelPermalink -}}
{{- with $anchor }}{{ $destination = printf "%s#%s" (strings.TrimSuffix "/" $destination) . -}}{{ end -}}
{{ if not $isLocal }}
{{ $ref := partial "utilities/GetPage.html" (dict "url" $destination "page" $page) }}
{{- if not $ref -}}
{{- errorf "partial [assets/link.html] - Cannot find page: %s" $destination -}}
{{- $error = true -}}
{{- else -}}
{{- $destination = $ref.RelPermalink -}}
{{- with $anchor }}{{ $destination = printf "%s#%s" (strings.TrimSuffix "/" $destination) . -}}{{ end -}}
{{- end -}}
{{- if not $text -}}
{{- if $anchor -}}
{{- $text = $anchor -}}
{{- else -}}
{{- $text = $ref.LinkTitle -}}
{{- end -}}
{{ if $anchor }}{{ $text = $anchor }}{{ else }}{{ $text = $ref.LinkTitle }}{{ end }}
{{ end -}}
{{- if not $case }}{{ $text = lower $text }}{{ end -}}
{{- end -}}
{{ else }}
{{ with $anchor }}
{{ $destination = printf "#%s" . }}
{{ if not $text }}{{ $text = . }}{{ end }}
{{ end }}
{{ end }}
{{- if not $case }}{{ $text = lower $text }}{{ end -}}
{{- end -}}
{{ if not $error -}}
<a
{{- with $destination }} href="{{ . | safeURL }}"{{ end -}}
{{- with $class }}class="{{ . }}" {{ end -}}
{{- with $target }} target="{{ . }}"{{ end -}}
{{- with $rel }} rel="{{ . }}"{{ end -}}
{{- with $title }} title="{{ . }}"{{ end -}}
{{ with $class }} class="{{ . }}" {{ end -}}
{{ with $target }} target="{{ . }}"{{ end -}}
{{ with $rel }} rel="{{ . }}"{{ end -}}
{{ with $title }} title="{{ . }}"{{ end -}}
>
{{- $text -}}
{{- $text | safeHTML -}}
</a>
{{- end }}
{{- end -}}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@gethinode/hinode",
"version": "0.26.0",
"version": "0.26.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@gethinode/hinode",
"version": "0.26.0",
"version": "0.26.1",
"license": "MIT",
"dependencies": {
"@fullhuman/postcss-purgecss": "^6.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@gethinode/hinode",
"version": "0.26.0",
"version": "0.26.1",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [
"hugo",