Allow videos in posts, simplify post image view
This commit is contained in:
@ -35,7 +35,7 @@ final class FeedPageGenerator {
|
||||
linkPrefix: String) -> String {
|
||||
var headers = content.postPageHeaders
|
||||
var footer = ""
|
||||
if posts.contains(where: { $0.images.count > 1 }) {
|
||||
if posts.contains(where: { $0.requiresSwiper }) {
|
||||
// Sort swiper style sheet before default style sheet
|
||||
includeSwiper(in: &headers)
|
||||
footer = swiperInitScript(posts: posts)
|
||||
@ -82,7 +82,7 @@ final class FeedPageGenerator {
|
||||
func swiperInitScript(posts: [FeedEntryData]) -> String {
|
||||
var result = "<script> window.onload = () => { "
|
||||
for post in posts {
|
||||
guard post.images.count > 1 else {
|
||||
guard post.requiresSwiper else {
|
||||
continue
|
||||
}
|
||||
result += ImageGallery.swiperInit(id: post.entryId)
|
||||
|
@ -66,10 +66,19 @@ final class PostListPageGenerator {
|
||||
url: tag.absoluteUrl(in: language))
|
||||
}
|
||||
|
||||
let images = localized.images.map { image in
|
||||
image.imageSet(width: mainContentMaximumWidth, height: mainContentMaximumWidth, language: language)
|
||||
let media: FeedEntryData.Media?
|
||||
if localized.hasImages {
|
||||
let images = localized.images.map { image in
|
||||
image.imageSet(width: mainContentMaximumWidth, height: mainContentMaximumWidth, language: language)
|
||||
}
|
||||
images.forEach(source.results.require)
|
||||
media = .images(images)
|
||||
} else if localized.hasVideos {
|
||||
media = .video(localized.images)
|
||||
localized.images.forEach(source.results.require)
|
||||
} else {
|
||||
media = nil
|
||||
}
|
||||
images.forEach(source.results.require)
|
||||
|
||||
return FeedEntryData(
|
||||
entryId: post.id,
|
||||
@ -78,7 +87,7 @@ final class PostListPageGenerator {
|
||||
link: linkUrl,
|
||||
tags: tags,
|
||||
text: localized.text.components(separatedBy: "\n\n"),
|
||||
images: images)
|
||||
media: media)
|
||||
#warning("Treat post text as markdown")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user