Skip to content

🎥 Make videos programmatically with React

better project name in title bar

Jonny Burgerb5c9da8dc2d3
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index 4c5055a8f2..c7447f3fd1 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -52,6 +52,27 @@ export type LegacyBundleOptions = {
onSymlinkDetected?: (path: string) => void;
};
+const getProjectName = ({
+ gitSource,
+ resolvedRemotionRoot,
+}: {
+ gitSource: GitSource | null;
+ resolvedRemotionRoot: string;
+}) => {
+ // Directory name
+ if (!gitSource) {
+ return path.basename(resolvedRemotionRoot);
+ }
+
+ // Subfolder name of a Git repo, e.g `example`
+ if (gitSource.relativeFromGitRoot.trim()) {
+ return path.basename(gitSource.relativeFromGitRoot.trim());
+ }
+
+ // Name of the repo
+ return gitSource.name;
+};
+
export const getConfig = ({
entryPoint,
outDir,
@@ -273,6 +294,10 @@ export async function bundle(...args: Arguments): Promise<string> {
renderDefaults: undefined,
publicFolderExists: `${baseDir + (baseDir.endsWith('/') ? '' : '/')}public`,
gitSource: actualArgs.gitSource ?? null,
+ projectName: getProjectName({
+ gitSource: actualArgs.gitSource ?? null,
+ resolvedRemotionRoot,
+ }),
});
fs.writeFileSync(path.join(outDir, 'index.html'), html);
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.ts
index bc2daa802d..b5eb5c2464 100644
--- a/packages/bundler/src/index-html.ts
+++ b/packages/bundler/src/index-html.ts
@@ -1,5 +1,4 @@
import type {GitSource, RenderDefaults} from '@remotion/studio';
-import path from 'node:path';
import type {StaticFile} from 'remotion';
import {Internals} from 'remotion';
@@ -19,6 +18,7 @@ export const indexHtml = ({
renderDefaults,
publicFolderExists,
gitSource,
+ projectName,
}: {
staticHash: string;
baseDir: string;
@@ -35,6 +35,7 @@ export const indexHtml = ({
title: string;
renderDefaults: RenderDefaults | undefined;
gitSource: GitSource | null;
+ projectName: string;
}) =>
// Must setup remotion_editorName and remotion.remotion_projectName before bundle.js is loaded
`
@@ -59,9 +60,7 @@ export const indexHtml = ({
? `<script>window.remotion_editorName = "${editorName}";</script>`
: '<script>window.remotion_editorName = null;</script>'
}
- <script>window.remotion_projectName = ${JSON.stringify(
- path.basename(remotionRoot),
- )};</script>
+ <script>window.remotion_projectName = ${JSON.stringify(projectName)};</script>
<script>window.remotion_renderDefaults = ${JSON.stringify(
renderDefaults,
)};</script>