Skip to content

Commit 293a641

Browse files
committed
fix template name in meta tags
1 parent cb27cee commit 293a641

5 files changed

Lines changed: 3832 additions & 13 deletions

File tree

functions/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ export const onRequest: PgFunction = async function (context) {
5858
}"`,
5959
)
6060
.replace(
61-
/content="Code Playground That Just Works!"/g,
61+
/content="A Code Playground That Just Works!"/g,
6262
`content="${
6363
!title && !description
64-
? 'Code Playground That Just Works!'
64+
? 'A Code Playground That Just Works!'
6565
: description || 'A project on LiveCodes.'
6666
}"`,
6767
)

functions/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { decompress } from './vendors/compression';
2+
import { starterTemplates } from './vendors/templates';
23

34
interface ProjectInfo {
45
title?: string;
@@ -35,8 +36,6 @@ const importProject = async (url: string): Promise<ProjectInfo> => {
3536
}
3637
};
3738

38-
const capitalize = (word: string) => word[0].toUpperCase() + word.slice(1).toLowerCase();
39-
4039
export const getProjectInfo = async (url: URL): Promise<ProjectInfo> => {
4140
const imports = url.searchParams.get('x') || url.hash.slice(1);
4241
if (isCompressedCode(imports)) {
@@ -54,11 +53,11 @@ export const getProjectInfo = async (url: URL): Promise<ProjectInfo> => {
5453
};
5554
}
5655
const template = url.searchParams.get('template');
57-
if (template) {
58-
const templateName = capitalize(template);
56+
const templateName = template ? starterTemplates.find((t) => t.name === template)?.title : '';
57+
if (templateName) {
5958
return {
60-
title: templateName + ' Starter',
61-
description: templateName + ' starter template on LiveCodes',
59+
title: templateName,
60+
description: templateName + ' Template on LiveCodes',
6261
};
6362
}
6463
return {

0 commit comments

Comments
 (0)