Skip to content

Commit b57bac5

Browse files
committed
Adds syntax-highlight webc component
1 parent b67b5e8 commit b57bac5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

syntax-highlight.webc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script webc:type="render" webc:is="template" webc:raw webc:nokeep>
2+
function() {
3+
let errorPrefix = "[11ty/eleventy-plugin-syntaxhighlight] <syntax-highlight> WebC component: ";
4+
5+
if(!this.slots || !this.slots.text) {
6+
throw new Error(errorPrefix + "requires WebC v0.6.0");
7+
}
8+
9+
if(!this.helpers || !this.helpers.highlight) {
10+
throw new Error(errorPrefix+ "missing the `highlight` helper! Did you run addPlugin on the syntax highlighter in your Eleventy config file?");
11+
}
12+
13+
let content = this.slots.text.default;
14+
return this.helpers.highlight(this.language, content);
15+
}
16+
</script>

0 commit comments

Comments
 (0)