Skip to content

Commit

Permalink
docs: Updated docs to remove the site metadata which is no longer a t…
Browse files Browse the repository at this point in the history
…hing
  • Loading branch information
kevinrenskers committed Nov 23, 2023
1 parent d60b71e commit 55bcf89
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions Sources/Saga/Saga.docc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SagaParsleyMarkdownReader
import SagaSwimRenderer
import HTML

func renderPage(context: ItemRenderingContext<EmptyMetadata, EmptyMetadata>) -> Node {
func renderPage(context: ItemRenderingContext<EmptyMetadata>) -> Node {
html(lang: "en-US") {
body {
div(id: "content") {
Expand All @@ -26,7 +26,7 @@ func renderPage(context: ItemRenderingContext<EmptyMetadata, EmptyMetadata>) ->
@main
struct Run {
static func main() async throws {
try await Saga(input: "content", output: "deploy", siteMetadata: EmptyMetadata())
try await Saga(input: "content", output: "deploy")
// All Markdown files within the `input` folder will be parsed to html.
.register(
metadata: EmptyMetadata.self,
Expand Down Expand Up @@ -77,7 +77,7 @@ images: lastfm_1.jpg, lastfm_2.jpg

As you can see, they both use different metadata: the article has `tags`, a `summary` and a `date`, while the app has a `url` and `images`.

Let's configure Saga to render these files, while also adding a `SiteMetadata` type that will be given to each template.
Let's configure Saga to render these files.

```swift
struct ArticleMetadata: Metadata {
Expand All @@ -90,22 +90,10 @@ struct AppMetadata: Metadata {
let images: [String]?
}

// SiteMetadata is given to every rendering context.
// You can put whatever properties you want in here.
struct SiteMetadata: Metadata {
let url: URL
let name: String
}

let siteMetadata = SiteMetadata(
url: URL(string: "http://www.example.com")!,
name: "Example website"
)

@main
struct Run {
static func main() async throws {
try await Saga(input: "content", output: "deploy", siteMetadata: siteMetadata)
try await Saga(input: "content", output: "deploy")
// All Markdown files within the "articles" subfolder will be parsed to html,
// using `ArticleMetadata` as the item's metadata type.
.register(
Expand Down

0 comments on commit 55bcf89

Please sign in to comment.