Skip to content

Commit 7f0840f

Browse files
feat: add rule features
1 parent 6c87391 commit 7f0840f

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

website/_data/catalog.data.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,22 @@ function extractOneRuleObject(rule: object, rules: Set<string>) {
8686
}
8787

8888
function extractUsedFeatures(yamls: Record<string, unknown>[]): string[] {
89-
return []
89+
const features = new Set<string>()
90+
for (const yaml of yamls) {
91+
if (typeof yaml === 'object' && yaml !== null) {
92+
if ('utils' in yaml) {
93+
features.add('utils')
94+
}
95+
if ('constraints' in yaml) {
96+
features.add('constraints')
97+
}
98+
if ('rewriters' in yaml) {
99+
features.add('rewriters')
100+
}
101+
if ('transform' in yaml) {
102+
features.add('transform')
103+
}
104+
}
105+
}
106+
return [...features]
90107
}

website/src/catalog/RuleList.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ const rules = computed(() => getRules(props.filter))
3131
<div class="rule-badges">
3232
<Badge v-if="rule.type === 'Pattern'" type="info" text="Simple Pattern" />
3333
<template v-else>
34-
<code class="used" v-for="usedRule in rule.rules">
35-
{{ usedRule }}
34+
📏
35+
<code class="used" v-for="r in rule.rules.slice(0, 2)">
36+
{{ r }}
3637
</code>
3738
</template>
3839
</div>
40+
<div class="rule-badges" v-if="rule.features.length > 0">
41+
💡
42+
<code class="used" v-for="feature in rule.features">
43+
{{ feature }}
44+
</code>
45+
</div>
3946
<a :href="rule.playgroundLink" class="playground-link" target="_blank">
4047
Try in Playground →
4148
</a>
@@ -75,7 +82,6 @@ a:hover {
7582
7683
.rule-badges {
7784
display: flex;
78-
align-items: center;
7985
gap: 0.2em;
8086
}
8187
@@ -85,6 +91,10 @@ a:hover {
8591
align-items: center;
8692
}
8793
94+
.rule-details > div {
95+
flex: 1;
96+
}
97+
8898
.used {
8999
filter: saturate(0);
90100
user-select: none;

0 commit comments

Comments
 (0)