#149 - Fix keywords

This commit is contained in:
Elio Struyf
2021-10-14 16:23:28 +02:00
parent 5667906caf
commit f74eec954f
3 changed files with 32 additions and 9 deletions
+17 -1
View File
@@ -13,6 +13,22 @@ export interface ISeoKeywordsProps {
export const SeoKeywords: React.FunctionComponent<ISeoKeywordsProps> = ({keywords, ...data}: React.PropsWithChildren<ISeoKeywordsProps>) => {
const validateKeywords = () => {
if (!keywords) {
return [];
}
if (typeof keywords === 'string') {
return [keywords];
}
if (Array.isArray(keywords)) {
return keywords;
}
return [];
}
if (!keywords || keywords.length === 0) {
return null;
}
@@ -31,7 +47,7 @@ export const SeoKeywords: React.FunctionComponent<ISeoKeywordsProps> = ({keyword
</VsTableHeader>
<VsTableBody slot="body">
{
keywords.map((keyword, index) => {
validateKeywords().map((keyword, index) => {
return (
<SeoKeywordInfo key={index} keyword={keyword} {...data} />
);