mirror of
https://github.com/kovetskiy/mark.git
synced 2026-01-22 10:47:36 +08:00
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:
parent
a334c1c1cc
commit
16f72b00bd
12
page/link.go
12
page/link.go
@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user