Add tag overview, improve assets

This commit is contained in:
Christoph Hagen
2024-12-15 21:20:12 +01:00
parent 8a3a0f1797
commit 1e67a99866
59 changed files with 1301 additions and 480 deletions

View File

@ -2,12 +2,6 @@ import Foundation
final class Page: Item {
/**
The unique id of the entry
*/
@Published
var id: String
/**
The external link this page points to.
@ -59,7 +53,6 @@ final class Page: Item {
german: LocalizedPage,
english: LocalizedPage,
tags: [Tag]) {
self.id = id
self.externalLink = externalLink
self.isDraft = isDraft
self.createdDate = createdDate
@ -70,14 +63,7 @@ final class Page: Item {
self.english = english
self.tags = tags
super.init(content: content)
}
func localized(in language: ContentLanguage) -> LocalizedPage {
switch language {
case .german: return german
case .english: return english
}
super.init(content: content, id: id)
}
func update(id newId: String) -> Bool {
@ -95,7 +81,7 @@ final class Page: Item {
// MARK: Paths
func absoluteUrl(for language: ContentLanguage) -> String {
override func absoluteUrl(in language: ContentLanguage) -> String {
if let url = externalLink {
return url
}
@ -103,40 +89,31 @@ final class Page: Item {
return makeCleanAbsolutePath(internalPath(for: language))
}
override func title(in language: ContentLanguage) -> String {
localized(in: language).title
}
func filePathRelativeToOutputFolder(for language: ContentLanguage) -> String {
makeCleanRelativePath(internalPath(for: language))
}
private func internalPath(for language: ContentLanguage) -> String {
content.settings.pages.pageUrlPrefix + "/" + localized(in: language).urlString
content.settings.paths.pagesOutputFolderPath + "/" + localized(in: language).urlString
}
}
extension Page: Identifiable {
}
extension Page: Equatable {
static func == (lhs: Page, rhs: Page) -> Bool {
lhs.id == rhs.id
override var itemType: ItemType {
.page
}
}
extension Page: Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
extension Page: Comparable {
static func < (lhs: Page, rhs: Page) -> Bool {
lhs.id < rhs.id
func contains(urlComponent: String) -> Bool {
english.urlString == urlComponent || german.urlString == urlComponent
}
}
extension Page: DateItem {
}
extension Page: LocalizedItem {
}