Skip to content

Commit

Permalink
Merge pull request #448 from JPToroDev/012925a
Browse files Browse the repository at this point in the history
Fix shared `PublishingContext` being called before initialization when error present in `parseContent()`. #445
  • Loading branch information
JPToroDev authored Feb 1, 2025
2 parents b73d396 + 2c50ae0 commit 99fa41d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions Sources/Ignite/Framework/Content.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,10 @@ public struct Content {
/// relative path to this content.
/// - resourceValues: Resource values that provide the creation and
/// last modification date for this content.
init(
from url: URL,
in context: PublishingContext,
resourceValues: URLResourceValues
) throws {
init(from url: URL, resourceValues: URLResourceValues) throws {
// Use whatever Markdown renderer was configured
// for the site we're publishing.
let context = PublishingContext.default
let parser = try context.site.markdownRenderer.init(url: url, removeTitleFromBody: true)

body = parser.body
Expand Down
5 changes: 2 additions & 3 deletions Sources/Ignite/Publishing/PublishingContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ final class PublishingContext {
fontsDirectory = sourceDirectory.appending(path: "Fonts")
contentDirectory = sourceDirectory.appending(path: "Content")
includesDirectory = sourceDirectory.appending(path: "Includes")

try parseContent()
}

/// Creates and sets the shared instance of `PublishingContext`
Expand Down Expand Up @@ -164,7 +162,7 @@ final class PublishingContext {
if objectURL.pathExtension == "md" {
let values = try objectURL.resourceValues(forKeys: [.creationDateKey, .contentModificationDateKey])

let article = try Content(from: objectURL, in: self, resourceValues: values)
let article = try Content(from: objectURL, resourceValues: values)

if article.isPublished {
allContent.append(article)
Expand All @@ -181,6 +179,7 @@ final class PublishingContext {

/// Performs all steps required to publish a site.
func publish() async throws {
try parseContent()
clearBuildFolder()
await generateContent()
copyResources()
Expand Down

0 comments on commit 99fa41d

Please sign in to comment.