Skip to content

Commit bc24566

Browse files
committed
hide glossary items with empty example value or description
1 parent 8286c2f commit bc24566

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

src/components/GlossarySearchNav.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,34 @@ const form = reactive({
4040
search: ''
4141
})
4242
43+
// Helper function to check if a glossary item should be displayed
44+
const shouldDisplayItem = (item: any): boolean => {
45+
const html = item.description?.html || ''
46+
47+
// Check if description contains "no-description-provided"
48+
if (html.includes('no-description-provided')) {
49+
return false
50+
}
51+
52+
// Check if Example value is empty
53+
// Matches: "Example value:</p>", "Example value: </p>", "Example value:&nbsp;</p>", etc.
54+
if (html.match(/Example value:\s*(&nbsp;|\s)*<\/p>/i)) {
55+
return false
56+
}
57+
58+
// Also check for "Example value:" followed by empty tags or whitespace before closing
59+
if (html.match(/Example value:\s*(<[^>]*>)*\s*<\/p>/i)) {
60+
return false
61+
}
62+
63+
return true
64+
}
65+
4366
onBeforeMount(() => {
4467
const glossary = inject(obpGlossaryKey)!
4568
for (const item of glossary.glossary_items) {
46-
if (!activeKeys.value.includes(item.title)) {
69+
// Only include items that pass the filter
70+
if (!activeKeys.value.includes(item.title) && shouldDisplayItem(item)) {
4771
activeKeys.value.push(item.title)
4872
}
4973
}

src/views/GlossaryView.vue

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,36 @@
2626
-->
2727

2828
<script setup lang="ts">
29-
import { reactive, ref, onBeforeMount, onMounted, inject } from 'vue'
29+
import { reactive, ref, onBeforeMount, onMounted, inject, computed } from 'vue'
3030
import SearchNav from '../components/GlossarySearchNav.vue'
3131
import { obpGlossaryKey } from '@/obp/keys';
3232
33-
const glossary = ref(inject(obpGlossaryKey)!.glossary_items)
33+
const allGlossaryItems = ref(inject(obpGlossaryKey)!.glossary_items)
34+
35+
// Filter out items with empty example values or "no-description-provided"
36+
const glossary = computed(() => {
37+
return allGlossaryItems.value.filter((item: any) => {
38+
const html = item.description?.html || ''
39+
40+
// Check if description contains "no-description-provided"
41+
if (html.includes('no-description-provided')) {
42+
return false
43+
}
44+
45+
// Check if Example value is empty
46+
// Matches: "Example value:</p>", "Example value: </p>", "Example value:&nbsp;</p>", etc.
47+
if (html.match(/Example value:\s*(&nbsp;|\s)*<\/p>/i)) {
48+
return false
49+
}
50+
51+
// Also check for "Example value:" followed by empty tags or whitespace before closing
52+
if (html.match(/Example value:\s*(<[^>]*>)*\s*<\/p>/i)) {
53+
return false
54+
}
55+
56+
return true
57+
})
58+
})
3459
</script>
3560

3661
<template>

0 commit comments

Comments
 (0)