diff --git a/cmd/build/client.go b/cmd/build/client.go index 00f9b34b..f60a3185 100644 --- a/cmd/build/client.go +++ b/cmd/build/client.go @@ -309,6 +309,8 @@ func compileSvelte(ctx *v8go.Context, SSRctx *v8go.Context, layoutPath string, d makeGlobalVar := globalVar + " = " + paginationVar + ";" // Assign value to global var inside create_ssr_component() func, like: plenti_global_pager_totalPages = totalPages; ssrStr = reLocalVar.ReplaceAllString(ssrStr, "${1}\n"+makeGlobalVar) + // Clear out styles for SSR since they are already pulled from client components. + ssrStr = removeCSS(ssrStr) } } } @@ -321,6 +323,13 @@ func compileSvelte(ctx *v8go.Context, SSRctx *v8go.Context, layoutPath string, d } +func removeCSS(str string) string { + // Match var css = { ... } + reCSS := regexp.MustCompile(`var(\s)css(\s)=(\s)\{(.*\n){0,}\};`) + // Delete these styles because they often break pagination SSR. + return reCSS.ReplaceAllString(str, "") +} + func makeNameList(importNameSlice []string) []string { var namedImportNameStrs []string // Get just the name(s) of the variable(s).