Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions docs/app/utils/site.ts
Original file line number Diff line number Diff line change
@@ -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}`
}
2 changes: 1 addition & 1 deletion docs/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
39 changes: 0 additions & 39 deletions docs/shared/site.ts

This file was deleted.

Loading