sitegen/framework/meta/nextjs/generate/icons.tsx
chloe caruso af60d1172f i accidentally deleted the repo, but recovered it. i'll start committing
it was weird. i pressed delete on a subfolder, i think one of the
pages.off folders that i was using. and then, suddenly, nvim on windows
7 decided to delete every file in the directory. they weren't shred off
the space time continuum, but just marked deleted. i had to pay $80 to
get access to a software that could see them. bleh!

just seeing all my work, a little over a week, was pretty heart
shattering. but i remembered that long ago, a close friend said i could
call them whenever i was feeling sad. i finally took them up on that
offer. the first time i've ever called someone for emotional support.
but it's ok. i got it back. and the site framework is better than ever.

i'm gonna commit and push more often. the repo is private anyways.
2025-06-06 23:38:02 -07:00

62 lines
1.6 KiB
TypeScript

import type { ResolvedMetadata } from "../types/metadata-interface";
import type { Icon, IconDescriptor } from "../types/metadata-types";
import React from "react";
function IconDescriptorLink({ icon }: { icon: IconDescriptor }) {
const { url, rel = "icon", ...props } = icon;
return <link rel={rel} href={url.toString()} {...props} />;
}
function IconLink({ rel, icon }: { rel?: string; icon: Icon }) {
if (typeof icon === "object" && !(icon instanceof URL)) {
if (rel) icon.rel = rel;
return <IconDescriptorLink icon={icon} />;
} else {
const href = icon.toString();
return <link rel={rel} href={href} />;
}
}
export function IconsMetadata({ icons }: { icons: ResolvedMetadata["icons"] }) {
if (!icons) return null;
const shortcutList = icons.shortcut;
const iconList = icons.icon;
const appleList = icons.apple;
const otherList = icons.other;
return (
<>
{shortcutList
? shortcutList.map((icon, index) => (
<IconLink
key={`shortcut-${index}`}
rel="shortcut icon"
icon={icon}
/>
))
: null}
{iconList
? iconList.map((icon, index) => (
<IconLink key={`shortcut-${index}`} rel="icon" icon={icon} />
))
: null}
{appleList
? appleList.map((icon, index) => (
<IconLink
key={`apple-${index}`}
rel="apple-touch-icon"
icon={icon}
/>
))
: null}
{otherList
? otherList.map((icon, index) => (
<IconDescriptorLink key={`other-${index}`} icon={icon} />
))
: null}
</>
);
}