Skip to content

Commit 2bf4639

Browse files
docs: DLT-3258 DLT-3259 improve sidebar search with logical keywords and fuzzy matching (#1174)
1 parent fe2b777 commit 2bf4639

15 files changed

Lines changed: 23 additions & 17 deletions

File tree

apps/dialtone-documentation/docs/.vuepress/theme/components/Sidebar.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,26 @@ const focusedIndex = ref(-1);
8383
// Ref to the search input element
8484
const searchInput = ref(null);
8585
86+
// Strip separators and case for fuzzy matching.
87+
const normalize = (str) => str.toLowerCase().replace(/[^a-z0-9]/g, '');
88+
8689
// Recursive filter function for sidebar items
8790
const filterItems = (items, searchTerm) => {
8891
if (!searchTerm) return items;
8992
90-
const term = searchTerm.toLowerCase().trim();
93+
const term = searchTerm.trim();
9194
if (!term) return items;
9295
96+
const normalizedTerm = normalize(term);
97+
if (!normalizedTerm) return [];
98+
9399
const filtered = [];
94100
95101
items.forEach(item => {
96102
// Check if current item matches (text or keywords)
97-
const itemMatches = item.text.toLowerCase().includes(term) ||
103+
const itemMatches = normalize(item.text).includes(normalizedTerm) ||
98104
(item.keywords?.some(keyword =>
99-
keyword.toLowerCase().includes(term),
105+
normalize(keyword).includes(normalizedTerm),
100106
) ?? false);
101107
102108
// Recursively filter children if they exist

apps/dialtone-documentation/docs/utilities/borders/direction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Border Directions
33
description: Utilities for controlling an element's border.
4-
keywords: ["border top", "border bottom", "border left", "border right"]
4+
keywords: ["border top", "border bottom", "border left", "border right", "border inline start", "border inline end", "border block start", "border block end"]
55
---
66

77
## All Sides

apps/dialtone-documentation/docs/utilities/borders/divide-width.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Divide Width
33
description: Utilities for controlling the divider width between an element's child items.
4-
keywords: ["divider width","separator width","divider size"]
4+
keywords: ["divider width","separator width","divider size","divide inline size","divide block size"]
55
---
66

77
## Default Width

apps/dialtone-documentation/docs/utilities/borders/radius.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Border Radius
33
description: Utilities for controlling an element's border radius.
4-
keywords: ["rounded", "corner", "pill", "circle"]
4+
keywords: ["rounded", "corner", "pill", "circle", "radius start", "radius end"]
55
---
66

77
## All Corners

apps/dialtone-documentation/docs/utilities/borders/width.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Border Widths
33
description: Utilities for controlling an element's border width.
4-
keywords: ["border size", "border thickness"]
4+
keywords: ["border size", "border thickness", "border inline size", "border block size"]
55
---
66

77
## All Sides

apps/dialtone-documentation/docs/utilities/layout/coordinates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Coordinates
33
description: Utility classes to assign an element’s top, right, bottom, or left position.
4-
keywords: ["top","right","bottom","left","inset","position offset"]
4+
keywords: ["top","right","bottom","left","inset","position offset","inset inline start","inset inline end","inset block start","inset block end"]
55
---
66

77
## Positive Coordinates

apps/dialtone-documentation/docs/utilities/sizing/height.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Height
33
description: Utilities to control an element's height.
4-
keywords: ["size", "tall", "vh", "viewport height"]
4+
keywords: ["size", "tall", "vh", "viewport height", "block size", "block-size"]
55
---
66

77
## Layout stops

apps/dialtone-documentation/docs/utilities/sizing/max-height.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Max-height
33
description: Utilities to control an element's maximum height.
4-
keywords: ["maximum height", "mxh"]
4+
keywords: ["maximum height", "mxh", "max block size", "max block-size"]
55
---
66

77
## Layout stops

apps/dialtone-documentation/docs/utilities/sizing/max-width.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Max-width
33
description: Utilities to control an element's maximum width.
4-
keywords: ["maximum width", "mxw"]
4+
keywords: ["maximum width", "mxw", "max inline size", "max inline-size"]
55
---
66

77
## Layout stops

apps/dialtone-documentation/docs/utilities/sizing/min-height.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Min-height
33
description: Utilities to control an element's minimum height.
4-
keywords: ["minimum height", "mnh"]
4+
keywords: ["minimum height", "mnh", "min block size", "min block-size"]
55
---
66

77
## Layout stops

0 commit comments

Comments
 (0)