Rework content commands, add audio player

This commit is contained in:
Christoph Hagen
2024-12-14 16:31:40 +01:00
parent b3b8c9a610
commit be2aab2ea8
52 changed files with 1758 additions and 767 deletions

View File

@ -5,17 +5,20 @@ struct ContentButtons {
let icon: PageIcon
let filePath: String
let filePath: String?
let text: String
let downloadFileName: String?
init(icon: PageIcon, filePath: String, text: String, downloadFileName: String? = nil) {
let onClickText: String?
init(icon: PageIcon, filePath: String?, text: String, downloadFileName: String? = nil, onClickText: String? = nil) {
self.icon = icon
self.filePath = filePath
self.text = text
self.downloadFileName = downloadFileName
self.onClickText = onClickText
}
}
@ -36,8 +39,10 @@ struct ContentButtons {
private func addButton(of item: Item, to result: inout String) {
let downloadText = item.downloadFileName.map { " download='\($0)'" } ?? ""
result += "<a class='tag' href='\(item.filePath)'\(downloadText)>"
result += "<svg><use href='#\(item.icon.name)'></use></svg>\(item.text)"
let linkText = item.filePath.map { " href='\($0)'" } ?? ""
let onClickText = item.onClickText.map { " onClick='\($0)'" } ?? ""
result += "<a class='tag'\(linkText)\(downloadText)\(onClickText)>"
result += "<svg><use href='#\(item.icon.icon.name)'></use></svg>\(item.text)"
result += "</a>"
}
}