@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;
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.113latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.113
0.0.101
0.0.91
0.0.81
0.0.72
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

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