From 0dbdc0b99bc0d3ee79499fcf5c0ac98e3da4544e Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 25 Jul 2024 18:05:21 +0800 Subject: [PATCH] Refactor SUI core to conditionally append page components in Compile function --- sui/core/compile.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sui/core/compile.go b/sui/core/compile.go index 0c0e053f..3624c373 100644 --- a/sui/core/compile.go +++ b/sui/core/compile.go @@ -93,8 +93,10 @@ func (page *Page) Compile(ctx *BuildContext, option *BuildOption) (string, []str } // Page Components - rawComponents, _ := jsoniter.MarshalToString(ctx.components) - body.AppendHtml("\n\n" + `\n\n") + if ctx != nil && ctx.components != nil && len(ctx.components) > 0 { + rawComponents, _ := jsoniter.MarshalToString(ctx.components) + body.AppendHtml("\n\n" + `\n\n") + } page.ReplaceDocument(doc) html, err := doc.Html()