diff --git a/docs/app/utils/site.ts b/docs/app/utils/site.ts index 07e750c..694cd28 100644 --- a/docs/app/utils/site.ts +++ b/docs/app/utils/site.ts @@ -1,13 +1,39 @@ -export { - absoluteImageUrl, - canonicalUrl, - IMAGE_ORIGIN, - OG_IMAGE_HEIGHT, - OG_IMAGE_PATH, - OG_IMAGE_URL, - OG_IMAGE_WIDTH, - shareTitle, - SITE_DESCRIPTION, - SITE_NAME, - SITE_ORIGIN, -} from '../../shared/site' +/** Canonical origin (`og:url`). Matches the site URL in the README. */ +export const SITE_ORIGIN = 'https://ui.froq.me' + +/** + * Share-image origin. X refuses to fetch froq.me, so `og:image` and + * `twitter:image` use the Worker URL. + */ +export const IMAGE_ORIGIN = 'https://ui.sayhola.workers.dev' + +export const SITE_NAME = 'froq/ui' + +export const OG_IMAGE_PATH = '/og.png' +export const OG_IMAGE_WIDTH = 1200 +export const OG_IMAGE_HEIGHT = 630 + +export const OG_IMAGE_URL = absoluteImageUrl(OG_IMAGE_PATH) + +export const SITE_DESCRIPTION = 'Small controls, shared behavior, one visual language. Built for froq’s projects, with the details still open to refinement.' + +/** Absolute canonical URL for a route path (`/` or `/zh/docs`). */ +export function canonicalUrl(path: string): string { + if (!path || path === '/') + return SITE_ORIGIN + return `${SITE_ORIGIN}${path.replace(/\/+$/, '')}` +} + +/** Absolute https URL for a share image. Already-absolute https URLs pass through. */ +export function absoluteImageUrl(src: string): string { + if (/^https:\/\//i.test(src)) + return src + const path = src.startsWith('/') ? src : `/${src}` + return `${IMAGE_ORIGIN}${path}` +} + +export function shareTitle(title: string | undefined | null): string { + if (!title || title === SITE_NAME) + return SITE_NAME + return `${title} — ${SITE_NAME}` +} diff --git a/docs/nuxt.config.ts b/docs/nuxt.config.ts index a5b6d38..d93e38f 100644 --- a/docs/nuxt.config.ts +++ b/docs/nuxt.config.ts @@ -1,10 +1,10 @@ import { readdirSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { countCardWords } from '@froq/og-covers-layer/card-words' +import { IMAGE_ORIGIN, SITE_DESCRIPTION, SITE_NAME } from './app/utils/site' import { componentFile } from './shared/component-files' import { keepEmptyTitle } from './shared/empty-title' import { listPublicShareImages } from './shared/public-files' -import { IMAGE_ORIGIN, SITE_DESCRIPTION, SITE_NAME } from './shared/site' const siteDist = fileURLToPath(new URL('../dist', import.meta.url)) const componentsRoot = fileURLToPath(new URL('../src/components', import.meta.url)) diff --git a/docs/shared/site.ts b/docs/shared/site.ts deleted file mode 100644 index 694cd28..0000000 --- a/docs/shared/site.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** Canonical origin (`og:url`). Matches the site URL in the README. */ -export const SITE_ORIGIN = 'https://ui.froq.me' - -/** - * Share-image origin. X refuses to fetch froq.me, so `og:image` and - * `twitter:image` use the Worker URL. - */ -export const IMAGE_ORIGIN = 'https://ui.sayhola.workers.dev' - -export const SITE_NAME = 'froq/ui' - -export const OG_IMAGE_PATH = '/og.png' -export const OG_IMAGE_WIDTH = 1200 -export const OG_IMAGE_HEIGHT = 630 - -export const OG_IMAGE_URL = absoluteImageUrl(OG_IMAGE_PATH) - -export const SITE_DESCRIPTION = 'Small controls, shared behavior, one visual language. Built for froq’s projects, with the details still open to refinement.' - -/** Absolute canonical URL for a route path (`/` or `/zh/docs`). */ -export function canonicalUrl(path: string): string { - if (!path || path === '/') - return SITE_ORIGIN - return `${SITE_ORIGIN}${path.replace(/\/+$/, '')}` -} - -/** Absolute https URL for a share image. Already-absolute https URLs pass through. */ -export function absoluteImageUrl(src: string): string { - if (/^https:\/\//i.test(src)) - return src - const path = src.startsWith('/') ? src : `/${src}` - return `${IMAGE_ORIGIN}${path}` -} - -export function shareTitle(title: string | undefined | null): string { - if (!title || title === SITE_NAME) - return SITE_NAME - return `${title} — ${SITE_NAME}` -}