Add labels block
This commit is contained in:
parent
cc19ff4a6f
commit
8e19adda70
@ -242,6 +242,7 @@
|
||||
E2FE0F602D2C0422002963B7 /* VideoBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F5F2D2C041E002963B7 /* VideoBlock.swift */; };
|
||||
E2FE0F622D2C0D8D002963B7 /* VersionedVideo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F612D2C0D8D002963B7 /* VersionedVideo.swift */; };
|
||||
E2FE0F642D2C2F4D002963B7 /* ButtonBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F632D2C2F46002963B7 /* ButtonBlock.swift */; };
|
||||
E2FE0F662D2C3B3A002963B7 /* LabelsBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2FE0F652D2C3B33002963B7 /* LabelsBlock.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -475,6 +476,7 @@
|
||||
E2FE0F5F2D2C041E002963B7 /* VideoBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoBlock.swift; sourceTree = "<group>"; };
|
||||
E2FE0F612D2C0D8D002963B7 /* VersionedVideo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionedVideo.swift; sourceTree = "<group>"; };
|
||||
E2FE0F632D2C2F46002963B7 /* ButtonBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonBlock.swift; sourceTree = "<group>"; };
|
||||
E2FE0F652D2C3B33002963B7 /* LabelsBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelsBlock.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -928,6 +930,7 @@
|
||||
E2FE0F342D2B27E6002963B7 /* Blocks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E2FE0F652D2C3B33002963B7 /* LabelsBlock.swift */,
|
||||
E2FE0F5C2D2BD006002963B7 /* Types */,
|
||||
E2FE0F322D2B265F002963B7 /* AudioBlock.swift */,
|
||||
E2FE0F542D2BCFC4002963B7 /* ContentBlock.swift */,
|
||||
@ -1172,6 +1175,7 @@
|
||||
E29D318E2D0B2E680051B7F4 /* PageSettingsContentView.swift in Sources */,
|
||||
E22990242D0EDBD0009F8D77 /* HeaderElement.swift in Sources */,
|
||||
E29D31BC2D0DB5120051B7F4 /* CommandProcessor.swift in Sources */,
|
||||
E2FE0F662D2C3B3A002963B7 /* LabelsBlock.swift in Sources */,
|
||||
E29D312C2D039DB80051B7F4 /* PageDetailView.swift in Sources */,
|
||||
E29D31432D0488960051B7F4 /* MainContentView.swift in Sources */,
|
||||
E29D31282D0371930051B7F4 /* ContentPageVideo.swift in Sources */,
|
||||
|
@ -43,6 +43,7 @@ struct ButtonsBlock: BlockLineProcessor {
|
||||
}
|
||||
|
||||
struct ButtonBlock: KeyedBlockProcessor {
|
||||
|
||||
enum Key: String, Equatable {
|
||||
case icon
|
||||
case file
|
||||
@ -117,12 +118,11 @@ struct ButtonBlock: KeyedBlockProcessor {
|
||||
|
||||
results.externalLink(to: url)
|
||||
results.require(icon: icon)
|
||||
return .init(icon: icon, filePath: url, text: text)
|
||||
return .init(icon: icon, filePath: encodedUrl, text: text)
|
||||
}
|
||||
|
||||
private func action(event: String, icon: PageIcon, text: String) -> ContentButtons.Item? {
|
||||
results.require(icon: icon)
|
||||
|
||||
return .init(icon: icon, filePath: nil, text: text, onClickText: event)
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ enum ContentBlock: String, CaseIterable {
|
||||
|
||||
case buttons
|
||||
|
||||
case labels
|
||||
|
||||
var processor: BlockProcessor.Type {
|
||||
switch self {
|
||||
case .audio: return AudioBlock.self
|
||||
@ -18,6 +20,7 @@ enum ContentBlock: String, CaseIterable {
|
||||
case .video: return VideoBlock.self
|
||||
case .button: return ButtonBlock.self
|
||||
case .buttons: return ButtonsBlock.self
|
||||
case .labels: return LabelsBlock.self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
CHDataManagement/Generator/Blocks/LabelsBlock.swift
Normal file
31
CHDataManagement/Generator/Blocks/LabelsBlock.swift
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
struct LabelsBlock: OrderedKeyBlockProcessor {
|
||||
|
||||
typealias Key = PageIcon
|
||||
|
||||
static let blockId: ContentBlock = .labels
|
||||
|
||||
let content: Content
|
||||
|
||||
let results: PageGenerationResults
|
||||
|
||||
let language: ContentLanguage
|
||||
|
||||
init(content: Content, results: PageGenerationResults, language: ContentLanguage) {
|
||||
self.content = content
|
||||
self.results = results
|
||||
self.language = language
|
||||
}
|
||||
|
||||
func process(_ arguments: [(key: PageIcon, value: String)], markdown: Substring) -> String {
|
||||
let labels: [ContentLabel] = arguments.compactMap { (icon, value) in
|
||||
guard value != "" else {
|
||||
invalid(markdown)
|
||||
return nil
|
||||
}
|
||||
results.require(icon: icon)
|
||||
return .init(icon: icon, value: value)
|
||||
}
|
||||
return ContentLabels(labels: labels).content
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@ import SFSafeSymbols
|
||||
- Posts: Generate separate pages for posts to link to
|
||||
- Settings: Introduce `Authors` (`name`, `image`, `description`)
|
||||
- Page: Property `author`
|
||||
- Video: Specify versions -> Block
|
||||
|
||||
**Generation**
|
||||
- ImageSet: Specify image aspect ratio (width, height) to prevent page jumps
|
||||
|
Loading…
x
Reference in New Issue
Block a user