Rework content commands, add audio player
This commit is contained in:
@ -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>"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user