Merge pull request #640 from trheyi/main

refactor: Create context if not exists in SUI page build
This commit is contained in:
Max 2024-07-02 20:52:28 +08:00 committed by GitHub
commit 1b19f3d0ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,11 @@ var langAttrRe = regexp.MustCompile(`'::(.*?)'`)
// Build is the struct for the public
func (page *Page) Build(ctx *BuildContext, option *BuildOption) (*goquery.Document, []string, error) {
// Create the context if not exists
if ctx == nil {
ctx = NewBuildContext(nil)
}
warnings := []string{}
html, err := page.BuildHTML(option)
if err != nil {
@ -34,9 +39,6 @@ func (page *Page) Build(ctx *BuildContext, option *BuildOption) (*goquery.Docume
warnings = append(warnings, err.Error())
}
// Add components scripts and styles
ctx.doc = doc
// Append the nested html
err = page.parse(ctx, doc, option, warnings)
if err != nil {