Skip to content

Commit abf5954

Browse files
committed
node: use <details> for mjs vs. cjs
1 parent 4dcf237 commit abf5954

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

assets/stylesheets/global/_base.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ pre, %pre {
123123
@extend %box;
124124
}
125125

126+
details:has(> pre) {
127+
margin: 1.5em 0;
128+
129+
> pre {
130+
margin: 0;
131+
}
132+
}
133+
126134
a > code { color: inherit; }
127135

128136
table {

lib/docs/filters/node/clean_html.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ def call
88
next unless (node.css('code').to_a.length > 1)
99

1010
node.css('code').each do |subnode|
11+
node.before(subnode)
1112

1213
if subnode.classes.include?('mjs')
13-
node.before('<p class=module-type>MJS modules</p>')
14+
subnode.wrap('<details open>')
15+
subnode.wrap('<pre>')
16+
subnode.ancestors('details').first.prepend_child('<summary>JavaScript modules</summary>')
1417
elsif subnode.classes.include?('cjs')
15-
node.before('<p class=module-type>CJS modules</p>')
18+
subnode.wrap('<details>')
19+
subnode.wrap('<pre>')
20+
subnode.ancestors('details').first.prepend_child('<summary>CommonJS</summary>')
1621
end
17-
18-
node.before(subnode)
19-
subnode.wrap('<pre>')
2022
end
2123

2224
node.remove

0 commit comments

Comments
 (0)