[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,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 {

View file

@ -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 {

View file

@ -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