Skip to content

feat(core): add getFontStylesheetUrl helper - #391

Closed
cameronapak wants to merge 3 commits into
mainfrom
cursor/cp/ype-4857-fonts-helper-7fa2
Closed

feat(core): add getFontStylesheetUrl helper#391
cameronapak wants to merge 3 commits into
mainfrom
cursor/cp/ype-4857-fonts-helper-7fa2

Conversation

@cameronapak

@cameronapak cameronapak commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

I want to make it easier for people to be able to get the font URL and get the font properly, so this is just an easy helper to make that possible

Summary

YPE-4857 (platform-core fonts helper only). Adds a URL builder so core-only partners can load a YouVersion font stylesheet without assembling app_key by hand.

getFontStylesheetUrl({ fontId?: number; appKey: string; apiHost?: string }): string
  • Default fontId is 1 (Untitled Serif)
  • Default apiHost is api.youversion.com (hostname-only, same as ApiClient / YvFonts / ADR-0004)
  • Returns {origin}/v1/fonts/{fontId}/stylesheet?app_key={appKey} with encodeURIComponent on the app key
  • Hostname-only values get https:// prefixed; full origins pass through
  • Exported from @youversion/platform-core
  • Patch changeset for @youversion/platform-core

Scope lock

URL builder only. This PR does not:

  • Add @font-face, FontsClient, or wire schemas/font.ts
  • Change CDN bible.css, release.yml, or UI (YvFonts stays as-is)
  • Touch hub DevDocs (remaining YPE-4857 work)
  • Touch PR 384, 385, 382 or cp/core-split

ADR-0004 is unchanged: the helper encodes the same stylesheet URL the ADR already describes. No ADR edit (decision unchanged).

Test plan

  • Unit: exact URL for default font/host, custom fontId, origin apiHost, hostname-only apiHost, and query encoding
  • pnpm --filter @youversion/platform-core test — 22 files / 433 tests passed after the hostname-only default
  • CI on f6a5949 was 15 green / 1 skipped; 62b82c1 re-running
Open in Web Open in Cursor 

Greptile Summary

Adds a framework-neutral helper to construct YouVersion font stylesheet URLs and exports it from the core package.

  • Defaults to Untitled Serif and the production API host.
  • Supports hostname-only and full-origin custom hosts.
  • Encodes app keys and removes trailing host slashes.
  • Adds unit coverage and a patch changeset.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported hostname-only custom-host issue is fixed at the current head.

Important Files Changed

Filename Overview
packages/core/src/getFontStylesheetUrl.ts Adds the URL builder and correctly fixes hostname-only custom hosts by prefixing HTTPS.
packages/core/src/getFontStylesheetUrl.test.ts Covers defaults, custom font IDs, full-origin and hostname-only hosts, trailing slashes, and app-key encoding.
packages/core/src/index.ts Exposes the helper and its options type through the core package entry point.
.changeset/ype-4857-fonts-helper.md Records the public helper as a patch release for the core package.

Reviews (3): Last reviewed commit: "fix(core): default getFontStylesheetUrl ..." | Re-trigger Greptile

Context used:

URL builder for the Fonts API stylesheet endpoint so core-only partners can load Untitled Serif without hand-assembling app_key query strings.

Co-authored-by: Cameron Pak <cameronandrewpak@gmail.com>
@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 62b82c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch
@youversion/platform-react-ui Patch
vite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor

cursor Bot commented Sep 9, 2026

Copy link
Copy Markdown

note: Cursor, an AI agent sent on behalf of Cam.

This PR is the platform-core fonts helper slice of YPE-4857 only. Hub DevDocs / the vanilla recipe stay on the ticket. No @font-face, no FontsClient, no CDN/release.yml/UI changes. PRs 384, 385, and 382 were not touched.

Comment thread packages/core/src/getFontStylesheetUrl.ts Outdated
Comment thread packages/core/src/getFontStylesheetUrl.ts Outdated
ApiClient and YvFonts pass apiHost as a bare hostname. Prefix https:// when no scheme is present so those values do not become relative stylesheet URLs.

@cameronapak cameronapak left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

YPE-4857 (fonts / platform-core slice)

Summary

  • Standards must-fix: 0
  • Spec must-fix: 0
  • Worst: none (fonts slice matches locked AC; hub DevDocs is a separate PR)
For Agents

CI: pass (Lint, Type Check, Test, Build, Bundle Size, Greptile Review, changeset, i18n, locale)
Greptile: pass (prior P1 bare-host scheme resolved on f6a5949; thread resolved)
Event: COMMENT — Cam-authored (no self-APPROVE). Would approve on criteria for non-UI.
HEAD: f6a5949
Scope: helper + test + export + patch changeset only; 384/385/382 untouched
Stale Cursor note on full-origin-only apiHost is outdated vs HEAD — resolve after reply

By Code Reviewer bot, sent on behalf of Cam.

Comment thread packages/core/src/getFontStylesheetUrl.ts Outdated
apiHost = 'https://api.youversion.com',
}: GetFontStylesheetUrlOptions): string {
const trimmed = apiHost.replace(/\/+$/, '');
const host = trimmed.includes('://') ? trimmed : `https://${trimmed}`;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Bare hostname now gets an https:// prefix, with a unit test for api-staging.youversion.com. That clears the Greptile P1 without forcing partners to hand-prefix.

For Agents

Verified on f6a5949 (fix(core): accept hostname-only apiHost).

By Code Reviewer bot, sent on behalf of Cam.

Match ApiClient, YvFonts, and ADR-0004. The helper still prefixes https:// when no scheme is present, so the default stylesheet URL is unchanged.
@cameronapak

Copy link
Copy Markdown
Collaborator Author

Closing this in favor of getStyledPassageElement for vanilla clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants