@beyonk/content-delivery
v5.6.2
Published
Beyonk Content Delivery Utils
Keywords
Readme
@beyonk/content-delivery
Utilities for generating CDN URLs for images, videos, and other assets served through Beyonk's content delivery infrastructure.
Installation
pnpm add @beyonk/content-deliveryUsage
ESM
import {
getCdnUrl,
getAssetUrl,
getThumbnailUrl,
getVideoUrl,
generateSocialImageUrl
} from '@beyonk/content-delivery'CommonJS
const {
getCdnUrl,
getAssetUrl,
getThumbnailUrl,
getVideoUrl,
generateSocialImageUrl
} = require('@beyonk/content-delivery')Mime Type Utilities
The mime type utilities are available as a separate entry point:
// ESM
import { extension, mimeType, getDeliveryType, types } from '@beyonk/content-delivery/lib/mime-type'
// CommonJS
const { extension, mimeType, getDeliveryType, types } = require('@beyonk/content-delivery/lib/mime-type')API
getCdnUrl(cdnUrl, environmentName, metadata, preset, isThumb)
Generates a CDN URL for an image or video asset.
const metadata = { path: 'experiences', id: 'abc123', type: 'image/webp' }
const url = getCdnUrl('https://cdn.example.com', 'prod', metadata, 'small')getAssetUrl(environmentName, metadata)
Generates a direct asset URL bypassing the CDN transformation layer.
const metadata = { path: 'documents', id: 'doc123', type: 'application/pdf' }
const url = getAssetUrl('prod', metadata)getThumbnailUrl(metadata, env, opts)
Generates a thumbnail URL for images or videos.
const env = {
ENVIRONMENT_NAME: 'prod',
IMAGE_BASE_URL: 'https://cdn.example.com',
VIDEO_BASE_URL: 'https://video.example.com/'
}
const url = getThumbnailUrl({ type: 'image/webp', path: 'experiences', id: 'abc123' }, env, { size: 'small' })getVideoUrl(libraryId, video, options)
Generates an embeddable video URL.
const url = getVideoUrl('12345', { id: 'video123' }, { autoplay: false, loop: true })generateSocialImageUrl(cdnUrl, environmentName, type, id, isPortal)
Generates a social sharing image URL.
const url = generateSocialImageUrl('https://cdn.example.com', 'prod', 'experience', 'abc123', false)