From 79a7d01258957a7a552d1051596dc1342236abf7 Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Tue, 22 Dec 2020 23:46:21 +0100 Subject: [PATCH 01/10] Add trailing slash to sitemap URLs to avoid unnecessary redirects. --- .../Publish/Internal/SiteMapGenerator.swift | 6 ++--- .../Tests/SiteMapGenerationTests.swift | 22 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Sources/Publish/Internal/SiteMapGenerator.swift b/Sources/Publish/Internal/SiteMapGenerator.swift index b196c7d4..80a89c1b 100644 --- a/Sources/Publish/Internal/SiteMapGenerator.swift +++ b/Sources/Publish/Internal/SiteMapGenerator.swift @@ -37,7 +37,7 @@ private extension SiteMapGenerator { return .group( .url( - .loc(site.url(for: section)), + .loc(site.url(for: section).appendingPathComponent("/")), .changefreq(.daily), .priority(1.0), .lastmod(max( @@ -51,7 +51,7 @@ private extension SiteMapGenerator { } return .url( - .loc(site.url(for: item)), + .loc(site.url(for: item).appendingPathComponent("/")), .changefreq(.monthly), .priority(0.5), .lastmod(item.lastModified) @@ -65,7 +65,7 @@ private extension SiteMapGenerator { } return .url( - .loc(site.url(for: page)), + .loc(site.url(for: page).appendingPathComponent("/")), .changefreq(.monthly), .priority(0.5), .lastmod(page.lastModified) diff --git a/Tests/PublishTests/Tests/SiteMapGenerationTests.swift b/Tests/PublishTests/Tests/SiteMapGenerationTests.swift index eefe808e..0970ae6d 100644 --- a/Tests/PublishTests/Tests/SiteMapGenerationTests.swift +++ b/Tests/PublishTests/Tests/SiteMapGenerationTests.swift @@ -22,9 +22,9 @@ final class SiteMapGenerationTests: PublishTestCase { let siteMap = try file.readAsString() let expectedLocations = [ - "https://swiftbysundell.com/one", - "https://swiftbysundell.com/one/item", - "https://swiftbysundell.com/page" + "https://swiftbysundell.com/one/", + "https://swiftbysundell.com/one/item/", + "https://swiftbysundell.com/page/" ] for location in expectedLocations { @@ -53,17 +53,17 @@ final class SiteMapGenerationTests: PublishTestCase { let siteMap = try file.readAsString() let expectedLocations = [ - "https://swiftbysundell.com/one", - "https://swiftbysundell.com/one/itemA", - "https://swiftbysundell.com/pageA" + "https://swiftbysundell.com/one/", + "https://swiftbysundell.com/one/itemA/", + "https://swiftbysundell.com/pageA/" ] let unexpectedLocations = [ - "https://swiftbysundell.com/one/itemB", - "https://swiftbysundell.com/two", - "https://swiftbysundell.com/two/itemC", - "https://swiftbysundell.com/two/itemD", - "https://swiftbysundell.com/pageB" + "https://swiftbysundell.com/one/itemB/", + "https://swiftbysundell.com/two/", + "https://swiftbysundell.com/two/itemC/", + "https://swiftbysundell.com/two/itemD/", + "https://swiftbysundell.com/pageB/" ] for location in expectedLocations { From 29e144cc23e75b8acc9664cd4688d4e2d1320f7b Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Wed, 12 May 2021 01:56:01 +0200 Subject: [PATCH 02/10] Add back accidentally deleted locations. Add back locations that got accidentally deleted. --- Tests/PublishTests/Tests/SiteMapGenerationTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/PublishTests/Tests/SiteMapGenerationTests.swift b/Tests/PublishTests/Tests/SiteMapGenerationTests.swift index 8b18f551..6cd847a3 100644 --- a/Tests/PublishTests/Tests/SiteMapGenerationTests.swift +++ b/Tests/PublishTests/Tests/SiteMapGenerationTests.swift @@ -58,6 +58,7 @@ final class SiteMapGenerationTests: PublishTestCase { let expectedLocations = [ "https://swiftbysundell.com/one/", "https://swiftbysundell.com/one/itemA/", + "https://swiftbysundell.com/three/itemE/", "https://swiftbysundell.com/pageA/" ] @@ -66,6 +67,7 @@ final class SiteMapGenerationTests: PublishTestCase { "https://swiftbysundell.com/two/", "https://swiftbysundell.com/two/itemC/", "https://swiftbysundell.com/two/itemD/", + "https://swiftbysundell.com/three/posts/itemF/", "https://swiftbysundell.com/pageB/" ] From c184931839fe61fb8b4076ef6a73d8608c0ec72e Mon Sep 17 00:00:00 2001 From: yonihemi Date: Sun, 5 Mar 2023 10:50:41 +0800 Subject: [PATCH 03/10] Make async versions of `publish` public --- Sources/Publish/API/Website.swift | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Sources/Publish/API/Website.swift b/Sources/Publish/API/Website.swift index a44bd1e6..fd4c5b8c 100644 --- a/Sources/Publish/API/Website.swift +++ b/Sources/Publish/API/Website.swift @@ -130,6 +130,67 @@ public extension Website { semaphore.wait() return try result!.get() } + + /// Publish this website using a default pipeline. To build a completely + /// custom pipeline, use the `publish(using:)` method. + /// - parameter theme: The HTML theme to generate the website using. + /// - parameter indentation: How to indent the generated files. + /// - parameter path: Any specific path to generate the website at. + /// - parameter rssFeedSections: What sections to include in the site's RSS feed. + /// - parameter rssFeedConfig: The configuration to use for the site's RSS feed. + /// - parameter deploymentMethod: How to deploy the website. + /// - parameter additionalSteps: Any additional steps to add to the publishing + /// pipeline. Will be executed right before the HTML generation process begins. + /// - parameter plugins: Plugins to be installed at the start of the publishing process. + /// - parameter file: The file that this method is called from (auto-inserted). + /// - parameter line: The line that this method is called from (auto-inserted). + @discardableResult + func publish(withTheme theme: Theme, + indentation: Indentation.Kind? = nil, + at path: Path? = nil, + rssFeedSections: Set = Set(SectionID.allCases), + rssFeedConfig: RSSFeedConfiguration? = .default, + deployedUsing deploymentMethod: DeploymentMethod? = nil, + additionalSteps: [PublishingStep] = [], + plugins: [Plugin] = [], + file: StaticString = #file) async throws -> PublishedWebsite { + try await publish( + at: path, + using: [ + .group(plugins.map(PublishingStep.installPlugin)), + .optional(.copyResources()), + .addMarkdownFiles(), + .sortItems(by: \.date, order: .descending), + .group(additionalSteps), + .generateHTML(withTheme: theme, indentation: indentation), + .unwrap(rssFeedConfig) { config in + .generateRSSFeed( + including: rssFeedSections, + config: config + ) + }, + .generateSiteMap(indentedBy: indentation), + .unwrap(deploymentMethod, PublishingStep.deploy) + ], + file: file + ) + } + + /// Publish this website using a custom pipeline. + /// - parameter path: Any specific path to generate the website at. + /// - parameter steps: The steps to use to form the website's publishing pipeline. + /// - parameter file: The file that this method is called from (auto-inserted). + /// - parameter line: The line that this method is called from (auto-inserted). + @discardableResult + func publish(at path: Path? = nil, + using steps: [PublishingStep], + file: StaticString = #file) async throws -> PublishedWebsite { + let pipeline = PublishingPipeline( + steps: steps, + originFilePath: Path("\(file)") + ) + return try await pipeline.execute(for: self, at: path) + } } // MARK: - Paths and URLs From 815b497bf59d2c43e0a8cd305f86bbfb7603b8b4 Mon Sep 17 00:00:00 2001 From: Roman Mirzoyan Date: Sun, 12 Mar 2023 10:57:36 +0100 Subject: [PATCH 04/10] Fixed typo --- Sources/Publish/API/Theme+Foundation.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/Publish/API/Theme+Foundation.swift b/Sources/Publish/API/Theme+Foundation.swift index d815219b..39cdcbb4 100644 --- a/Sources/Publish/API/Theme+Foundation.swift +++ b/Sources/Publish/API/Theme+Foundation.swift @@ -24,7 +24,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .lang(context.site.language), .head(for: index, on: context.site), .body { - SiteHeader(context: context, selectedSelectionID: nil) + SiteHeader(context: context, selectedSectionID: nil) Wrapper { H1(index.title) Paragraph(context.site.description) @@ -49,7 +49,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .lang(context.site.language), .head(for: section, on: context.site), .body { - SiteHeader(context: context, selectedSelectionID: section.id) + SiteHeader(context: context, selectedSectionID: section.id) Wrapper { H1(section.title) ItemList(items: section.items, site: context.site) @@ -67,7 +67,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .body( .class("item-page"), .components { - SiteHeader(context: context, selectedSelectionID: item.sectionID) + SiteHeader(context: context, selectedSectionID: item.sectionID) Wrapper { Article { Div(item.content.body).class("content") @@ -87,7 +87,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .lang(context.site.language), .head(for: page, on: context.site), .body { - SiteHeader(context: context, selectedSelectionID: nil) + SiteHeader(context: context, selectedSectionID: nil) Wrapper(page.body) SiteFooter() } @@ -100,7 +100,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .lang(context.site.language), .head(for: page, on: context.site), .body { - SiteHeader(context: context, selectedSelectionID: nil) + SiteHeader(context: context, selectedSectionID: nil) Wrapper { H1("Browse all tags") List(page.tags.sorted()) { tag in @@ -124,7 +124,7 @@ private struct FoundationHTMLFactory: HTMLFactory { .lang(context.site.language), .head(for: page, on: context.site), .body { - SiteHeader(context: context, selectedSelectionID: nil) + SiteHeader(context: context, selectedSectionID: nil) Wrapper { H1 { Text("Tagged with ") @@ -161,7 +161,7 @@ private struct Wrapper: ComponentContainer { private struct SiteHeader: Component { var context: PublishingContext - var selectedSelectionID: Site.SectionID? + var selectedSectionID: Site.SectionID? var body: Component { Header { @@ -184,7 +184,7 @@ private struct SiteHeader: Component { return Link(section.title, url: section.path.absoluteString ) - .class(sectionID == selectedSelectionID ? "selected" : "") + .class(sectionID == selectedSectionID ? "selected" : "") } } } From fdcce6ab6294ec8047ae658812941b5e9756157c Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Sun, 9 Apr 2023 23:49:52 +0200 Subject: [PATCH 05/10] Update packages. --- Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.resolved b/Package.resolved index d3d55a8b..6377475b 100644 --- a/Package.resolved +++ b/Package.resolved @@ -42,8 +42,8 @@ "repositoryURL": "https://github.com/johnsundell/plot.git", "state": { "branch": null, - "revision": "80612b34252188edbef280e5375e2fc5249ac770", - "version": "0.9.0" + "revision": "4237057acdaaea5def56d350815e37fa8311d1fd", + "version": "0.13.0" } }, { From 58e943047882a5a6d8135ae2711be8ba7fba57c4 Mon Sep 17 00:00:00 2001 From: uhooi Date: Sat, 15 Apr 2023 16:55:09 +0900 Subject: [PATCH 06/10] Foundation theme: Add margin to tags (#133) --- Resources/FoundationTheme/styles.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Resources/FoundationTheme/styles.css b/Resources/FoundationTheme/styles.css index a6858fc9..f08b6caa 100644 --- a/Resources/FoundationTheme/styles.css +++ b/Resources/FoundationTheme/styles.css @@ -102,7 +102,7 @@ a { } .tag-list { - margin-bottom: 15px; + margin-bottom: 10px; } .tag-list li, @@ -113,6 +113,7 @@ a { padding: 4px 6px; border-radius: 5px; margin-right: 5px; + margin-bottom: 5px; } .tag-list a, @@ -136,6 +137,7 @@ a { .all-tags li { font-size: 1.4em; margin-right: 10px; + margin-bottom: 10px; padding: 6px 10px; } From 9079d39fbd804f2e2659c9d70183f0b6c3f26897 Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Sat, 22 Apr 2023 15:48:46 +0200 Subject: [PATCH 07/10] Merge from upstream. --- Package.resolved | 14 +++++++------- Package.swift | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Package.resolved b/Package.resolved index 6377475b..798d8042 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/johnsundell/collectionConcurrencyKit.git", "state": { "branch": null, - "revision": "2e4984dcaed6432f4eff175f6616ba463428cd8a", - "version": "0.1.0" + "revision": "b4f23e24b5a1bff301efc5e70871083ca029ff95", + "version": "0.2.0" } }, { @@ -33,17 +33,17 @@ "repositoryURL": "https://github.com/johnsundell/ink.git", "state": { "branch": null, - "revision": "77c3d8953374a9cf5418ef0bd7108524999de85a", - "version": "0.5.1" + "revision": "bcc9f219900a62c4210e6db726035d7f03ae757b", + "version": "0.6.0" } }, { "package": "Plot", "repositoryURL": "https://github.com/johnsundell/plot.git", "state": { - "branch": null, - "revision": "4237057acdaaea5def56d350815e37fa8311d1fd", - "version": "0.13.0" + "branch": "0.9.0", + "revision": "80612b34252188edbef280e5375e2fc5249ac770", + "version": null } }, { diff --git a/Package.swift b/Package.swift index f81064cc..24cd23d7 100644 --- a/Package.swift +++ b/Package.swift @@ -24,7 +24,7 @@ let package = Package( .package( name: "Plot", url: "https://github.com/johnsundell/plot.git", - from: "0.9.0" + revision: "0.9.0" ), .package( name: "Files", From 6cdad3769401892c04be84ccb455993013a7ec7e Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Sat, 22 Apr 2023 21:42:12 +0200 Subject: [PATCH 08/10] Fix Plot package version. --- Package.resolved | 6 +++--- Package.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.resolved b/Package.resolved index 798d8042..f9eb5b46 100644 --- a/Package.resolved +++ b/Package.resolved @@ -41,9 +41,9 @@ "package": "Plot", "repositoryURL": "https://github.com/johnsundell/plot.git", "state": { - "branch": "0.9.0", - "revision": "80612b34252188edbef280e5375e2fc5249ac770", - "version": null + "branch": null, + "revision": "4237057acdaaea5def56d350815e37fa8311d1fd", + "version": "0.13.0" } }, { diff --git a/Package.swift b/Package.swift index 24cd23d7..f81064cc 100644 --- a/Package.swift +++ b/Package.swift @@ -24,7 +24,7 @@ let package = Package( .package( name: "Plot", url: "https://github.com/johnsundell/plot.git", - revision: "0.9.0" + from: "0.9.0" ), .package( name: "Files", From dcd15af906900a7c615a60514763e1799d7388f7 Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Sat, 22 Apr 2023 21:48:10 +0200 Subject: [PATCH 09/10] Fix Plot package version. --- Package.resolved | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index f9eb5b46..798d8042 100644 --- a/Package.resolved +++ b/Package.resolved @@ -41,9 +41,9 @@ "package": "Plot", "repositoryURL": "https://github.com/johnsundell/plot.git", "state": { - "branch": null, - "revision": "4237057acdaaea5def56d350815e37fa8311d1fd", - "version": "0.13.0" + "branch": "0.9.0", + "revision": "80612b34252188edbef280e5375e2fc5249ac770", + "version": null } }, { From 8fe6b2f8a22dd0d8cef53a898b8f52273957995d Mon Sep 17 00:00:00 2001 From: Michael Wermeester Date: Sat, 22 Apr 2023 21:57:47 +0200 Subject: [PATCH 10/10] Fix resolved Plot package version. --- Package.resolved | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.resolved b/Package.resolved index 798d8042..6c2cce60 100644 --- a/Package.resolved +++ b/Package.resolved @@ -43,7 +43,7 @@ "state": { "branch": "0.9.0", "revision": "80612b34252188edbef280e5375e2fc5249ac770", - "version": null + "version": "0.9.0" } }, {