feat: Ports all existing articles and images.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import HTML
|
||||
import PathKit
|
||||
@preconcurrency import Saga
|
||||
import SagaParsleyMarkdownReader
|
||||
@@ -45,6 +46,12 @@ func permalink(item: Item<ArticleMetadata>) {
|
||||
item.relativeDestination = Path(components: components)
|
||||
}
|
||||
|
||||
func removingBreaks<M>(item: Item<M>) {
|
||||
// remove explicit <br /> from items that show up likely due to how prettier formats
|
||||
// markdown files inside of neovim.
|
||||
item.body = item.body.removeBreaks
|
||||
}
|
||||
|
||||
@main
|
||||
struct Run {
|
||||
static func main() async throws {
|
||||
@@ -56,14 +63,13 @@ struct Run {
|
||||
folder: "articles",
|
||||
metadata: ArticleMetadata.self,
|
||||
readers: [.parsleyMarkdownReader],
|
||||
itemProcessor: sequence(publicationDateInFilename, permalink),
|
||||
itemProcessor: sequence(removingBreaks, publicationDateInFilename, permalink),
|
||||
filter: \.public,
|
||||
writers: [
|
||||
.itemWriter(swim(renderArticle)),
|
||||
.listWriter(swim(renderArticles)),
|
||||
.tagWriter(swim(renderTag), tags: \.metadata.tags),
|
||||
.yearWriter(swim(renderYear)),
|
||||
|
||||
// Atom feed for all articles, and a feed per tag
|
||||
.listWriter(
|
||||
atomFeed(
|
||||
@@ -84,27 +90,12 @@ struct Run {
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
// All markdown files within the "apps" subfolder will be parsed to html,
|
||||
// using AppMetadata as the Item's metadata type.
|
||||
// .register(
|
||||
// folder: "apps",
|
||||
// metadata: AppMetadata.self,
|
||||
// readers: [.parsleyMarkdownReader],
|
||||
// writers: [.listWriter(swim(renderApps))]
|
||||
// )
|
||||
//
|
||||
// .register(
|
||||
// folder: "photos",
|
||||
// readers: [.parsleyMarkdownReader],
|
||||
// writers: [.itemWriter(swim(renderPhotos))]
|
||||
// )
|
||||
|
||||
// All the remaining markdown files will be parsed to html,
|
||||
// using the default EmptyMetadata as the Item's metadata type.
|
||||
.register(
|
||||
metadata: PageMetadata.self,
|
||||
readers: [.parsleyMarkdownReader],
|
||||
itemWriteMode: .keepAsFile, // need to keep 404.md as 404.html, not 404/index.html
|
||||
writers: [.itemWriter(swim(renderPage))]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user