mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
chore: replace SocialLinks with preact component
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
---
|
---
|
||||||
import Legal from './Legal.astro';
|
import Legal from './Legal.astro';
|
||||||
import RSSLink from './RSSLink.astro';
|
import RSSLink from './RSSLink.astro';
|
||||||
import SocialLinks from './SocialLinks.astro';
|
|
||||||
import Subnavigation from './Subnavigation.astro';
|
import Subnavigation from './Subnavigation.astro';
|
||||||
import { UpLink } from '.';
|
import { UpLink, SocialLinks } from '.';
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer
|
<footer
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
import { Sprite } from 'astro-icon';
|
|
||||||
|
|
||||||
import { Link } from '.';
|
|
||||||
|
|
||||||
import data from '../data/social-links.json';
|
|
||||||
---
|
|
||||||
|
|
||||||
<nav class="flex flex-1 sm:justify-center" aria-label="Social Links">
|
|
||||||
{
|
|
||||||
data.map(({ text, url, icon, props = {} }) => (
|
|
||||||
<Link
|
|
||||||
aria-label={text}
|
|
||||||
class="flex h-clickarea w-clickarea cursor-pointer items-center justify-center"
|
|
||||||
href={url}
|
|
||||||
title={text}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<Sprite name={icon} class="h-icon-small w-icon-small" />
|
|
||||||
</Link>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</nav>
|
|
||||||
39
src/components/SocialLinks.tsx
Normal file
39
src/components/SocialLinks.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import type { FunctionalComponent, JSX } from 'preact';
|
||||||
|
import type { SVGProps } from 'preact/compat';
|
||||||
|
|
||||||
|
import { Link } from '.';
|
||||||
|
import { Github, Instagram, Mail, TwitterX } from './icons';
|
||||||
|
|
||||||
|
import data from '../data/social-links.json';
|
||||||
|
|
||||||
|
type IconComponent = FunctionalComponent<SVGProps<SVGSVGElement>>;
|
||||||
|
type IconMap = { [key: string]: IconComponent };
|
||||||
|
|
||||||
|
const renderIcon = (iconName: string): JSX.Element => {
|
||||||
|
const iconMap: IconMap = {
|
||||||
|
mail: Mail,
|
||||||
|
twitter: TwitterX,
|
||||||
|
github: Github,
|
||||||
|
instagram: Instagram,
|
||||||
|
};
|
||||||
|
|
||||||
|
const IconComponent = iconMap[iconName];
|
||||||
|
return <IconComponent class="icon h-icon-small w-icon-small" />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SocialLinks: FunctionalComponent = () => (
|
||||||
|
<nav class="flex flex-1 sm:justify-center" aria-label="Social Links">
|
||||||
|
{data.map((item, index) => (
|
||||||
|
<Link
|
||||||
|
aria-label={item.text}
|
||||||
|
class="flex h-clickarea w-clickarea cursor-pointer items-center justify-center"
|
||||||
|
href={item.url}
|
||||||
|
key={index}
|
||||||
|
title={item.text}
|
||||||
|
{...(item.props ? item.props : {})}
|
||||||
|
>
|
||||||
|
{renderIcon(item.icon)}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
@@ -25,6 +25,7 @@ export * from './OrderedList';
|
|||||||
export * from './PrimeVideoFlag';
|
export * from './PrimeVideoFlag';
|
||||||
export * from './ProjectIntro';
|
export * from './ProjectIntro';
|
||||||
export * from './Pullquote';
|
export * from './Pullquote';
|
||||||
|
export * from './SocialLinks';
|
||||||
export * from './Spotify';
|
export * from './Spotify';
|
||||||
export * from './Subheadline';
|
export * from './Subheadline';
|
||||||
export * from './Subsubheadline';
|
export * from './Subsubheadline';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"text": "Mail",
|
"text": "Mail",
|
||||||
"url": "#protected-email",
|
"url": "#protected-email",
|
||||||
"icon": "ri:mail-line",
|
"icon": "mail",
|
||||||
"props": {
|
"props": {
|
||||||
"data-domain": "stefanimhoff",
|
"data-domain": "stefanimhoff",
|
||||||
"data-name": "hey",
|
"data-name": "hey",
|
||||||
@@ -13,16 +13,16 @@
|
|||||||
{
|
{
|
||||||
"text": "Twitter",
|
"text": "Twitter",
|
||||||
"url": "https://twitter.com/kogakure",
|
"url": "https://twitter.com/kogakure",
|
||||||
"icon": "ri:twitter-line"
|
"icon": "twitter"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Instagram",
|
"text": "Instagram",
|
||||||
"url": "https://instagram.com/kogakure",
|
"url": "https://instagram.com/kogakure",
|
||||||
"icon": "ri:instagram-line"
|
"icon": "instagram"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "GitHub",
|
"text": "GitHub",
|
||||||
"url": "https://github.com/kogakure",
|
"url": "https://github.com/kogakure",
|
||||||
"icon": "ri:github-line"
|
"icon": "github"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user