Skip to content

Commit

Permalink
fix(website): improve meta descriptions (#969)
Browse files Browse the repository at this point in the history
* fix(website): improve meta descriptions

* fix: add variable typefaces to desc

* fix: cdn title
  • Loading branch information
ayuhito committed Apr 18, 2024
1 parent 105202b commit 51af24d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 12 deletions.
20 changes: 18 additions & 2 deletions website/app/routes/fonts.$id._index.tsx
Expand Up @@ -155,13 +155,29 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
});
};

const generateDescription = (metadata: Metadata) => {
const { family, category, weights, styles, variable } = metadata;
const weightDesc =
weights.length > 1
? `weights ranging from ${weights[0]} to ${weights.at(-1)}`
: `a single weight of ${weights[0]}`;

const italicDesc = styles.includes('italic')
? ' including italic variants'
: '';

const variableDesc = variable ? 'variable ' : '';

return `The ${family} ${variableDesc}font family is a versatile ${category} web typeface offering ${weightDesc}${italicDesc} for free. Download and self-host via an NPM package for performance and privacy, enhancing your website's typography and user experience.`;
};

export const meta: MetaFunction<typeof loader> = ({ data }) => {
const title = data?.metadata.family
? `${data.metadata.family} | Fontsource`
: 'Fontsource';

const description = data?.metadata.family
? `Download and self-host the ${data.metadata.family} font in a neatly bundled NPM package.`
const description = data?.metadata
? generateDescription(data.metadata)
: undefined;
return ogMeta({ title, description });
};
Expand Down
22 changes: 19 additions & 3 deletions website/app/routes/fonts.$id.cdn.tsx
Expand Up @@ -38,13 +38,29 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
});
};

const generateDescription = (metadata: Metadata) => {
const { family, category, weights, styles, variable } = metadata;
const weightDesc =
weights.length > 1
? `weights ranging from ${weights[0]} to ${weights.at(-1)}`
: `a single weight of ${weights[0]}`;

const italicDesc = styles.includes('italic')
? ' including italic variants'
: '';

const variableDesc = variable ? 'variable ' : '';

return `The ${family} ${variableDesc}font family is a versatile ${category} web typeface offering ${weightDesc}${italicDesc} for free. Hosted on a privacy-friendly CDN that is free to use and simple to integrate into your website.`;
};

export const meta: MetaFunction<typeof loader> = ({ data }) => {
const title = data?.metadata.family
? `${data.metadata.family} | Fontsource`
? `${data.metadata.family} | CDN | Fontsource`
: undefined;

const description = data?.metadata.family
? `Download and self-host the ${data.metadata.family} font in a neatly bundled NPM package.`
const description = data?.metadata
? generateDescription(data.metadata)
: undefined;
return ogMeta({ title, description });
};
Expand Down
22 changes: 19 additions & 3 deletions website/app/routes/fonts.$id.install.tsx
Expand Up @@ -38,13 +38,29 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
});
};

const generateDescription = (metadata: Metadata) => {
const { family, category, weights, styles, variable } = metadata;
const weightDesc =
weights.length > 1
? `weights ranging from ${weights[0]} to ${weights.at(-1)}`
: `a single weight of ${weights[0]}`;

const italicDesc = styles.includes('italic')
? ' including italic variants'
: '';

const variableDesc = variable ? 'variable ' : '';

return `The ${family} ${variableDesc}font family is a versatile ${category} web typeface offering ${weightDesc}${italicDesc} for free. Download and self-host via an NPM package for performance and privacy, enhancing your website's typography and user experience.`;
};

export const meta: MetaFunction<typeof loader> = ({ data }) => {
const title = data?.metadata.family
? `${data.metadata.family} | Fontsource`
? `${data.metadata.family} | Install | Fontsource`
: undefined;

const description = data?.metadata.family
? `Download and self-host the ${data.metadata.family} font in a neatly bundled package.`
const description = data?.metadata
? generateDescription(data.metadata)
: undefined;
return ogMeta({ title, description });
};
Expand Down
8 changes: 4 additions & 4 deletions website/app/utils/meta.ts
Expand Up @@ -14,7 +14,7 @@ export const ogMeta = ({ title, description }: OGMeta): MetaDescriptor[] => {
name: 'description',
content:
description ??
'Download and self-host Open Source fonts in neatly bundled NPM packages.',
'Download and self-host 1500+ open-source fonts in neatly bundled NPM packages. Access a comprehensive library of web typefaces for free.',
},
{
property: 'og:title',
Expand All @@ -24,7 +24,7 @@ export const ogMeta = ({ title, description }: OGMeta): MetaDescriptor[] => {
property: 'og:description',
content:
description ??
'Download and self-host Open Source fonts in neatly bundled NPM packages.',
'Download and self-host 1500+ open-source fonts in neatly bundled NPM packages. Access a comprehensive library of web typefaces for free.',
},
{
property: 'og:image',
Expand Down Expand Up @@ -54,7 +54,7 @@ export const ogMeta = ({ title, description }: OGMeta): MetaDescriptor[] => {
name: 'twitter:description',
content:
description ??
'Download and self-host Open Source fonts in neatly bundled NPM packages.',
'Download and self-host 1500+ open-source fonts in neatly bundled NPM packages. Access a comprehensive library of web typefaces for free.',
},
{
name: 'twitter:image',
Expand All @@ -76,7 +76,7 @@ export const ogMeta = ({ title, description }: OGMeta): MetaDescriptor[] => {
url: 'https://fontsource.org',
name: 'Fontsource',
description:
'Download and self-host Open Source fonts in neatly bundled NPM packages.',
'Download and self-host 1500+ open-source fonts in neatly bundled NPM packages. Access a comprehensive library of web typefaces for free.',
},
},
];
Expand Down

0 comments on commit 51af24d

Please sign in to comment.