Unified detail views, model
This commit is contained in:
@ -8,13 +8,6 @@ final class FeedPageGenerator {
|
||||
self.content = content
|
||||
}
|
||||
|
||||
func navigationBar(in language: ContentLanguage) -> [NavigationBar.Link] {
|
||||
content.settings.navigationItems.map {
|
||||
.init(text: $0.title(in: language),
|
||||
url: $0.absoluteUrl(in: language))
|
||||
}
|
||||
}
|
||||
|
||||
var swiperIncludes: [HeaderElement] {
|
||||
var result = [HeaderElement]()
|
||||
if let swiperCss = content.settings.posts.swiperCssFile {
|
||||
@ -57,7 +50,7 @@ final class FeedPageGenerator {
|
||||
language: language,
|
||||
title: title,
|
||||
description: description,
|
||||
links: navigationBar(in: language),
|
||||
links: content.navigationBar(in: language),
|
||||
headers: headers,
|
||||
additionalFooter: footer) { content in
|
||||
if showTitle {
|
||||
|
@ -22,13 +22,6 @@ final class LocalizedWebsiteGenerator {
|
||||
|
||||
private let imageGenerator: ImageGenerator
|
||||
|
||||
private var navigationBarLinks: [NavigationBar.Link] {
|
||||
content.settings.navigationItems.map {
|
||||
.init(text: $0.title(in: language),
|
||||
url: $0.absoluteUrl(in: language))
|
||||
}
|
||||
}
|
||||
|
||||
init(content: Content, language: ContentLanguage) {
|
||||
self.language = language
|
||||
self.content = content
|
||||
@ -61,7 +54,6 @@ final class LocalizedWebsiteGenerator {
|
||||
language: language,
|
||||
content: content,
|
||||
imageGenerator: imageGenerator,
|
||||
navigationBarLinks: navigationBarLinks,
|
||||
showTitle: false,
|
||||
pageTitle: localizedPostSettings.title,
|
||||
pageDescription: localizedPostSettings.description,
|
||||
@ -82,7 +74,6 @@ final class LocalizedWebsiteGenerator {
|
||||
language: language,
|
||||
content: content,
|
||||
imageGenerator: imageGenerator,
|
||||
navigationBarLinks: navigationBarLinks,
|
||||
showTitle: true,
|
||||
pageTitle: localized.name,
|
||||
pageDescription: localized.description ?? "",
|
||||
@ -115,8 +106,7 @@ final class LocalizedWebsiteGenerator {
|
||||
}
|
||||
let pageGenerator = PageGenerator(
|
||||
content: content,
|
||||
imageGenerator: imageGenerator,
|
||||
navigationBarLinks: navigationBarLinks)
|
||||
imageGenerator: imageGenerator)
|
||||
|
||||
let content: String
|
||||
let results: PageGenerationResults
|
||||
|
@ -4,12 +4,9 @@ final class PageGenerator {
|
||||
|
||||
private let imageGenerator: ImageGenerator
|
||||
|
||||
private let navigationBarLinks: [NavigationBar.Link]
|
||||
|
||||
init(content: Content, imageGenerator: ImageGenerator, navigationBarLinks: [NavigationBar.Link]) {
|
||||
init(content: Content, imageGenerator: ImageGenerator) {
|
||||
self.content = content
|
||||
self.imageGenerator = imageGenerator
|
||||
self.navigationBarLinks = navigationBarLinks
|
||||
}
|
||||
|
||||
func makeHeaders(requiredItems: [HeaderFile]) -> [HeaderElement] {
|
||||
@ -51,7 +48,7 @@ final class PageGenerator {
|
||||
tags: tags,
|
||||
linkTitle: localized.linkPreviewTitle ?? localized.title,
|
||||
description: localized.linkPreviewDescription ?? "",
|
||||
navigationBarLinks: navigationBarLinks,
|
||||
navigationBarLinks: content.navigationBar(in: language),
|
||||
pageContent: pageContent,
|
||||
headers: headers,
|
||||
footers: contentGenerator.results.requiredFooters.sorted(),
|
||||
|
@ -8,9 +8,6 @@ final class PostListPageGenerator {
|
||||
|
||||
private let imageGenerator: ImageGenerator
|
||||
|
||||
#warning("Get from settings")
|
||||
private let navigationBarLinks: [NavigationBar.Link]
|
||||
|
||||
private let showTitle: Bool
|
||||
|
||||
private let pageTitle: String
|
||||
@ -20,11 +17,10 @@ final class PostListPageGenerator {
|
||||
/// The url of the page, excluding the extension
|
||||
private let pageUrlPrefix: String
|
||||
|
||||
init(language: ContentLanguage, content: Content, imageGenerator: ImageGenerator, navigationBarLinks: [NavigationBar.Link], showTitle: Bool, pageTitle: String, pageDescription: String, pageUrlPrefix: String) {
|
||||
init(language: ContentLanguage, content: Content, imageGenerator: ImageGenerator, showTitle: Bool, pageTitle: String, pageDescription: String, pageUrlPrefix: String) {
|
||||
self.language = language
|
||||
self.content = content
|
||||
self.imageGenerator = imageGenerator
|
||||
self.navigationBarLinks = navigationBarLinks
|
||||
self.showTitle = showTitle
|
||||
self.pageTitle = pageTitle
|
||||
self.pageDescription = pageDescription
|
||||
@ -50,14 +46,14 @@ final class PostListPageGenerator {
|
||||
let startIndex = (pageIndex - 1) * postsPerPage
|
||||
let endIndex = min(pageIndex * postsPerPage, totalCount)
|
||||
let postsOnPage = posts[startIndex..<endIndex]
|
||||
guard createPostFeedPage(pageIndex, pageCount: numberOfPages, posts: postsOnPage, bar: navigationBarLinks) else {
|
||||
guard createPostFeedPage(pageIndex, pageCount: numberOfPages, posts: postsOnPage) else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private func createPostFeedPage(_ pageIndex: Int, pageCount: Int, posts: ArraySlice<Post>, bar: [NavigationBar.Link]) -> Bool {
|
||||
private func createPostFeedPage(_ pageIndex: Int, pageCount: Int, posts: ArraySlice<Post>) -> Bool {
|
||||
let posts: [FeedEntryData] = posts.map { post in
|
||||
let localized: LocalizedPost = post.localized(in: language)
|
||||
|
||||
@ -78,7 +74,7 @@ final class PostListPageGenerator {
|
||||
textAboveTitle: post.dateText(in: language),
|
||||
link: linkUrl,
|
||||
tags: tags,
|
||||
text: [localized.content], // TODO: Convert from markdown to html
|
||||
text: localized.text.components(separatedBy: "\n"),
|
||||
images: localized.images.map(createImageSet))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user