mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve local image rendering in README of installed marketplace packages https://github.com/siyuan-note/siyuan/issues/14502
This commit is contained in:
parent
7ab4ccf991
commit
4b27f131ca
6 changed files with 20 additions and 9 deletions
|
@ -190,7 +190,7 @@ func InstalledIcons() (ret []*Icon) {
|
|||
continue
|
||||
}
|
||||
|
||||
icon.PreferredReadme, _ = renderREADME(icon.URL, readme)
|
||||
icon.PreferredReadme, _ = renderLocalREADME("/appearance/icons/"+dirName+"/", readme)
|
||||
icon.Outdated = isOutdatedIcon(icon, bazaarIcons)
|
||||
ret = append(ret, icon)
|
||||
}
|
||||
|
|
|
@ -688,6 +688,17 @@ func renderREADME(repoURL string, mdData []byte) (ret string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func renderLocalREADME(basePath string, mdData []byte) (ret string, err error) {
|
||||
luteEngine := lute.New()
|
||||
luteEngine.SetSoftBreak2HardBreak(false)
|
||||
luteEngine.SetCodeSyntaxHighlight(false)
|
||||
linkBase := basePath
|
||||
luteEngine.SetLinkBase(linkBase)
|
||||
ret = luteEngine.Md2HTML(string(mdData))
|
||||
ret = util.LinkTarget(ret, linkBase)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
packageLocks = map[string]*sync.Mutex{}
|
||||
packageLocksLock = sync.Mutex{}
|
||||
|
|
|
@ -227,7 +227,7 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
|
|||
continue
|
||||
}
|
||||
|
||||
plugin.PreferredReadme, _ = renderREADME(plugin.URL, readme)
|
||||
plugin.PreferredReadme, _ = renderLocalREADME("/plugins/"+dirName+"/", readme)
|
||||
plugin.Outdated = isOutdatedPlugin(plugin, bazaarPlugins)
|
||||
plugin.Incompatible = isIncompatiblePlugin(plugin, frontend)
|
||||
ret = append(ret, plugin)
|
||||
|
|
|
@ -191,7 +191,7 @@ func InstalledTemplates() (ret []*Template) {
|
|||
continue
|
||||
}
|
||||
|
||||
template.PreferredReadme, _ = renderREADME(template.URL, readme)
|
||||
template.PreferredReadme, _ = renderLocalREADME("/templates/"+dirName+"/", readme)
|
||||
template.Outdated = isOutdatedTemplate(template, bazaarTemplates)
|
||||
ret = append(ret, template)
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ func InstalledThemes() (ret []*Theme) {
|
|||
continue
|
||||
}
|
||||
|
||||
theme.PreferredReadme, _ = renderREADME(theme.URL, readme)
|
||||
theme.PreferredReadme, _ = renderLocalREADME("/appearance/themes/"+dirName+"/", readme)
|
||||
theme.Outdated = isOutdatedTheme(theme, bazaarThemes)
|
||||
ret = append(ret, theme)
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ func InstalledWidgets() (ret []*Widget) {
|
|||
continue
|
||||
}
|
||||
|
||||
widget.PreferredReadme, _ = renderREADME(widget.URL, readme)
|
||||
widget.PreferredReadme, _ = renderLocalREADME("/widgets/"+dirName+"/", readme)
|
||||
widget.Outdated = isOutdatedWidget(widget, bazaarWidgets)
|
||||
ret = append(ret, widget)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue