From 71ea40abd2ee8da7a75bfe6135021fc449746a07 Mon Sep 17 00:00:00 2001 From: Vithanco Date: Wed, 19 Jul 2023 05:55:23 +0200 Subject: [PATCH] first version --- .../Publish_TableOfContent/Breadcrumbs.swift | 12 ++++----- .../TableOfContent.swift | 27 ++----------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/Sources/Publish_TableOfContent/Breadcrumbs.swift b/Sources/Publish_TableOfContent/Breadcrumbs.swift index 0e2c313..0f5bb38 100644 --- a/Sources/Publish_TableOfContent/Breadcrumbs.swift +++ b/Sources/Publish_TableOfContent/Breadcrumbs.swift @@ -1,5 +1,5 @@ // -// Breadcrumps.swift +// Breadcrumbs.swift // // // Created by Klaus Kneupner on 19/07/2023. @@ -10,15 +10,15 @@ import Publish import Plot -public struct Breadcrumps: Component where Site.ItemMetadata : HasShortTitle { +public struct Breadcrumbs: Component where Site.ItemMetadata : HasShortTitle { var originalPath: Path var _body: ComponentGroup public var body: Component { - // debugPrint("breadcrump for \(self.originalPath) : \(items.count)") + // debugPrint("breadcrumb for \(self.originalPath) : \(items.count)") return _body.members.count > 0 ? Div { _body - }.class("breadcrumps") as Component + }.class("breadcrumbs") as Component : EmptyComponent() as Component } @@ -27,9 +27,9 @@ public struct Breadcrumps: Component where Site.ItemMetadata : Ha var converted = section.items .filter({return item.path.hasAncestor($0.path)}) .sorted(by: {return $0.path ~< $1.path}) - .map({Link($0.title, url: $0.path.absoluteString).class("breadcrump")}) + .map({Link($0.title, url: $0.path.absoluteString).class("breadcrumb")}) for i in stride (from: converted.count-1, through: 1, by: -1) { - converted.insert(Image(url: "/images/socialmedia-icons/chevron.svg", description: "breadcrump separator"), at: i) + converted.insert(Image(url: "/images/socialmedia-icons/chevron.svg", description: "breadcrumb separator"), at: i) } _body = ComponentGroup(members: converted) } diff --git a/Sources/Publish_TableOfContent/TableOfContent.swift b/Sources/Publish_TableOfContent/TableOfContent.swift index 85f6fb3..5793204 100644 --- a/Sources/Publish_TableOfContent/TableOfContent.swift +++ b/Sources/Publish_TableOfContent/TableOfContent.swift @@ -142,7 +142,7 @@ public struct TableOfContent: Component { self.toc.childrenAsHTML }.class("toc-list") as Component : EmptyComponent() as Component } - init(items: [any TableOfContentEntry], item: any TableOfContentEntry){ + public init(items: [any TableOfContentEntry], item: any TableOfContentEntry){ self.originalPath = item.path let filteredItems = items.filter({return item.path.hasChild($0.path)}) .sorted(by: {return $0.path ~< $1.path}) @@ -155,27 +155,4 @@ public struct TableOfContent: Component { } } -public struct Breadcrumps: Component where Site.ItemMetadata : HasShortTitle { - var originalPath: Path - var _body: ComponentGroup - - public var body: Component { - // debugPrint("breadcrump for \(self.originalPath) : \(items.count)") - return _body.members.count > 0 ? Div { - _body - }.class("breadcrumps") as Component - : EmptyComponent() as Component - } - - init(section: Section, item: any TableOfContentEntry) { - self.originalPath = item.path - var converted = section.items - .filter({return item.path.hasAncestor($0.path)}) - .sorted(by: {return $0.path ~< $1.path}) - .map({Link($0.title, url: $0.path.absoluteString).class("breadcrump")}) - for i in stride (from: converted.count-1, through: 1, by: -1) { - converted.insert(Image(url: "/images/socialmedia-icons/chevron.svg", description: "breadcrump separator"), at: i) - } - _body = ComponentGroup(members: converted) - } -} +