Fix script imports
This commit is contained in:
parent
54a4d6dbc3
commit
ddf489c2c4
@ -99,8 +99,11 @@ struct HTMLElementsGenerator {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
func scriptInclude(path: String) -> String {
|
func scriptInclude(path: String, asModule: Bool) -> String {
|
||||||
"<script src=\"\(path)\"></script>"
|
if asModule {
|
||||||
|
return "<script type=\"module\" src=\"\(path)\"></script>"
|
||||||
|
}
|
||||||
|
return "<script src=\"\(path)\"></script>"
|
||||||
}
|
}
|
||||||
|
|
||||||
func codeHighlightFooter() -> String {
|
func codeHighlightFooter() -> String {
|
||||||
|
@ -38,12 +38,11 @@ struct PageHeadGenerator {
|
|||||||
content[.customPageContent] = results.getContentOfOptionalFile(at: page.additionalHeadContentPath, source: page.path)
|
content[.customPageContent] = results.getContentOfOptionalFile(at: page.additionalHeadContentPath, source: page.path)
|
||||||
|
|
||||||
let head = (content[.customPageContent].unwrapped { [$0] } ?? []) + headers
|
let head = (content[.customPageContent].unwrapped { [$0] } ?? []) + headers
|
||||||
.map { $0.rawValue }
|
.sorted { $0.rawValue < $1.rawValue }
|
||||||
.sorted()
|
|
||||||
.map { option in
|
.map { option in
|
||||||
let scriptPath = "assets/js/\(option)"
|
let scriptPath = "assets/js/\(option.rawValue)"
|
||||||
let relative = page.relativePathToOtherSiteElement(file: scriptPath)
|
let relative = page.relativePathToOtherSiteElement(file: scriptPath)
|
||||||
return factory.html.scriptInclude(path: relative)
|
return factory.html.scriptInclude(path: relative, asModule: option.asModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
content[.customPageContent] = head.joined(separator: "\n")
|
content[.customPageContent] = head.joined(separator: "\n")
|
||||||
|
@ -3,6 +3,13 @@ import Foundation
|
|||||||
enum HeaderFile: String {
|
enum HeaderFile: String {
|
||||||
case codeHightlighting = "highlight.js"
|
case codeHightlighting = "highlight.js"
|
||||||
case modelViewer = "model-viewer.js"
|
case modelViewer = "model-viewer.js"
|
||||||
|
|
||||||
|
var asModule: Bool {
|
||||||
|
switch self {
|
||||||
|
case .codeHightlighting: return false
|
||||||
|
case .modelViewer: return true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias RequiredHeaders = Set<HeaderFile>
|
typealias RequiredHeaders = Set<HeaderFile>
|
||||||
|
Loading…
Reference in New Issue
Block a user