Skip to content

Commit 7c9bd40

Browse files
committed
fix template name in meta tags
1 parent aa235ec commit 7c9bd40

File tree

4 files changed

+3832
-15
lines changed

4 files changed

+3832
-15
lines changed

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: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// eslint-disable-next-line import/no-unresolved, import/no-internal-modules
2-
import { decompress } from './build/compression';
1+
import { decompress } from './vendors/compression';
2+
import { starterTemplates } from './vendors/templates';
33

44
interface ProjectInfo {
55
title?: string;
@@ -36,8 +36,6 @@ const importProject = async (url: string): Promise<ProjectInfo> => {
3636
}
3737
};
3838

39-
const capitalize = (word: string) => word[0].toUpperCase() + word.slice(1).toLowerCase();
40-
4139
export const getProjectInfo = async (url: URL): Promise<ProjectInfo> => {
4240
const imports = url.searchParams.get('x') || url.hash.slice(1);
4341
if (isCompressedCode(imports)) {
@@ -55,11 +53,11 @@ export const getProjectInfo = async (url: URL): Promise<ProjectInfo> => {
5553
};
5654
}
5755
const template = url.searchParams.get('template');
58-
if (template) {
59-
const templateName = capitalize(template);
56+
const templateName = template ? starterTemplates.find((t) => t.name === template)?.title : '';
57+
if (templateName) {
6058
return {
61-
title: templateName + ' Starter',
62-
description: templateName + ' starter template on LiveCodes',
59+
title: templateName,
60+
description: templateName + ' Template on LiveCodes',
6361
};
6462
}
6563
return {

0 commit comments

Comments
 (0)