Skip to content

Commit

Permalink
Merge pull request #263 from JPToroDev/011524c
Browse files Browse the repository at this point in the history
Remove unnecessary disabling of syntax highlighter meta links.
  • Loading branch information
twostraws authored Jan 16, 2025
2 parents f22948e + e16bf15 commit faec602
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
15 changes: 3 additions & 12 deletions Sources/Ignite/Elements/MetaLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,9 @@ public struct MetaLink: HeadElement, Sendable {
/// - Returns: An array of MetaLink elements. If multiple themes are provided,
/// includes data attributes for theme switching.
static func highlighterThemeMetaLinks(for themes: some Collection<HighlighterTheme>) -> [MetaLink] {
let hasMultipleThemes = themes.count > 1

return themes.sorted().map { theme in
var link = MetaLink(href: "/\(theme.url)", rel: .stylesheet)

if hasMultipleThemes {
link = link
.data("highlight-theme", theme.description)
.customAttribute(name: "disabled", value: "")
}

return link
themes.sorted().map { theme in
MetaLink(href: "/\(theme.url)", rel: .stylesheet)
.data("highlight-theme", theme.description)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/IgniteTesting/Elements/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ struct AttributesTest {

#expect(
output == [
"<link disabled=\"\" href=\"/css/prism-github-dark.css\" rel=\"stylesheet\" data-highlight-theme=\"github-dark\" />",
"<link disabled=\"\" href=\"/css/prism-github-light.css\" rel=\"stylesheet\" data-highlight-theme=\"github-light\" />",
"<link disabled=\"\" href=\"/css/prism-xcode-dark.css\" rel=\"stylesheet\" data-highlight-theme=\"xcode-dark\" />"
"<link href=\"/css/prism-github-dark.css\" rel=\"stylesheet\" data-highlight-theme=\"github-dark\" />",
"<link href=\"/css/prism-github-light.css\" rel=\"stylesheet\" data-highlight-theme=\"github-light\" />",
"<link href=\"/css/prism-xcode-dark.css\" rel=\"stylesheet\" data-highlight-theme=\"xcode-dark\" />"
]
)
}
Expand Down

0 comments on commit faec602

Please sign in to comment.