From 46b20bb778d7a65eacc1a6c0f5aebcfc90697a31 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 29 Nov 2023 21:29:44 +0800 Subject: [PATCH] [add] sui build IgnoreDocument support --- sui/core/build.go | 10 +++++++--- sui/core/editor.go | 1 + sui/core/types.go | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sui/core/build.go b/sui/core/build.go index f9dbfdf2..f9740285 100644 --- a/sui/core/build.go +++ b/sui/core/build.go @@ -41,9 +41,13 @@ func (page *Page) Build(option *BuildOption) (*goquery.Document, []string, error // BuildHTML build the html func (page *Page) BuildHTML(option *BuildOption) (string, error) { - html := string(page.Document) - if page.Codes.HTML.Code != "" { - html = strings.Replace(html, "{{ __page }}", page.Codes.HTML.Code, 1) + html := string(page.Codes.HTML.Code) + + if !option.IgnoreDocument { + html = string(page.Document) + if page.Codes.HTML.Code != "" { + html = strings.Replace(html, "{{ __page }}", page.Codes.HTML.Code, 1) + } } if !option.IgnoreAssetRoot { diff --git a/sui/core/editor.go b/sui/core/editor.go index baf1737d..78c94023 100644 --- a/sui/core/editor.go +++ b/sui/core/editor.go @@ -42,6 +42,7 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) { doc, warnings, err := page.Build(&BuildOption{ SSR: true, IgnoreAssetRoot: true, + IgnoreDocument: true, }) if err != nil { diff --git a/sui/core/types.go b/sui/core/types.go index c5ffa742..4c396548 100644 --- a/sui/core/types.go +++ b/sui/core/types.go @@ -140,6 +140,7 @@ type BuildOption struct { UpdateAll bool `json:"update_all"` AssetRoot string `json:"asset_root,omitempty"` IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"` + IgnoreDocument bool `json:"ignore_document,omitempty"` } // Request is the struct for the request