From a815c291074b454d4bb1a31067cd363c84df1360 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 12 Dec 2025 19:21:22 +0100 Subject: refactor(frontend): remove JS files --- backend/parser.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'backend/parser.go') diff --git a/backend/parser.go b/backend/parser.go index c7d6445..b8e730b 100644 --- a/backend/parser.go +++ b/backend/parser.go @@ -18,6 +18,23 @@ type EntryInfo struct { PubLocalDate toml.LocalDate `toml:"publication_date"` } +func renderLinkFunc(url string) func(string, string) template.HTML { + return func(content, href string) template.HTML { + b := "%s`, b, href, content)) + } +} + +func renderLink(content, href, url string) template.HTML { + return renderLinkFunc(url)(content, href) +} + func parse(b []byte, info *EntryInfo, d *data) (template.HTML, bool) { var dd string splits := strings.SplitN(string(b), "---", 2) @@ -31,7 +48,10 @@ func parse(b []byte, info *EntryInfo, d *data) (template.HTML, bool) { } else { dd = string(b) } - content, err := markdown.Parse(dd, &markdown.Option{ImageSource: getStatic}) + opt := new(markdown.Option) + opt.ImageSource = getStatic + opt.RenderLink = renderLinkFunc(d.URL) + content, err := markdown.Parse(dd, opt) var errMd *markdown.ParseError errors.As(err, &errMd) if errMd != nil { -- cgit v1.2.3