Make search work with category names (#4103)

This commit is contained in:
Pierre-Yves B
2019-10-02 20:03:59 +01:00
committed by GitHub
parent a865b81acb
commit 157a6180b2
14 changed files with 37 additions and 37 deletions

View File

@@ -2,6 +2,7 @@
const Joi = require('@hapi/joi')
const pathToRegexp = require('path-to-regexp')
const categories = require('../../services/categories')
const coalesceBadge = require('./coalesce-badge')
const { makeFullUrl } = require('./route')
@@ -154,7 +155,9 @@ function transformExample(inExample, index, ServiceClass) {
style: style === 'flat' ? undefined : style,
namedLogo,
},
keywords,
keywords: keywords.concat(
categories.find(c => c.id === ServiceClass.category).keywords
),
documentation: documentation ? { __html: documentation } : undefined,
}
}

View File

@@ -84,6 +84,7 @@ test(transformExample, function() {
defaultBadgeData: {
label: 'downloads',
},
category: 'platform-support',
}
given(
@@ -109,7 +110,7 @@ test(transformExample, function() {
namedLogo: undefined,
style: undefined,
},
keywords: ['hello'],
keywords: ['hello', 'platform'],
documentation: undefined,
})
@@ -135,7 +136,7 @@ test(transformExample, function() {
namedLogo: undefined,
style: undefined,
},
keywords: ['hello'],
keywords: ['hello', 'platform'],
documentation: undefined,
})
@@ -162,7 +163,7 @@ test(transformExample, function() {
namedLogo: undefined,
style: undefined,
},
keywords: ['hello'],
keywords: ['hello', 'platform'],
documentation: undefined,
})
})

View File

@@ -66,6 +66,7 @@ const serviceDefinitionExport = Joi.object({
Joi.object({
id: Joi.string().required(),
name: Joi.string().required(),
keywords: arrayOfStrings,
})
)
.required(),