diff --git a/src/commands/docs/baseline.ts b/src/commands/docs/baseline.ts index 79d6542..f1dc848 100644 --- a/src/commands/docs/baseline.ts +++ b/src/commands/docs/baseline.ts @@ -11,6 +11,7 @@ import { features as data } from 'web-features'; import { fuzzySearch } from '../../util/fuzzy-search.js'; import type { ProviderConfig } from './types.js'; import { createBaseConfig, getBaselineFeatures } from './utils.js'; +import { clampText } from '../../util/text.js'; export type FeatureData = { name: string; @@ -72,11 +73,8 @@ export const baselineProvider: ProviderConfig = { .setMaxValues(1) .addOptions( ...data.map((feature) => ({ - label: feature.name.length > 100 ? `${feature.name.slice(0, 97)}...` : feature.name, - description: - feature.description.length > 100 - ? `${feature.description.slice(0, 97)}...` - : feature.description, + label: clampText(feature.name, 100), + description: clampText(feature.description, 100), value: feature.key, })) ) diff --git a/src/commands/docs/mdn.ts b/src/commands/docs/mdn.ts index a759d3c..d58b77a 100644 --- a/src/commands/docs/mdn.ts +++ b/src/commands/docs/mdn.ts @@ -56,8 +56,8 @@ export const mdnProvider: ProviderConfig = { .setMaxValues(Math.min(5, data.size)) .addOptions( ...data.map((doc) => ({ - label: doc.title.length > 100 ? `${doc.title.slice(0, 97)}...` : doc.title, - description: doc.summary.length > 100 ? `${doc.summary.slice(0, 97)}...` : doc.summary, + label: clampText(doc.title, 100), + description: clampText(doc.summary, 100), value: doc.slug, })) ) diff --git a/src/commands/docs/npm.ts b/src/commands/docs/npm.ts index 1461b9c..62c1dfb 100644 --- a/src/commands/docs/npm.ts +++ b/src/commands/docs/npm.ts @@ -64,7 +64,7 @@ export const npmProvider: ProviderConfig = { ...data.map((pkg) => new StringSelectMenuOptionBuilder() .setLabel(pkg.name) - .setDescription(pkg.description) + .setDescription(clampText(pkg.description, 100)) .setValue(pkg.name) ) )