Getting Started With Publish
Last active
September 4, 2023 17:50
-
-
Save bsrz/868d69c5e8b9bb3b1f1b9937eb08fdd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension Theme { | |
| static var hello: Self { | |
| Theme( | |
| htmlFactory: HelloHTMLFactory(), | |
| resourcePaths: ["Resources/ThemeHello/styles.css"] | |
| ) | |
| } | |
| } | |
| private struct HelloHTMLFactory<Site: Website>: HTMLFactory { | |
| func makeIndexHTML(for index: Index, context: PublishingContext<Site>) throws -> HTML { | |
| [...] | |
| } | |
| func makeSectionHTML(for section: Section<Site>, context: PublishingContext<Site>) throws -> HTML { | |
| [...] | |
| } | |
| func makeItemHTML(for item: Item<Site>, context: PublishingContext<Site>) throws -> HTML { | |
| [...] | |
| } | |
| func makePageHTML(for page: Page, context: PublishingContext<Site>) throws -> HTML { | |
| [...] | |
| } | |
| func makeTagListHTML(for page: TagListPage, context: PublishingContext<Site>) throws -> HTML? { | |
| [...] | |
| } | |
| func makeTagDetailsHTML(for page: TagDetailsPage, context: PublishingContext<Site>) throws -> HTML? { | |
| [...] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension Theme where Site == HelloPublish { | |
| static var hello: Self { | |
| Theme( | |
| htmlFactory: HelloHTMLFactory(), | |
| resourcePaths: ["Resources/ThemeHello/styles.css"] | |
| ) | |
| } | |
| } | |
| private struct HelloHTMLFactory: HTMLFactory { | |
| func makeIndexHTML(for index: Index, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| [...] | |
| } | |
| func makeSectionHTML(for section: Section<Site>, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| [...] | |
| } | |
| func makeItemHTML(for item: Item<Site>, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| [...] | |
| } | |
| func makePageHTML(for page: Page, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| [...] | |
| } | |
| func makeTagListHTML(for page: TagListPage, context: PublishingContext<HelloPublish>) throws -> HTML? { | |
| [...] | |
| } | |
| func makeTagDetailsHTML(for page: TagDetailsPage, context: PublishingContext<HelloPublish>) throws -> HTML? { | |
| [...] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func makeItemHTML(for item: Item<HelloPublish>, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| HTML( | |
| .lang(context.site.language), | |
| .head(for: item, on: context.site), | |
| .body( | |
| .class("item-page"), | |
| .components { | |
| SiteHeader(context: context, selectedSelectionID: item.sectionID) | |
| Wrapper { | |
| Article { | |
| Div(item.content.body).class("content") | |
| Span("Tagged with: ") | |
| ItemTagList(item: item, site: context.site) | |
| } | |
| } | |
| SiteFooter() | |
| } | |
| ) | |
| ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func makeItemHTML(for item: Item<HelloPublish>, context: PublishingContext<HelloPublish>) throws -> HTML { | |
| HTML( | |
| .lang(context.site.language), | |
| .head(for: item, on: context.site), | |
| .body( | |
| .class("item-page"), | |
| .components { | |
| SiteHeader(context: context, selectedSelectionID: item.sectionID) | |
| Wrapper { | |
| Article { | |
| Div("Originally written on: \(item.date)") | |
| if let updated = item.metadata.updated { | |
| Div("Updated on: \(updated)") | |
| } | |
| Div(item.content.body).class("content") | |
| Span("Tagged with: ") | |
| ItemTagList(item: item, site: context.site) | |
| } | |
| } | |
| SiteFooter() | |
| } | |
| ) | |
| ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct HelloPublish: Website { | |
| // ... | |
| struct ItemMetadata: WebsiteItemMetadata { | |
| // Add any site-specific metadata that you want to use here. | |
| } | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct HelloPublish: Website { | |
| // ... | |
| struct ItemMetadata: WebsiteItemMetadata { | |
| var updated: Date? | |
| } | |
| // ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| date: 2023-05-08 22:36 | |
| description: A description of my first post. | |
| tags: first, article | |
| --- | |
| # My first post | |
| My first post's text. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| date: 2023-05-08 22:36 | |
| description: A description of my first post. | |
| tags: first, article | |
| updated: 2023-09-04 15:00 | |
| --- | |
| # My first post | |
| My first post's text. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment