Skip to main content

social-sharing

Prepares submission body text for social previews by handling markdown-style embed pills ![behavior](url) and ![behavior|width](url).

cleanContentForSocialSharing(content, options?)​

OptionDefaultEffect
convertEmbedsToUrlstrueReplace pills with bare URL
removeEmbedsfalseDrop pills entirely (wins when both set)
maxLength160Truncate at word boundary with ...

Also collapses whitespace and empty lines.

URL helpers​

  • extractEmbedUrls(content) — Valid URLs from embed pills.
  • getFirstYouTubeUrl(content) — First YouTube / youtu.be link among embed URLs.

Sources: src/lib/utils/social-sharing.ts