Add web app manifest file
This commit is contained in:
parent
1e5fed5bbc
commit
0bd48be2c2
@ -50,11 +50,14 @@ enum HeaderElement {
|
||||
|
||||
case robots
|
||||
|
||||
case manifest(FileResource)
|
||||
|
||||
var order: Int {
|
||||
switch self {
|
||||
case .charset: 1
|
||||
case .robots: 2
|
||||
case .viewport: 3
|
||||
case .manifest: 4
|
||||
case .icon: 10
|
||||
case .css(_, let order): order
|
||||
case .js: 20
|
||||
@ -79,6 +82,8 @@ enum HeaderElement {
|
||||
return file
|
||||
case .jsModule(let file):
|
||||
return file
|
||||
case .manifest(let file):
|
||||
return file
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -129,6 +134,8 @@ extension HeaderElement {
|
||||
return "<meta name='viewport' content='width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1' />"
|
||||
case .robots:
|
||||
return "<meta name='robots' content='noindex'>"
|
||||
case .manifest(let file):
|
||||
return "<link rel='manifest' href='\(file.absoluteUrl)'>"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,6 +172,8 @@ extension HeaderElement: CustomStringConvertible {
|
||||
return "viewport"
|
||||
case .robots:
|
||||
return "robots"
|
||||
case .manifest:
|
||||
return "manifest"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,9 @@ extension Content {
|
||||
if let css {
|
||||
result.insert(.css(file: css, order: HeaderElement.defaultCssFileOrder))
|
||||
}
|
||||
if let manifest = settings.pages.manifestFile {
|
||||
result.insert(.manifest(manifest))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,9 @@ final class PageSettings: ObservableObject {
|
||||
@Published
|
||||
var imageCompareCssFile: FileResource?
|
||||
|
||||
@Published
|
||||
var manifestFile: FileResource?
|
||||
|
||||
@Published
|
||||
var german: LocalizedPageSettings
|
||||
|
||||
@ -40,6 +43,7 @@ final class PageSettings: ObservableObject {
|
||||
modelViewerJsFile: FileResource? = nil,
|
||||
imageCompareJsFile: FileResource? = nil,
|
||||
imageCompareCssFile: FileResource? = nil,
|
||||
manifestFile: FileResource? = nil,
|
||||
german: LocalizedPageSettings,
|
||||
english: LocalizedPageSettings) {
|
||||
self.contentWidth = contentWidth
|
||||
@ -50,6 +54,7 @@ final class PageSettings: ObservableObject {
|
||||
self.modelViewerJsFile = modelViewerJsFile
|
||||
self.imageCompareJsFile = imageCompareJsFile
|
||||
self.imageCompareCssFile = imageCompareCssFile
|
||||
self.manifestFile = manifestFile
|
||||
self.german = german
|
||||
self.english = english
|
||||
}
|
||||
@ -70,6 +75,9 @@ final class PageSettings: ObservableObject {
|
||||
if imageCompareCssFile == file {
|
||||
imageCompareCssFile = nil
|
||||
}
|
||||
if manifestFile == file {
|
||||
manifestFile = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,6 +95,7 @@ extension PageSettings {
|
||||
modelViewerJsFile: data.modelViewerJsFile.map(context.file),
|
||||
imageCompareJsFile: data.imageCompareJsFile.map(context.file),
|
||||
imageCompareCssFile: data.imageCompareCssFile.map(context.file),
|
||||
manifestFile: data.manifestFile.map(context.file),
|
||||
german: .init(data: data.german),
|
||||
english: .init(data: data.english))
|
||||
}
|
||||
@ -100,6 +109,7 @@ extension PageSettings {
|
||||
modelViewerJsFile: modelViewerJsFile?.id,
|
||||
imageCompareJsFile: imageCompareJsFile?.id,
|
||||
imageCompareCssFile: imageCompareCssFile?.id,
|
||||
manifestFile: manifestFile?.id,
|
||||
german: german.data,
|
||||
english: english.data)
|
||||
}
|
||||
@ -113,6 +123,7 @@ extension PageSettings {
|
||||
let modelViewerJsFile: String?
|
||||
let imageCompareJsFile: String?
|
||||
let imageCompareCssFile: String?
|
||||
let manifestFile: String?
|
||||
let german: LocalizedPageSettings.Data
|
||||
let english: LocalizedPageSettings.Data
|
||||
}
|
||||
|
@ -57,6 +57,11 @@ struct PageSettingsDetailView: View {
|
||||
selectedFile: $pageSettings.imageCompareJsFile,
|
||||
allowedType: .code)
|
||||
|
||||
FilePropertyView(
|
||||
title: "Web App Manifest File",
|
||||
footer: "The manifest file with the properties of the website when used as a progressive web app",
|
||||
selectedFile: $pageSettings.manifestFile)
|
||||
|
||||
LocalizedPageSettingsView(settings: pageSettings.localized(in: language))
|
||||
.id(language)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user