← Public packages
@kentcdodds/photo-portfolio
A fast, photo-first portfolio site you update by chatting with your agent: galleries, about, contact, and one-step rollback.
Files
import type { SiteConfig } from './types.ts'
/**
* Public base URL for links that leave the site (canonical, Open Graph,
* sitemap, preview links): the configured `siteUrl` when set, else the
* Kody-hosted mount URL. Never ends with a slash.
*/
export function publicBaseUrl(
config: Pick<SiteConfig, 'siteUrl'>,
hostedUrl: string | undefined,
) {
const base = config.siteUrl ?? hostedUrl
return base ? base.replace(/\/+$/, '') : null
}
/** Join a site path ("/galleries/x") onto a base URL. */
export function joinUrl(base: string, path: string) {
const relative = path.replace(/^\/+/, '')
return relative ? `${base}/${relative}` : base
}
export function previewLink(base: string, token: string) {
return `${joinUrl(base, '/preview')}?token=${encodeURIComponent(token)}`
}