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