Skip to content

Commit

Permalink
API fixes (#57)
Browse files Browse the repository at this point in the history
- only create api folder if needed
- disable page api by default
- 1.0.0-beta.2 version bump
  • Loading branch information
tib authored Dec 12, 2024
1 parent d50b7d3 commit d46df7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Watch the source folder to any changes, to automatically re-generate the site.
toucan watch ./src ./docs --base-url http://localhost:3000/
```

NOTE: version 1.0.0-beta.1 watch command only supports macOS, Linux support is coming soon.
NOTE: version 1.0.0-beta.2 watch command only supports macOS, Linux support is coming soon.

### serve

Expand Down
2 changes: 1 addition & 1 deletion Sources/ToucanSDK/ContentType/ContentType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extension ContentType {

static let `default` = ContentType(
id: "page",
api: "pages",
api: nil,
rss: nil,
location: nil,
template: "pages.default",
Expand Down
17 changes: 11 additions & 6 deletions Sources/ToucanSDK/Renderers/APIRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ struct APIRenderer {
// MARK: - render related methods

func render() throws {
let hasAPIOutput = !source.contentTypes
.compactMap { $0.api }
.filter { !$0.isEmpty }
.isEmpty

guard hasAPIOutput else {
return
}
let apiUrl = destinationUrl.appendingPathComponent("api")
// TODO: check if exists
try fileManager.createDirectory(at: apiUrl)
if !fileManager.directoryExists(at: apiUrl) {
try fileManager.createDirectory(at: apiUrl)
}

// let globalContext = contextStore.getPageBundlesForSiteContext()

// let siteContext = globalContext.mapValues {
// $0.map { contextStore.fullContext(for: $0) }
// }
Expand All @@ -69,9 +77,6 @@ struct APIRenderer {
.appendingPathComponent(api)
.appendingPathExtension("json")

// print(url)
// print(contentType.id)

let bundles = source.pageBundles
.filter { $0.contentType.id == contentType.id }
// .map { $0.baseContext }
Expand Down
2 changes: 1 addition & 1 deletion Sources/toucan-cli/Entrypoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct Entrypoint: AsyncParsableCommand {
discussion: """
A markdown-based Static Site Generator (SSG) written in Swift.
""",
version: "1.0.0-beta.1",
version: "1.0.0-beta.2",
subcommands: [
Generate.self,
Serve.self,
Expand Down

0 comments on commit d46df7e

Please sign in to comment.