Social Links Profile | Dynamic Link Component with JS

Solution retrospective
I create link button component using Javascript, So I can create links dynamically, and In the future I want to make a CMS for this app so that we can create links in the User Interface not from code directly
export default function ({ href, icon, text }) {
const a = document.createElement("a");
a.href = href || "#";
a.classList.add("card__link");
a.setAttribute("target", "_blank");
a.setAttribute("rel", "noopener noreferrer");
const i = document.createElement("i");
i.classList.add(icon);
a.append(i, text);
return a;
}
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on Muh Suryadi Triputra Rahman's solution.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord