diff --git a/src/components/SearchBar/index.module.css b/src/components/SearchBar/index.module.css
index 0c961ab..4c28331 100644
--- a/src/components/SearchBar/index.module.css
+++ b/src/components/SearchBar/index.module.css
@@ -53,6 +53,16 @@
font-size: 0.8em;
}
+.description {
+ display: block;
+ margin-top: 5px;
+ color: var(--theme-color-disabled);
+ font-size: 0.85em;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
.search-container > button,
.search-icon {
position: absolute;
diff --git a/src/components/SearchBar/index.tsx b/src/components/SearchBar/index.tsx
index e6ab7c5..702f2a0 100644
--- a/src/components/SearchBar/index.tsx
+++ b/src/components/SearchBar/index.tsx
@@ -136,7 +136,7 @@ const SearchBar = () => {
{name} {searchTerm}
))}
- {results.map(({ name, url, featured, link }, index) => (
+ {results.map(({ name, url, featured, link, description }, index) => (
{
)}
{name}
{url}
+ {description && (
+ {description}
+ )}
))}
diff --git a/src/components/SearchBar/useSearch.tsx b/src/components/SearchBar/useSearch.tsx
index ae22c2e..729e5cc 100644
--- a/src/components/SearchBar/useSearch.tsx
+++ b/src/components/SearchBar/useSearch.tsx
@@ -12,11 +12,12 @@ const useSearch = (searchTerm: string, config?: ConfigEntity) => {
if (config && config.featured) {
list.push(
...config.featured.map((link, index) => {
- const { name, link: url, tags } = link
+ const { name, link: url, tags, description, desc } = link
return {
featured: true,
link,
- searchText: [name, url, tags].join(' '),
+ description: description || desc,
+ searchText: [name, url, tags, description, desc].join(' '),
name,
url,
}
@@ -28,12 +29,13 @@ const useSearch = (searchTerm: string, config?: ConfigEntity) => {
if (config?.categories) {
config.categories.forEach((category, categoryIndex) => {
category.links.forEach((link, linkIndex) => {
- const { name, link: url, tags } = link
+ const { name, link: url, tags, description, desc } = link
list.push({
featured: false,
link,
- searchText: [name, url, tags].join(' '),
+ description: description || desc,
+ searchText: [name, url, tags, description, desc].join(' '),
name,
url,
})
diff --git a/src/components/SearchContext/index.tsx b/src/components/SearchContext/index.tsx
index 0345bf8..a21b4ec 100644
--- a/src/components/SearchContext/index.tsx
+++ b/src/components/SearchContext/index.tsx
@@ -7,6 +7,7 @@ export interface SearchResult {
searchText: string
name: string
url: string
+ description?: string
}
interface ISearchContext {
diff --git a/src/modules/config/constants.ts b/src/modules/config/constants.ts
index c1bad2b..819d9c9 100644
--- a/src/modules/config/constants.ts
+++ b/src/modules/config/constants.ts
@@ -24,6 +24,7 @@ export const DEFAULT_LINK: LinksEntity = {
name: '',
link: '',
tags: '',
+ description: '',
target: '_blank',
}
@@ -32,6 +33,7 @@ export const DEFAULT_FEATURED_LINK: FeaturedEntity = {
link: '',
background: DEFAULT_BG,
tags: '',
+ description: '',
target: '_blank',
}
@@ -53,6 +55,8 @@ export const CONFIG_ENTITY_SCHEMA: JSONSchemaType = {
name: { type: 'string' },
link: { type: 'string' },
tags: { type: 'string', nullable: true },
+ description: { type: 'string', nullable: true },
+ desc: { type: 'string', nullable: true },
background: { type: 'string', nullable: true },
target: { type: 'string', enum: ['_self', '_blank'], nullable: true },
},
@@ -73,6 +77,8 @@ export const CONFIG_ENTITY_SCHEMA: JSONSchemaType = {
name: { type: 'string' },
link: { type: 'string' },
tags: { type: 'string', nullable: true },
+ description: { type: 'string', nullable: true },
+ desc: { type: 'string', nullable: true },
target: { type: 'string', enum: ['_self', '_blank'], nullable: true },
},
required: ['link', 'name'],
diff --git a/src/modules/config/types.ts b/src/modules/config/types.ts
index c120266..8002e6d 100644
--- a/src/modules/config/types.ts
+++ b/src/modules/config/types.ts
@@ -10,6 +10,14 @@ export interface LinksEntity {
name: string
link: string
tags?: string
+ /**
+ * Optional longer text for a bookmark, used in search results.
+ */
+ description?: string
+ /**
+ * Backward-compatible alias used by some configs.
+ */
+ desc?: string
/**
* Where should the link open?
* Defaults to `_blank` to preserve existing behaviour.