Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
fix renderWidget 更合适的处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
2234839 committed Sep 12, 2021
1 parent 35e9c3d commit fa048e4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/render/ocean_press_render_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ func (r *OceanPressRender) renderWidget(node *ast.Node, entering bool) ast.WalkS
iframe := dom.Find("iframe")
src, exists := iframe.Attr("src")
if exists {
localPrefix := "http://127.0.0.1:6806/"
if strings.HasPrefix(src, localPrefix) {
src = src[len(localPrefix):]
if strings.HasSuffix(src, "/") {
src += "index.html"
} else if !strings.HasSuffix(src, ".html") {
src += "/index.html"
}
iframe.SetAttr("src", r.context.BaseEntity.RootPath()+"assets/"+src)
start := strings.Index(src, "/widgets/")
src = src[start:]
if strings.HasSuffix(src, "/") {
src += "index.html"
} else if !strings.HasSuffix(src, ".html") {
src += "/index.html"
}
iframe.SetAttr("src", r.context.BaseEntity.RootPath()+"assets/"+src)
html, err := goquery.OuterHtml(iframe)
if err == nil {
node.Tokens = []byte(html)
Expand Down

0 comments on commit fa048e4

Please sign in to comment.