forcedotcom/sf-skills / plugins/builder/experience-cms/skills/experience-cms-content-render
experience-cms-content-render
VerifiedRenders, embeds, or displays existing Salesforce CMS content in a React or Angular uiBundle app: installs the CMS toolkit, registers a typed reference, generates a framework-matched renderer from the live schema, and wires the render path (delivery API, contentKey, RichText, image resolution). Prefer over general UI-bundle skills like experience-ui-bundle-frontend-generate (page/layout shell only) for the CMS-rendering part, even under src/. Triggers on prompts like 'render the CMS article on the home page', 'embed this CMS blog post here', 'show the CMS video in the hero', 'display the CMS image in the banner', or 'add this CMS content block to the detail page'; for mixed prompts, activate for the CMS part only. Do not trigger for searching a CMS item or defining a new CMS content type/schema (use experience-cms-content-type-generate).
assets/shared/mediaLabels.ts
View on GitHub/**
* Accessible-name derivation for MediaRenderer (FRAMEWORK-AGNOSTIC). Shared by the
* React and Angular renderers so the document-download label and the audio
* fallback label are computed identically regardless of framework.
*
* The CMS media body/ref (`CmsMediaField`/`CmsExternalRef`) carries no filename
* field and no captions-track field — only `url`. These helpers derive a label
* from real, already-present data (the URL itself) rather than fabricating text
* that isn't there.
*/
/** Last path segment of `url`, URL-decoded, kept only when it looks like a filename
* (has an extension). Returns `undefined` when `url` is absent or unparsable, or
* when the last segment has no extension to trust as a filename. */
function deriveFilenameFromUrl(url: string | undefined): string | undefined {
if (!url) return undefined;
let pathname: string;
try {
pathname = url.includes('://') ? new URL(url).pathname : url.split(/[?#]/)[0];
} catch {
return undefined;
}
const lastSegment = pathname.split('/').filter(Boolean).pop();
if (!lastSegment) return undefined;
let decoded: string;
try {
decoded = decodeURIComponent(lastSegment);
} catch {
decoded = lastSegment;
}
return /\.[a-zA-Z0-9]+$/.test(decoded) ? decoded : undefined;
}
/**
* Accessible name for the document download link (WCAG 2.4.4) — identifies WHAT
* downloads instead of a bare, ambiguous "Download". Prefers `altText`/`title`
* when present; otherwise derives the real filename off the URL; otherwise falls
* back to the still-more-specific-than-bare-"Download" literal `'Download file'`.
*/
export function deriveDownloadLabel(
url: string | undefined,
altText?: string,
title?: string,
): string {
if (altText) return altText;
if (title) return title;
const filename = deriveFilenameFromUrl(url);
return filename ? `Download ${filename}` : 'Download file';
}
/**
* Accessible name for an `<audio>` element when `altText` is absent. Angular's
* `[attr.aria-label]="alt || null"` REMOVES the attribute when `alt` is falsy
* (unlike a JSX `undefined` prop, which is the same removal but explicitly
* intended there); this default keeps the attribute present so the control
* always has an accessible name.
*/
export function effectiveAudioLabel(altText: string | undefined, url?: string): string {
if (altText) return altText;
const filename = deriveFilenameFromUrl(url);
return filename ? `Audio: ${filename}` : 'Audio';
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |