Skip to content

Commit f9c49a2

Browse files
committed
feat: imrpove static site generation process
1 parent 34cf173 commit f9c49a2

File tree

5 files changed

+213
-250
lines changed

5 files changed

+213
-250
lines changed

Sources/WebUI/Core/Document.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct Document {
2222
public var stylesheets: [String]?
2323
public var theme: Theme?
2424
public let head: String?
25-
private let contentBuilder: () -> [any HTML]
25+
public let contentBuilder: () -> [any HTML]
2626

2727
/// Computed HTML content from the content builder.
2828
var content: [any HTML] {

Sources/WebUI/Core/Metadata.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public enum Locale: String {
1111

1212
public struct ThemeColor {
1313
public let light: String
14-
public let dark: String
14+
public let dark: String?
1515

16-
public init(light: String, dark: String) {
16+
public init(_ light: String, dark: String? = nil) {
1717
self.light = light
1818
self.dark = dark
1919
}
@@ -119,11 +119,13 @@ public struct Metadata {
119119
}
120120
if let themeColor {
121121
baseTags.append(
122-
"<meta name=\"theme-color\" content=\"\(themeColor.light)\" media=\"(prefers-color-scheme: light)\">"
123-
)
124-
baseTags.append(
125-
"<meta name=\"theme-color\" content=\"\(themeColor.dark)\" media=\"(prefers-color-scheme: dark)\">"
122+
"<meta name=\"theme-color\" content=\"\(themeColor.light)\" \(themeColor.dark != nil ? "media=\"(prefers-color-scheme: light)\"" : "")>"
126123
)
124+
if themeColor.dark != nil {
125+
baseTags.append(
126+
"<meta name=\"theme-color\" content=\"\(themeColor.dark)\" media=\"(prefers-color-scheme: dark)\">"
127+
)
128+
}
127129
}
128130

129131
return baseTags

Sources/WebUI/Core/StaticSite.swift

Lines changed: 0 additions & 243 deletions
This file was deleted.

0 commit comments

Comments
 (0)