feat: extend link resolution to support blog posts

Previously, relative markdown links only resolved to Confluence pages.
Now the lookup also searches for blog posts if a page is not found,
enabling links like [My Blog](./blog-post.md) to work correctly.
This commit is contained in:
Nikolai Emil Damm 2026-01-06 13:53:59 +01:00 committed by Manuel Rüger
parent a334c1c1cc
commit 16f72b00bd

View File

@ -202,17 +202,27 @@ func parseLinks(markdown string) []markdownLink {
return links return links
} }
// getConfluenceLink builds a stable Confluence tiny link for the given page. // getConfluenceLink builds a stable Confluence tiny link for the given page or blog post.
// Tiny links use the format {baseURL}/x/{encodedPageID} and are immune to // Tiny links use the format {baseURL}/x/{encodedPageID} and are immune to
// Cloud-specific URL variations like /ex/confluence/<cloudId>/wiki/... // Cloud-specific URL variations like /ex/confluence/<cloudId>/wiki/...
func getConfluenceLink( func getConfluenceLink(
api *confluence.API, api *confluence.API,
space, title string, space, title string,
) (string, error) { ) (string, error) {
// Try to find as a page first
page, err := api.FindPage(space, title, "page") page, err := api.FindPage(space, title, "page")
if err != nil { if err != nil {
return "", karma.Format(err, "api: find page") return "", karma.Format(err, "api: find page")
} }
// If not found as a page, try to find as a blog post
if page == nil {
page, err = api.FindPage(space, title, "blogpost")
if err != nil {
return "", karma.Format(err, "api: find blogpost")
}
}
if page == nil { if page == nil {
return "", nil return "", nil
} }