Skip to content

Commit

Permalink
feat(config): add title, description and seo metas
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <github@iverly.net>
  • Loading branch information
iverly committed Oct 24, 2023
1 parent 7aea3e2 commit 2bc83f0
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion theme.config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DocsThemeConfig } from 'nextra-theme-docs';
import { useRouter } from 'next/router';
import { useConfig, type DocsThemeConfig } from 'nextra-theme-docs';
import React from 'react';

const config: DocsThemeConfig = {
Expand All @@ -7,6 +8,50 @@ const config: DocsThemeConfig = {
project: {
link: 'https://github.com/faast-rt',
},
head: () => {
const { asPath, defaultLocale, locale } = useRouter();
const { frontMatter } = useConfig();

const domain = 'faast-rt.com';
const url =
'https://faast-rt.com' +
(defaultLocale === locale ? asPath : `/${locale}${asPath}`);

return (
<>
<meta property="og:url" content={url} />
<meta property="og:type" content="website" />
<meta
property="og:title"
content={frontMatter.title || 'Faast - A Serverless runtime in Rust'}
/>
<meta
property="og:description"
content={frontMatter.description || 'A Serverless runtime in Rust'}
/>

<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content={domain} />
<meta property="twitter:url" content={url} />
<meta
name="twitter:title"
content={frontMatter.title || 'Faast - A Serverless runtime in Rust'}
/>
<meta
name="twitter:description"
content={frontMatter.description || 'A Serverless runtime in Rust'}
/>
</>
);
},
useNextSeoProps() {
const { asPath } = useRouter();
if (asPath !== '/') {
return {
titleTemplate: '%s - Faast',
};
}
},
};

export default config;

0 comments on commit 2bc83f0

Please sign in to comment.