Skip to content

Commit

Permalink
Remove CSS from paginated SSR components (#112).
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Jan 9, 2021
1 parent 40ca29d commit 8c3e8a2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/build/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -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).
Expand Down

0 comments on commit 8c3e8a2

Please sign in to comment.