diff --git a/website/src/components/util.js b/website/src/components/util.js index 0d3f7bda3..1935a8085 100644 --- a/website/src/components/util.js +++ b/website/src/components/util.js @@ -45,6 +45,14 @@ export function isString(obj) { return typeof obj === 'string' || obj instanceof String } +/** + * @param obj - The object to check. + * @returns {boolean} - Whether the object is empty. + */ +export function isEmptyObj(obj) { + return Object.entries(obj).length === 0 && obj.constructor === Object +} + /** * Convert raw HTML to React elements * @param {string} html - The HTML markup to convert. diff --git a/website/src/templates/models.js b/website/src/templates/models.js index 82c7e4219..3ac5e6ebf 100644 --- a/website/src/templates/models.js +++ b/website/src/templates/models.js @@ -15,7 +15,8 @@ import Link from '../components/link' import Grid from '../components/grid' import Infobox from '../components/infobox' import Accordion from '../components/accordion' -import { join, arrayToObj, abbrNum, markdownToReact, isString } from '../components/util' +import { join, arrayToObj, abbrNum, markdownToReact } from '../components/util' +import { isString, isEmptyObj } from '../components/util' const MODEL_META = { core: 'Vocabulary, syntax, entities, vectors', @@ -105,7 +106,7 @@ function formatModelMeta(data) { author: data.author, url: data.url, license: data.license, - labels: data.labels, + labels: isEmptyObj(data.labels) ? null : data.labels, vectors: formatVectors(data.vectors), accuracy: formatAccuracy(data.accuracy), }