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
2 changes: 1 addition & 1 deletion site/src/components/docs/api-reference/MediaImports.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ interface Props {
const { media, package: pkg, react } = Astro.props;
---

<ModuleImports name={media} package={pkg} react={react} subpath="media" />
<ModuleImports name={media} package={pkg} packageOnlyInstall={true} react={react} subpath="media" />
17 changes: 12 additions & 5 deletions site/src/components/docs/api-reference/ModuleImports.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,29 @@ interface Props {
name: string;
/** Package that ships the module's adapter or extension, installed beside the framework package. */
package?: string;
/** Whether the install command should include only the module package. */
packageOnlyInstall?: boolean;
/** Named export from the React module. */
react: string;
/** Public module family shared by the React, HTML, and CDN imports. */
subpath: 'extensions' | 'media';
}

const { name, package: pkg, react, subpath } = Astro.props;
const { name, package: pkg, packageOnlyInstall = false, react, subpath } = Astro.props;

const cdnCode = `<script type="module" src="${VJS10_CDN_BASE}/${subpath}/${name}.js"></script>`;

const imports: Array<{ code: string; framework: 'react' | 'html'; lang: BundledLanguage }> = [
...(pkg
? [
{ code: `pnpm add @videojs/react ${pkg}`, framework: 'react' as const, lang: 'bash' as const },
{ code: `pnpm add @videojs/html ${pkg}`, framework: 'html' as const, lang: 'bash' as const },
]
? packageOnlyInstall
? [
{ code: `pnpm add ${pkg}`, framework: 'react' as const, lang: 'bash' as const },
{ code: `pnpm add ${pkg}`, framework: 'html' as const, lang: 'bash' as const },
]
: [
{ code: `pnpm add @videojs/react ${pkg}`, framework: 'react' as const, lang: 'bash' as const },
{ code: `pnpm add @videojs/html ${pkg}`, framework: 'html' as const, lang: 'bash' as const },
]
: []),
{
code: `import { ${react} } from '@videojs/react/${subpath}/${name}';`,
Expand Down
Loading