[add] sui build IgnoreDocument support

This commit is contained in:
Max 2023-11-29 21:29:44 +08:00
parent 4015573f5b
commit 46b20bb778
3 changed files with 9 additions and 3 deletions

View file

@ -41,10 +41,14 @@ func (page *Page) Build(option *BuildOption) (*goquery.Document, []string, error
// BuildHTML build the html // BuildHTML build the html
func (page *Page) BuildHTML(option *BuildOption) (string, error) { func (page *Page) BuildHTML(option *BuildOption) (string, error) {
html := string(page.Document) html := string(page.Codes.HTML.Code)
if !option.IgnoreDocument {
html = string(page.Document)
if page.Codes.HTML.Code != "" { if page.Codes.HTML.Code != "" {
html = strings.Replace(html, "{{ __page }}", page.Codes.HTML.Code, 1) html = strings.Replace(html, "{{ __page }}", page.Codes.HTML.Code, 1)
} }
}
if !option.IgnoreAssetRoot { if !option.IgnoreAssetRoot {
html = strings.ReplaceAll(html, "@assets", option.AssetRoot) html = strings.ReplaceAll(html, "@assets", option.AssetRoot)

View file

@ -42,6 +42,7 @@ func (page *Page) EditorRender() (*ResponseEditorRender, error) {
doc, warnings, err := page.Build(&BuildOption{ doc, warnings, err := page.Build(&BuildOption{
SSR: true, SSR: true,
IgnoreAssetRoot: true, IgnoreAssetRoot: true,
IgnoreDocument: true,
}) })
if err != nil { if err != nil {

View file

@ -140,6 +140,7 @@ type BuildOption struct {
UpdateAll bool `json:"update_all"` UpdateAll bool `json:"update_all"`
AssetRoot string `json:"asset_root,omitempty"` AssetRoot string `json:"asset_root,omitempty"`
IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"` IgnoreAssetRoot bool `json:"ignore_asset_root,omitempty"`
IgnoreDocument bool `json:"ignore_document,omitempty"`
} }
// Request is the struct for the request // Request is the struct for the request