feat: social links with inline SVG icons from CMS
SocialRecord gains icon field (SVG markup string). InlineSvg component parses SVG string via html-react-parser. Footer renders icon on mobile (sm:hidden label), label on sm+ (hidden icon). Email field refactored from string to SocialRecord relation.
This commit is contained in:
+10
-2
@@ -141,6 +141,10 @@ export type SocialRecord = BaseRecord & {
|
||||
* Full URL for the social profile
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* SVG markup string stored in PocketBase
|
||||
*/
|
||||
icon: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,7 +153,7 @@ export type SocialRecord = BaseRecord & {
|
||||
*/
|
||||
export type ContactsRecord = BaseRecord & {
|
||||
/**
|
||||
* Primary contact email address
|
||||
* Raw relation ID — use expand?.email for the resolved record
|
||||
*/
|
||||
email: string;
|
||||
/**
|
||||
@@ -157,9 +161,13 @@ export type ContactsRecord = BaseRecord & {
|
||||
*/
|
||||
socials: string[];
|
||||
/**
|
||||
* Expanded relation data, present when fetched with expand=socials
|
||||
* Expanded relation data, present when fetched with expand=email,socials
|
||||
*/
|
||||
expand?: {
|
||||
/**
|
||||
* Resolved email contact record
|
||||
*/
|
||||
email?: SocialRecord;
|
||||
/**
|
||||
* Resolved social link records
|
||||
*/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { InlineSvg } from './ui/InlineSvg';
|
||||
@@ -0,0 +1,25 @@
|
||||
import parse from 'html-react-parser';
|
||||
import { cn } from '$shared/lib';
|
||||
|
||||
type Props = {
|
||||
/**
|
||||
* SVG markup string to inline as React elements
|
||||
*/
|
||||
svg: string;
|
||||
/**
|
||||
* Additional CSS classes on the wrapper span
|
||||
*/
|
||||
className?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses an SVG markup string into React elements.
|
||||
* Inherits color from parent via currentColor.
|
||||
*/
|
||||
export function InlineSvg({ svg, className }: Props) {
|
||||
if (!svg) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <span className={cn('inline-flex items-center', className)}>{parse(svg)}</span>;
|
||||
}
|
||||
Reference in New Issue
Block a user