Skip to content

Commit 2ae132c

Browse files
committed
events: Optimize data chunk
1 parent 7750b1b commit 2ae132c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

components/EventsComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const d = Object.fromEntries(Object.entries(data).filter(([k, v]) =>
1414
(v.root && v.root == props.root)) ||
1515
(props.tag &&
1616
((v.root && v.root == props.tag) ||
17-
(v.tags.includes(props.tag)))))
17+
(v.tags?.includes(props.tag)))))
1818
).sort())
1919
</script>
2020

data/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const events = {
2929

3030
// Event(s) this field inherits fields from.
3131
// Can be a single event or an array of events.
32-
inherit: '',
32+
// inherit: '',
3333

3434
// List of fields emitted. Keys are field names, values are
3535
// descriptions (string) or an object with multiple keys (see below for

lib/events.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { loadData, normalizeArrayData } from './utility.js'
22
import { getVitepressMd } from './markdown.js'
3+
import cleanDeep from 'clean-deep'
34

45
/* Take the events list and normalize entries and process inheritance. */
56
function processInherit(i, ob) {
@@ -115,17 +116,21 @@ async function normalizeEvents(events, global_inherits, inherits) {
115116
v.fields = fields
116117

117118
/* Prefix the list of changes to the event's description. */
118-
v.text = v.text ? md.render(`${appendListOfUpdates(v)}\n${v.text}`) : null
119+
if (v.text) {
120+
v.text = md.render(`${appendListOfUpdates(v)}\n${v.text}`)
121+
}
119122
}
120123

121124
return events
122125
}
123126

124127
export async function loadEvents() {
125128
const data = await loadData('events')
126-
return await normalizeEvents(
127-
structuredClone(data.events),
128-
structuredClone(data.global_inherits),
129-
structuredClone(data.inherits)
129+
return cleanDeep(
130+
await normalizeEvents(
131+
structuredClone(data.events),
132+
structuredClone(data.global_inherits),
133+
structuredClone(data.inherits)
134+
)
130135
)
131136
}

0 commit comments

Comments
 (0)