diff --git a/Sources/ToucanSDK/PageBundle/PageBundle.swift b/Sources/ToucanSDK/PageBundle/PageBundle.swift index bc547607..d14f3afa 100644 --- a/Sources/ToucanSDK/PageBundle/PageBundle.swift +++ b/Sources/ToucanSDK/PageBundle/PageBundle.swift @@ -18,6 +18,7 @@ struct PageBundle { let id: String let url: URL + let baseUrl: String let slug: String let permalink: String @@ -48,7 +49,7 @@ struct PageBundle { return path } let src = String(path.dropFirst(prefix.count)) - return "/" + config.assets.folder + "/" + assetsLocation + "/" + src + return baseUrl + config.assets.folder + "/" + assetsLocation + "/" + src } // MARK: - diff --git a/Sources/ToucanSDK/PageBundle/PageBundleLoader.swift b/Sources/ToucanSDK/PageBundle/PageBundleLoader.swift index ae9cceff..84b17063 100644 --- a/Sources/ToucanSDK/PageBundle/PageBundleLoader.swift +++ b/Sources/ToucanSDK/PageBundle/PageBundleLoader.swift @@ -163,6 +163,7 @@ public struct PageBundleLoader { return .init( id: id, url: dirUrl, + baseUrl: sourceConfig.site.baseUrl, slug: slug, permalink: slug.permalink( baseUrl: sourceConfig.site.baseUrl diff --git a/Sources/ToucanSDK/Renderers/HTMLRenderer.swift b/Sources/ToucanSDK/Renderers/HTMLRenderer.swift index 95421957..f71c1e4c 100644 --- a/Sources/ToucanSDK/Renderers/HTMLRenderer.swift +++ b/Sources/ToucanSDK/Renderers/HTMLRenderer.swift @@ -266,6 +266,7 @@ struct HTMLRenderer { let finalBundle = PageBundle( id: pageBundle.id, url: pageBundle.url, + baseUrl: source.sourceConfig.site.baseUrl, slug: finalSlug, permalink: finalSlug.permalink( baseUrl: source.sourceConfig.site.baseUrl diff --git a/Tests/ToucanSDKTests/Mocks/PageBundle+Mocks.swift b/Tests/ToucanSDKTests/Mocks/PageBundle+Mocks.swift index 3de89666..4fc37cbf 100644 --- a/Tests/ToucanSDKTests/Mocks/PageBundle+Mocks.swift +++ b/Tests/ToucanSDKTests/Mocks/PageBundle+Mocks.swift @@ -14,6 +14,7 @@ extension PageBundle { static let post1 = PageBundle( id: "post-1", url: URL(fileURLWithPath: "/"), + baseUrl: "http://localhost:3000/", slug: "post-1", permalink: "post-1", title: "Post 1", @@ -59,6 +60,7 @@ extension PageBundle { static let author1 = PageBundle( id: "author-1", url: URL(fileURLWithPath: "/"), + baseUrl: "http://localhost:3000/", slug: "author-1", permalink: "author-1", title: "Author 1", @@ -101,6 +103,7 @@ extension PageBundle { static let page1 = PageBundle( id: "page-1", url: URL(fileURLWithPath: "/"), + baseUrl: "http://localhost:3000/", slug: "page-1", permalink: "page-1", title: "Page 1",