diff --git a/CHDataManagement.xcodeproj/project.pbxproj b/CHDataManagement.xcodeproj/project.pbxproj index 95166dd..184a372 100644 --- a/CHDataManagement.xcodeproj/project.pbxproj +++ b/CHDataManagement.xcodeproj/project.pbxproj @@ -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 = ""; }; E2FE0F612D2C0D8D002963B7 /* VersionedVideo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionedVideo.swift; sourceTree = ""; }; E2FE0F632D2C2F46002963B7 /* ButtonBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonBlock.swift; sourceTree = ""; }; + E2FE0F652D2C3B33002963B7 /* LabelsBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelsBlock.swift; sourceTree = ""; }; /* 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 */, diff --git a/CHDataManagement/Generator/Blocks/ButtonBlock.swift b/CHDataManagement/Generator/Blocks/ButtonBlock.swift index 7e12148..d1aa64e 100644 --- a/CHDataManagement/Generator/Blocks/ButtonBlock.swift +++ b/CHDataManagement/Generator/Blocks/ButtonBlock.swift @@ -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) } } diff --git a/CHDataManagement/Generator/Blocks/ContentBlock.swift b/CHDataManagement/Generator/Blocks/ContentBlock.swift index a363e66..ea11f91 100644 --- a/CHDataManagement/Generator/Blocks/ContentBlock.swift +++ b/CHDataManagement/Generator/Blocks/ContentBlock.swift @@ -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 } } } diff --git a/CHDataManagement/Generator/Blocks/LabelsBlock.swift b/CHDataManagement/Generator/Blocks/LabelsBlock.swift new file mode 100644 index 0000000..e9e6642 --- /dev/null +++ b/CHDataManagement/Generator/Blocks/LabelsBlock.swift @@ -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 + } +} diff --git a/CHDataManagement/Main/MainView.swift b/CHDataManagement/Main/MainView.swift index e58346c..168d453 100644 --- a/CHDataManagement/Main/MainView.swift +++ b/CHDataManagement/Main/MainView.swift @@ -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