Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Vithanco committed Jul 19, 2023
1 parent 66b948e commit 71ea40a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
12 changes: 6 additions & 6 deletions Sources/Publish_TableOfContent/Breadcrumbs.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Breadcrumps.swift
// Breadcrumbs.swift
//
//
// Created by Klaus Kneupner on 19/07/2023.
Expand All @@ -10,15 +10,15 @@ import Publish
import Plot


public struct Breadcrumps<Site: Website>: Component where Site.ItemMetadata : HasShortTitle {
public struct Breadcrumbs<Site: Website>: 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
}

Expand All @@ -27,9 +27,9 @@ public struct Breadcrumps<Site: Website>: 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)
}
Expand Down
27 changes: 2 additions & 25 deletions Sources/Publish_TableOfContent/TableOfContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -155,27 +155,4 @@ public struct TableOfContent: Component {
}
}

public struct Breadcrumps<Site: Website>: 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<Site>, 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)
}
}

0 comments on commit 71ea40a

Please sign in to comment.