🎥 Make videos programmatically with React
seo ämtli
Jonny Burger2b1748b85e86
diff --git a/packages/convert/app/routes/rotate._index.tsx b/packages/convert/app/routes/rotate._index.tsxnew file mode 100644index 0000000000..e47f4e3674--- /dev/null+++ b/packages/convert/app/routes/rotate._index.tsx@@ -0,0 +1,13 @@+import {Main} from '~/components/Main';+import {getHeaderTitle, getPageTitle} from '~/seo';++const Index = () => {+ return (+ <Main+ headerTitle={getHeaderTitle({type: 'generic-rotate'})}+ pageTitle={getPageTitle({type: 'generic-rotate'})}+ />+ );+};++export default Index;diff --git a/packages/convert/app/seo.ts b/packages/convert/app/seo.tsindex b353daebf4..b8cc2fbb93 100644--- a/packages/convert/app/seo.ts+++ b/packages/convert/app/seo.ts@@ -32,6 +32,9 @@ export type RouteAction =}| {type: 'generic-convert';+ }+ | {+ type: 'generic-rotate';};export const getHeaderTitle = (routeAction: RouteAction) => {@@ -43,19 +46,27 @@ export const getHeaderTitle = (routeAction: RouteAction) => {return 'Fast video conversion in the browser';}- throw new Error('Invalid route action');+ if (routeAction.type === 'generic-rotate') {+ return 'Fast video rotation in the browser';+ }++ throw new Error(`Invalid route action ${routeAction satisfies never}`);};export const getPageTitle = (routeAction: RouteAction) => {if (routeAction.type === 'generic-convert') {- return 'Remotion Convert – Fast video conversion in the browser';+ return 'Remotion Convert - Fast video conversion in the browser';}if (routeAction.type === 'convert') {return `Online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter - Remotion Convert`;}- throw new Error('Invalid route action');+ if (routeAction.type === 'generic-rotate') {+ return 'Online video Rotation - Remotion Convert';+ }++ throw new Error(`Invalid route action ${routeAction satisfies never}`);};export const getDescription = (routeAction: RouteAction) => {@@ -67,5 +78,25 @@ export const getDescription = (routeAction: RouteAction) => {return `The fastest online ${renderHumanReadableContainer(routeAction.input)} to ${renderHumanReadableContainer(routeAction.output)} converter, powered by WebCodecs. No upload required, no watermarks, no limits.`;}- throw new Error('Invalid route action');+ if (routeAction.type === 'generic-rotate') {+ return `The fastest online video rotator, powered by WebCodecs. No upload required, no watermarks, no limits.`;+ }++ throw new Error(`Invalid route action ${routeAction satisfies never}`);+};++export const makeSlug = (routeAction: RouteAction) => {+ if (routeAction.type === 'convert') {+ return `/convert/${routeAction.input}-to-${routeAction.output}`;+ }++ if (routeAction.type === 'generic-convert') {+ return '/convert';+ }++ if (routeAction.type === 'generic-rotate') {+ return '/rotate';+ }++ throw new Error(`Invalid route action ${routeAction satisfies never}`);};diff --git a/packages/docs/copy-convert.ts b/packages/docs/copy-convert.tsindex 154736701a..0bbd7eec6d 100644--- a/packages/docs/copy-convert.ts+++ b/packages/docs/copy-convert.ts@@ -1,5 +1,5 @@import {$} from 'bun';-import fs, {readFileSync, writeFileSync} from 'fs';+import fs, {readFileSync} from 'fs';import path from 'path';// @ts-ignore outside projectimport * as seo from '../convert/app/seo';@@ -11,26 +11,20 @@ const dir = path.join(__dirname, '../convert/spa-dist/client');fs.cpSync(dir, path.join(__dirname, './build/convert'), {recursive: true});-const extraPages: {- slug: string;- pageTitle: string;- description: string;-}[] = [];+const extraPages: seo.RouteAction[] = [];for (const inputs of seo.inputContainers) {for (const outputs of seo.outputContainers) {+ const action: seo.RouteAction = {+ input: inputs,+ output: outputs,+ type: 'convert',+ };+extraPages.push({- slug: `/convert/${inputs}-to-${outputs}`,- pageTitle: seo.getPageTitle({- input: inputs,- output: outputs,- type: 'convert',- }),- description: seo.getDescription({- input: inputs,- output: outputs,- type: 'convert',- }),+ input: inputs,+ output: outputs,+ type: 'convert',});}}@@ -60,18 +54,21 @@ const getContentWithTitle = (title: string, description: string) => {.replace(matcher, `<title>${title}</title>`);};-writeFileSync(- path.join(__dirname, './build/convert/index.html'),- getContentWithTitle(- seo.getPageTitle({type: 'generic-convert'}),- seo.getDescription({type: 'generic-convert'}),- ),-);+extraPages.push({+ type: 'generic-convert',+});++extraPages.push({+ type: 'generic-rotate',+});for (const page of extraPages) {- const out = path.join(__dirname, `./build/${page.slug}/index.html`);+ const slug = seo.makeSlug(page);+ const pageTitle = seo.getPageTitle(page);+ const description = seo.getDescription(page);+ const out = path.join(__dirname, `./build${slug}/index.html`);if (!fs.existsSync(path.dirname(out))) {fs.mkdirSync(path.dirname(out), {recursive: true});}- fs.writeFileSync(out, getContentWithTitle(page.pageTitle, page.description));+ fs.writeFileSync(out, getContentWithTitle(pageTitle, description));}