Это больше похоже на html, css, проблему реакции, чем на что-либо, связанное с contentful или gatsby.
Вот как вы могли бы создать компонент тегов.
// App.js
import React from "react";
import Tags from "./Tags";
import "./styles.css";
const tagsArray = [
{ title: "dropshipping tips" },
{ title: "product selection" },
{ title: "other tag 1" },
{ title: "other tag 2" }
];
export default function App() {
return (
<>
<h1>My article</h1>
<Tags data={tagsArray} />
</>
);
}
// Tags.js
import React from "react";
export default function Tags({ data }) {
return (
<ul className="tags">
{data.map((tag, index) => (
<li key={index} className="tag">
{titleCase(tag.title)}
</li>
))}
</ul>
);
}
function titleCase(str) {
return str
.split(" ")
.map(
([firstChar, ...rest]) =>
firstChar.toUpperCase() + rest.join("").toLowerCase()
)
.join(" ");
}
/* styles.css */
.tags {
list-style: none;
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
}
.tag {
margin: 0 0.5em 0.5em 0;
padding: 0.7em;
background: LemonChiffon;
border-radius: 0.2em;
box-shadow: 4px 4px 2px rgba(0, 0, 0, 0.3);
}
titleCase helper, взятый из этот ответ