Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
79a7d01
Add trailing slash to sitemap URLs to avoid unnecessary redirects.
mwermeester Dec 22, 2020
fafe7ba
Merge branch 'master' into add-trailing-slash-to-sitemap-urls
mwermeester May 4, 2021
29e144c
Add back accidentally deleted locations.
mwermeester May 11, 2021
ff888dc
Merge branch 'JohnSundell:master' into add-trailing-slash-to-sitemap-…
mwermeester May 11, 2021
bd4cffa
Merge branch 'JohnSundell:master' into add-trailing-slash-to-sitemap-…
mwermeester Jul 3, 2021
5200019
Merge branch 'JohnSundell:master' into add-trailing-slash-to-sitemap-…
mwermeester Aug 27, 2022
c184931
Make async versions of `publish` public
yonihemi Mar 5, 2023
815b497
Fixed typo
Mar 12, 2023
d0ac447
Merge pull request #144 from ramzesenok/master
JohnSundell Apr 7, 2023
fb0e911
Merge pull request #143 from yonihemi/public_async
JohnSundell Apr 7, 2023
fdcce6a
Update packages.
mwermeester Apr 9, 2023
82e7c74
Merge branch 'master' into add-trailing-slash-to-sitemap-urls
mwermeester Apr 11, 2023
58e9430
Foundation theme: Add margin to tags (#133)
uhooi Apr 15, 2023
f48eb1c
Merge branch 'JohnSundell:master' into master
mwermeester Apr 22, 2023
fbfb25a
Merge branch 'JohnSundell:master' into add-trailing-slash-to-sitemap-…
mwermeester Apr 22, 2023
c83950d
Merge branch 'master' into add-trailing-slash-to-sitemap-urls
mwermeester Apr 22, 2023
9079d39
Merge from upstream.
mwermeester Apr 22, 2023
6cdad37
Fix Plot package version.
mwermeester Apr 22, 2023
dcd15af
Fix Plot package version.
mwermeester Apr 22, 2023
8fe6b2f
Fix resolved Plot package version.
mwermeester Apr 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Resources/FoundationTheme/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ a {
}

.tag-list {
margin-bottom: 15px;
margin-bottom: 10px;
}

.tag-list li,
Expand All @@ -113,6 +113,7 @@ a {
padding: 4px 6px;
border-radius: 5px;
margin-right: 5px;
margin-bottom: 5px;
}

.tag-list a,
Expand All @@ -136,6 +137,7 @@ a {
.all-tags li {
font-size: 1.4em;
margin-right: 10px;
margin-bottom: 10px;
padding: 6px 10px;
}

Expand Down
16 changes: 8 additions & 8 deletions Sources/Publish/API/Theme+Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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)
Expand All @@ -49,7 +49,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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)
Expand All @@ -67,7 +67,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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")
Expand All @@ -87,7 +87,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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()
}
Expand All @@ -100,7 +100,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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
Expand All @@ -124,7 +124,7 @@ private struct FoundationHTMLFactory<Site: Website>: 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 ")
Expand Down Expand Up @@ -161,7 +161,7 @@ private struct Wrapper: ComponentContainer {

private struct SiteHeader<Site: Website>: Component {
var context: PublishingContext<Site>
var selectedSelectionID: Site.SectionID?
var selectedSectionID: Site.SectionID?

var body: Component {
Header {
Expand All @@ -184,7 +184,7 @@ private struct SiteHeader<Site: Website>: Component {
return Link(section.title,
url: section.path.absoluteString
)
.class(sectionID == selectedSelectionID ? "selected" : "")
.class(sectionID == selectedSectionID ? "selected" : "")
}
}
}
Expand Down
61 changes: 61 additions & 0 deletions Sources/Publish/API/Website.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>,
indentation: Indentation.Kind? = nil,
at path: Path? = nil,
rssFeedSections: Set<SectionID> = Set(SectionID.allCases),
rssFeedConfig: RSSFeedConfiguration? = .default,
deployedUsing deploymentMethod: DeploymentMethod<Self>? = nil,
additionalSteps: [PublishingStep<Self>] = [],
plugins: [Plugin<Self>] = [],
file: StaticString = #file) async throws -> PublishedWebsite<Self> {
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<Self>],
file: StaticString = #file) async throws -> PublishedWebsite<Self> {
let pipeline = PublishingPipeline(
steps: steps,
originFilePath: Path("\(file)")
)
return try await pipeline.execute(for: self, at: path)
}
}

// MARK: - Paths and URLs
Expand Down
6 changes: 3 additions & 3 deletions Sources/Publish/Internal/SiteMapGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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(
Expand All @@ -57,7 +57,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)
Expand All @@ -71,7 +71,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)
Expand Down
26 changes: 13 additions & 13 deletions Tests/PublishTests/Tests/SiteMapGenerationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -56,19 +56,19 @@ final class SiteMapGenerationTests: PublishTestCase {
let siteMap = try file.readAsString()

let expectedLocations = [
"https://swiftbysundell.com/one",
"https://swiftbysundell.com/one/itemA",
"https://swiftbysundell.com/three/itemE",
"https://swiftbysundell.com/pageA"
"https://swiftbysundell.com/one/",
"https://swiftbysundell.com/one/itemA/",
"https://swiftbysundell.com/three/itemE/",
"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/three/posts/itemF",
"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/three/posts/itemF/",
"https://swiftbysundell.com/pageB/"
]

for location in expectedLocations {
Expand Down