diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 00000000..cc146997 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,51 @@ +{ + "originHash" : "27fc44db5d602a3eb6052ee08ebaf473001ed8db7fa1b54b79f7f4682568491d", + "pins" : [ + { + "identity" : "swift-cmark", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-cmark.git", + "state" : { + "revision" : "b022b08312decdc46585e0b3440d97f6f22ef703", + "version" : "0.6.0" + } + }, + { + "identity" : "swift-docc-plugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-docc-plugin", + "state" : { + "revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64", + "version" : "1.4.3" + } + }, + { + "identity" : "swift-docc-symbolkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-docc-symbolkit", + "state" : { + "revision" : "b45d1f2ed151d057b54504d653e0da5552844e34", + "version" : "1.0.0" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa", + "version" : "1.6.3" + } + }, + { + "identity" : "swift-markdown", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-markdown", + "state" : { + "revision" : "ea79e83c8744d2b50b0dc2d5bbd1e857e1253bf9", + "version" : "0.6.0" + } + } + ], + "version" : 3 +} diff --git a/Sources/WebUI/Core/Metadata.swift b/Sources/WebUI/Core/Metadata.swift index b1984540..5c08051f 100644 --- a/Sources/WebUI/Core/Metadata.swift +++ b/Sources/WebUI/Core/Metadata.swift @@ -22,7 +22,7 @@ public struct ThemeColor { public struct Metadata { public var site: String? public var title: String? - public var titleSeperator: String + public var titleSeperator: String? public var description: String public var date: Date? public var image: String? @@ -34,13 +34,13 @@ public struct Metadata { public var themeColor: ThemeColor? public var pageTitle: String { - "\(title ?? "")\(titleSeperator)\(site ?? "")" + "\(title ?? "")\(titleSeperator ?? "")\(site ?? "")" } public init( site: String? = nil, title: String? = nil, - titleSeperator: String = " | ", + titleSeperator: String? = " ", description: String, date: Date? = nil, image: String? = nil, @@ -121,9 +121,9 @@ public struct Metadata { baseTags.append( "" ) - if themeColor.dark != nil { + if let themeDark = themeColor.dark { baseTags.append( - "" + "" ) } } diff --git a/Sources/WebUI/Core/Theme.swift b/Sources/WebUI/Core/Theme.swift index 8fc28dd7..df796bc9 100644 --- a/Sources/WebUI/Core/Theme.swift +++ b/Sources/WebUI/Core/Theme.swift @@ -215,7 +215,7 @@ public struct Theme { --breakpoint-xs: 30rem; --breakpoint-3xl: 120rem; --breakpoint-4xl: 160rem; - \(self.generateCSS() ?? "") + \(self.generateCSS()) @custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *)); } """ diff --git a/Tests/WebUITests/Core/ApplicationTests.swift b/Tests/WebUITests/Core/ApplicationTests.swift index ddb4bd58..47bbf059 100644 --- a/Tests/WebUITests/Core/ApplicationTests.swift +++ b/Tests/WebUITests/Core/ApplicationTests.swift @@ -6,7 +6,7 @@ import Testing @Suite("Application Tests") struct ApplicationTests { @Test("Creates the build directory and populates correctly") func createsAndPopulatesBuildDirectory() throws { - let app = Application( + let app = Website( routes: [ Document( path: "index", @@ -22,7 +22,7 @@ import Testing } Main { Stack { - Heading(level: .one) { "Tagline" } + Heading(.one) { "Tagline" } Text { "Lorem ipsum dolor sit amet." } } } @@ -35,7 +35,7 @@ import Testing metadata: .init(title: "About", description: "Learn more here") ) { Article { - Heading(level: .two) { "Article Heading" } + Heading(.two) { "Article Heading" } Text { "Lorem ipsum dolor sit amet." } } }, diff --git a/Tests/WebUITests/Core/DocumentTests.swift b/Tests/WebUITests/Core/DocumentTests.swift index 093e1c36..19262a91 100644 --- a/Tests/WebUITests/Core/DocumentTests.swift +++ b/Tests/WebUITests/Core/DocumentTests.swift @@ -11,6 +11,7 @@ import Testing metadata: Metadata( site: "Test Site", title: "Hello World", + titleSeperator: " | ", description: "A test description" ) ) { @@ -40,7 +41,7 @@ import Testing metadata: Metadata( site: "Test Site", title: "Full Test", - titleSeperator: "-", + titleSeperator: " - ", description: "A complete metadata test", date: Date(), image: "https://example.com/image.png", @@ -49,7 +50,7 @@ import Testing twitter: "testhandle", locale: .ru, type: .article, - themeColor: .init(light: "#0099ff", dark: "#1c1c1c"), + themeColor: .init("#0099ff", dark: "#1c1c1c"), ) ) { "Content" diff --git a/Tests/WebUITests/Core/MetadataTests.swift b/Tests/WebUITests/Core/MetadataTests.swift index 9c757ac3..02dd8aa9 100644 --- a/Tests/WebUITests/Core/MetadataTests.swift +++ b/Tests/WebUITests/Core/MetadataTests.swift @@ -11,15 +11,16 @@ struct MetadataTests { let metadata = Metadata( site: "Test Site", title: "Test Title", + titleSeperator: " | ", description: "Test description", - themeColor: .init(light: "#0099ff", dark: "#1c1c1c") + themeColor: .init("#0099ff", dark: "#1c1c1c") ) // Assert #expect(metadata.site == "Test Site") #expect(metadata.title == "Test Title") #expect(metadata.description == "Test description") - #expect(metadata.titleSeperator == "|") + #expect(metadata.titleSeperator == " | ") #expect(metadata.pageTitle == "Test Title | Test Site") #expect(metadata.locale == .en) #expect(metadata.themeColor?.light == "#0099ff") @@ -30,6 +31,7 @@ struct MetadataTests { @Test func testNoSiteMetadata() throws { let metadata = Metadata( title: "Just Title", + titleSeperator: nil, description: "No site metadata" ) @@ -42,11 +44,11 @@ struct MetadataTests { let metadata = Metadata( site: "My Site", title: "My Title", - titleSeperator: "-", + titleSeperator: " - ", description: "Custom separator test" ) - #expect(metadata.titleSeperator == "-") + #expect(metadata.titleSeperator == " - ") #expect(metadata.pageTitle == "My Title - My Site") } @@ -58,7 +60,7 @@ struct MetadataTests { let metadata = Metadata( site: "Full Site", title: "Full Title", - titleSeperator: ":", + titleSeperator: " : ", description: "Full metadata description", date: testDate, image: "/images/test.jpg", diff --git a/Tests/WebUITests/ElementTests.swift b/Tests/WebUITests/ElementTests.swift index e1e90120..88983a4d 100644 --- a/Tests/WebUITests/ElementTests.swift +++ b/Tests/WebUITests/ElementTests.swift @@ -292,9 +292,9 @@ import Testing @Test("Heading element") func testHeadingElement() async throws { - let heading1 = Heading(level: .one) { "Main Title" } - let heading2 = Heading(level: .two) { "Subtitle" } - let heading6 = Heading(level: .six) { "Small Heading" } + let heading1 = Heading(.one) { "Main Title" } + let heading2 = Heading(.two) { "Subtitle" } + let heading6 = Heading(.six) { "Small Heading" } #expect(heading1.render() == "

Main Title

") #expect(heading2.render() == "

Subtitle

") @@ -484,7 +484,7 @@ import Testing @Test("Header element") func testHeaderElement() async throws { let header = Header(id: "page-header") { - Heading(level: .one) { "Site Title" } + Heading(.one) { "Site Title" } } let rendered = header.render() @@ -551,7 +551,7 @@ import Testing @Test("Article element") func testArticleElement() async throws { let article = Article(id: "blog-post") { - Heading(level: .two) { "Article Title" } + Heading(.two) { "Article Title" } Text { "Article content" } } @@ -566,7 +566,7 @@ import Testing @Test("Section element") func testSectionElement() async throws { let section = Section(id: "features") { - Heading(level: .three) { "Features" } + Heading(.three) { "Features" } Text { "Feature list" } } @@ -649,7 +649,7 @@ import Testing func testPageLayout() async throws { let page = Fragment { Header(id: "main-header") { - Heading(level: .one) { "My Website" } + Heading(.one) { "My Website" } Navigation { List(type: .unordered, classes: ["nav-links"]) { Item { Link(to: "/") { "Home" } } @@ -660,12 +660,12 @@ import Testing } Main { Article { - Heading(level: .two) { "Welcome" } + Heading(.two) { "Welcome" } Text { "This is the main content of the page." } } } Aside(id: "sidebar") { - Heading(level: .three) { "Related Links" } + Heading(.three) { "Related Links" } List(type: .unordered) { Item { Link(to: "/link1") { "Link 1" } } Item { Link(to: "/link2") { "Link 2" } }