Skip to content

feat(zod-transform-socials): add generated label field#43

Open
qianmao1989 wants to merge 1 commit into
FujoWebDev:mainfrom
qianmao1989:feat/social-label
Open

feat(zod-transform-socials): add generated label field#43
qianmao1989 wants to merge 1 commit into
FujoWebDev:mainfrom
qianmao1989:feat/social-label

Conversation

@qianmao1989
Copy link
Copy Markdown

Summary

Adds a label field to the transformed social link output as requested in #42.

Label Generation Precedence

  1. Explicit input label — from object social input (e.g., label: "Official Website")
  2. Known platform name — when platform !== "custom" (e.g., "github", "bsky")
  3. URL fallback — strips leading www. from hostname (e.g., "fujocoded.com")

Changes

  • zod-transform-socials/index.ts:
    • Added optional label field to SocialsSchema input object
    • Added generateLabel() helper function
    • Updated buildTransformSocial to include label in output

Example

// Input
["https://github.com/FujoWebDev", { url: "https://store.fujocoded.com", label: "Merch Store" }]

// Output
[
  { url: "https://github.com/FujoWebDev", platform: "github", username: "fujowebdev", icon: "simple-icons:github", label: "github" },
  { url: "https://store.fujocoded.com", platform: "custom", username: null, icon: null, label: "Merch Store" }
]

Fixes #42

… output

Add a `label` field to the transformed social link output with the following precedence:
1. Explicit input `label` from object social input
2. Known platform name when platform !== "custom"
3. Fallback from URL hostname, stripping leading "www."

Closes FujoWebDev#42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add generated labels to social link transforms

1 participant