Skip to content

Commit

Permalink
feat: add the external_url page parameter (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Apr 15, 2024
1 parent 07f790b commit 7234642
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ sticky = true

[params.hb.blog.toc]
position = "end" # start, end or content.

[params.hugopress.modules.hb-blog.hooks.head-begin]
cacheable = false
14 changes: 12 additions & 2 deletions layouts/partials/hb/modules/blog/post/card.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{{- $page := .Page }}
{{- $url := $page.RelPermalink }}
{{- $external := false }}
{{- with $page.Params.external_url }}
{{- $url = . }}
{{- $external = true }}
{{- end }}
{{- $showSummary := default true .Summary }}
{{- $readMore := default true .ReadMore }}
{{- $readingTime := default true .ReadingTime }}
Expand All @@ -24,11 +30,15 @@
<a
class="hb-blog-post-title-link d-block"
title="{{ $page.Title }}"
href="{{ $page.RelPermalink }}">
{{ if $external }}target="_blank" rel="external"{{ end }}
href="{{ $url }}">
{{- if $page.Params.pinned }}
{{- partialCached "hb/modules/blog/helpers/pinned-icon" . -}}
{{- end }}
{{- $page.Title -}}
{{- if $external }}
{{- partial "icons/icon" (dict "vendor" "bootstrap" "name" "box-arrow-up-right" "className" "ms-1") }}
{{- end }}
</a>
</div>
{{- if $meta }}
Expand All @@ -49,7 +59,7 @@
{{- if and $readMore $truncated }}
<div class="mt-2">
<a
class="text-secondary" href="{{ $page.RelPermalink }}">
class="text-secondary" href="{{ $url }}"{{ if $external }}target="_blank" rel="external"{{ end }}>
{{- i18n "read_more_about" $page.Title -}}
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- with .Page.Params.external_url }}
<meta http-equiv="refresh" content="0; url={{ . }}">
{{- end }}

0 comments on commit 7234642

Please sign in to comment.