-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
Sources/ContributeWordPress/MarkdownProcessor+Starter.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import Contribute | ||
import Foundation | ||
import SyndiKit | ||
import Yams | ||
|
||
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
|
||
extension MarkdownProcessor where ContentURLGeneratorType == SectionContentURLGenerator, | ||
MarkdownContentBuilderType == MarkdownContentYAMLBuilder< | ||
Source, | ||
FilteredHTMLMarkdownExtractor<Source>, | ||
FrontMatterYAMLExporter<Source, SpecFrontMatterTranslator> | ||
> { | ||
public static func begin( | ||
importFrom exportsDirectoryURL: URL, | ||
to rootPublishSiteURL: URL, | ||
usingGenerator markdownGenerator: MarkdownGenerator, | ||
filteringPostsWith postFilters: [PostFilter] = .default, | ||
redirectsFormattedUsing redirectFromatter: RedirectFormatter? = nil, | ||
importAssetsBy assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false | ||
) throws { | ||
let settings = Settings( | ||
rootPublishSiteURL: rootPublishSiteURL, | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
markdownGenerator: markdownGenerator, | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets | ||
) | ||
let processor = MarkdownProcessor( | ||
postFilters: postFilters, | ||
redirectFromatter: redirectFromatter | ||
) | ||
try processor.begin(withSettings: settings) | ||
} | ||
|
||
public static func begin( | ||
importFrom exportsDirectoryURL: URL, | ||
to rootPublishSiteURL: URL, | ||
filteringPostsWith postFilters: [PostFilter] = .default, | ||
redirectsFormattedUsing redirectFromatter: RedirectFormatter? = nil, | ||
importAssetsBy assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
shellOut: @escaping (String, [String]) throws -> String | ||
) throws { | ||
try begin( | ||
importFrom: exportsDirectoryURL, | ||
to: rootPublishSiteURL, | ||
usingGenerator: PandocMarkdownGenerator(shellOut: shellOut), | ||
filteringPostsWith: postFilters, | ||
redirectsFormattedUsing: redirectFromatter, | ||
importAssetsBy: assetImportSetting, | ||
overwriteAssets: overwriteAssets | ||
) | ||
} | ||
} |