fix(site): skip docs links for features without reference pages (#1394)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Darius Cepulis
2026-07-02 11:04:31 -07:00
committed by GitHub
co-authored by Claude
parent fb50e331f2
commit 2a8cbd0df4
8 changed files with 115 additions and 34 deletions
@@ -30,14 +30,6 @@ const presets: PresetReferenceType[] = entries
const { framework } = Astro.params;
const pkg = framework && isValidFramework(framework) ? `@videojs/${framework}` : '@videojs/html';
/**
* Feature slug overrides for cases where kebabCase(featureName) doesn't
* match the docs page slug.
*/
const FEATURE_SLUG_OVERRIDES: Record<string, string> = {
textTrack: 'text-tracks',
};
/**
* Native media elements used by presets that don't have a custom element.
* The pipeline can't detect these since they're not classes with `static tagName`.
@@ -47,13 +39,6 @@ const NATIVE_MEDIA_ELEMENTS: Record<string, string> = {
audio: 'audio',
};
function featureDocsSlug(featureName: string): string {
const override = FEATURE_SLUG_OVERRIDES[featureName];
if (override) return `reference/feature-${override}`;
const kebab = featureName.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
return `reference/feature-${kebab}`;
}
function htmlMediaElement(preset: PresetReferenceType): string | undefined {
return preset.html.mediaElement ?? NATIVE_MEDIA_ELEMENTS[preset.name];
}
@@ -122,19 +107,27 @@ const listFormat = new Intl.ListFormat('en', { style: 'long', type: 'unit' });
<dd>
{preset.features.length > 0
? listFormat
.formatToParts(preset.features)
.map((part) =>
part.type === "element" ? (
.formatToParts(preset.features.map((f) => f.name))
.map((part) => {
if (part.type !== "element") {
return <span>{part.value}</span>;
}
const feature = preset.features.find(
(f) => f.name === part.value,
)!;
return feature.hasReference ? (
<DocsLink
class="inline-block whitespace-nowrap"
slug={featureDocsSlug(part.value)}
slug={feature.slug}
>
{part.value}
{feature.name}
</DocsLink>
) : (
<span>{part.value}</span>
),
)
<span class="inline-block whitespace-nowrap">
{feature.name}
</span>
);
})
: ""}
</dd>