Refactor page content generators
This commit is contained in:
24
CHDataManagement/Generator/Commands/IconCommand.swift
Normal file
24
CHDataManagement/Generator/Commands/IconCommand.swift
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
struct IconCommand: CommandProcessor {
|
||||
|
||||
static let commandType: CommandType = .icons
|
||||
|
||||
let results: PageGenerationResults
|
||||
|
||||
init(content: Content, results: PageGenerationResults, language: ContentLanguage) {
|
||||
self.results = results
|
||||
}
|
||||
|
||||
func process(_ arguments: [String], markdown: Substring) -> String {
|
||||
var icons = [PageIcon]()
|
||||
for argument in arguments {
|
||||
guard let icon = PageIcon(rawValue: argument) else {
|
||||
invalid(markdown)
|
||||
continue
|
||||
}
|
||||
icons.append(icon)
|
||||
}
|
||||
results.require(icons: icons)
|
||||
return ""
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user