@fujocoded/zod-transform-socials
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published

@fujocoded/zod-transform-socials

Applies a zod transformation to a list of social contacts. Automatically surfaces website and username, as well as an icon name for usage with AstroIcon.

Sample usage

In content collection (or other Zod bit):

import { SocialLinks } from "@fujocoded/zod-transform-socials";
// ...

export const teamCollection = defineCollection({
  type: "data",
  schema: (tools) =>
    z.object({
      // ...
      contacts: SocialLinks,
    });
});

Yaml file:

name: essential-randomness
contacts:
  - https://essentialrandomness.com
  - https://essential-randomness.tumblr.com
  - https://twitter.com/essentialrandom
  - url: https://indiepocalypse.social/@essentialrandom
    platform: mastodon
  - https://github.com/essential-randomness
  - https://patreon.com/essentialrandomness
  - https://ko-fi.com/essentialrandomness

Usage (look at output for understading):

const team = await getCollection("team");
team.map((member) => console.log(member.data.contacts));

Usage as props:

import type { SocialLinksData } from "@fujocoded/zod-transform-socials";

interface Props {
  name: string;
  avatar: string;
  contacts: SocialLinksData;
}

Readme

Keywords

Package Sidebar

Install

npm i @fujocoded/zod-transform-socials

Weekly Downloads

8

Version

0.0.11

License

MIT

Unpacked Size

19 kB

Total Files

7

Last publish

Collaborators

  • enigmalea
  • essential.randomn3ss