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
4 changes: 4 additions & 0 deletions packages/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export default async function RootLayout({children}: {children: React.ReactNode}
docsRepositoryBase="https://github.com/redotvideo/revideo/blob/main/packages/docs"
sidebar={{defaultMenuCollapseLevel: 1}}
pageMap={pageMap}
// The docs are dark-only (forcedTheme below), so hide the theme
// switch Nextra otherwise renders in the sidebar footer — a toggle
// that has no effect.
darkMode={false}
nextThemes={{defaultTheme: "dark", forcedTheme: "dark"}}
>
{children}
Expand Down
30 changes: 10 additions & 20 deletions packages/docs/src/components/site/revideo-import-map.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import fs from 'node:fs';
import path from 'node:path';
// Statically imported (rather than read via `fs` at render time) so Next
// bundles it into the server output. A runtime `fs.readFileSync` of a computed
// path isn't picked up by Next's file tracing, so it's dropped from the
// production build and the import map silently disappears - which breaks the
// fiddles' `import('@revideo/2d')` with "bare specifier ... not remapped".
//
// The manifest is generated by scripts/copy-modules.mjs, which runs before
// `next build`/`next dev` (see package.json). It maps `@revideo/core` /
// `@revideo/2d` to the hashed ESM bundles copied into public/modules.
import manifest from '@/generated/modules.json';

// Keep in sync with `basePath` in next.config.ts.
const BASE_PATH = '/revideo';
Expand All @@ -10,24 +18,6 @@ const BASE_PATH = '/revideo';
* bundles copied into public/modules by scripts/copy-modules.mjs.
*/
export function RevideoImportMap() {
let manifest: Record<string, string>;
try {
manifest = JSON.parse(
fs.readFileSync(
path.join(process.cwd(), 'src', 'generated', 'modules.json'),
'utf8',
),
);
} catch {
// Without the manifest the fiddles cannot load the runtime; skip the
// import map instead of failing the whole site.
console.warn(
'src/generated/modules.json is missing - run `npm run modules:copy` ' +
'to enable the interactive fiddles.',
);
return null;
}

const importMap = {
imports: {
'@revideo/core': `${BASE_PATH}${manifest['@revideo/core']}`,
Expand Down
Loading