diff --git a/docs/plugins.md b/docs/plugins.md index 8b84461..d7fb9e7 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -54,7 +54,9 @@ You can add webring links like this: ```yaml config: default: # Name of the blog - - title: Webring # Title to show for the webring + - title: Webring # Title to show for the webring (required) + # At least one of link, prev or next is required + link: https://example.org/ # Link to the webring prev: https://example.com/ # Link to previous webring site next: https://example.net/ # Link to next webring site ``` \ No newline at end of file diff --git a/plugins/webrings/src/webrings/webrings.go b/plugins/webrings/src/webrings/webrings.go index 61bccec..d64ccaa 100644 --- a/plugins/webrings/src/webrings/webrings.go +++ b/plugins/webrings/src/webrings/webrings.go @@ -46,17 +46,26 @@ func (p *plugin) Render(hb *htmlbuilder.HtmlBuilder, t plugintypes.RenderType, d for _, webringAny := range blogWebrings { if webring, ok := webringAny.(map[string]any); ok { title, titleOk := unwrapToString(webring["title"]) + link, linkOk := unwrapToString(webring["link"]) prev, prevOk := unwrapToString(webring["prev"]) next, nextOk := unwrapToString(webring["next"]) - if titleOk && (prevOk || nextOk) { + if titleOk && (linkOk || prevOk || nextOk) { hb.WriteElementOpen("p") if prevOk { hb.WriteElementOpen("a", "href", prev) hb.WriteEscaped("←") hb.WriteElementClose("a") + hb.WriteEscaped(" ") + } + if linkOk { + hb.WriteElementOpen("a", "href", link) + } + hb.WriteEscaped(title) + if linkOk { + hb.WriteElementClose("a") } - hb.WriteEscaped(" " + title + " ") if nextOk { + hb.WriteEscaped(" ") hb.WriteElementOpen("a", "href", next) hb.WriteEscaped("→") hb.WriteElementClose("a")