Skip to content

Commit

Permalink
add open graph tags
Browse files Browse the repository at this point in the history
Source: <https://ogp.me/>
  • Loading branch information
EthanThatOneKid committed Mar 27, 2024
1 parent 8395bbb commit dce07dd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion components/doc/doc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ export default async function DocumentationPage(request: Request) {
const content = contentOf(request);
const playground = await playgroundOf(content.playground);
return (
<DocContent body={content.body} toc={content.toc} playground={playground} />
<DocContent
title={content.title}
body={content.body}
toc={content.toc}
playground={playground}
/>
);
}

Expand Down
11 changes: 10 additions & 1 deletion components/doc/doc_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import Hljs from "#/components/hljs.tsx";
* DocContentProps are the properties for the DocContent component.
*/
export interface DocContentProps {
/**
* title is the title of the documentation page.
*/
title?: string;

/**
* body is the html content of the documentation page.
*/
Expand All @@ -31,12 +36,16 @@ export interface DocContentProps {
* DocContent is the content of a jsonx documentation page.
*/
export default function DocContent(props: DocContentProps) {
const title = `jsonx | ${props.title ?? "Documentation"}`;
return (
<>
<Head>
<title>{title}</title>
<meta property="og:title" content={title} />
<link rel="stylesheet" href="/md.css" />

<Hljs id="github" />
<script src="/copy.js" defer></script>
<link rel="stylesheet" href="/md.css" />
</Head>

<aside class="aside">
Expand Down
7 changes: 6 additions & 1 deletion lib/docs/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface Content {
*/
body: string;

/**
* title is the title of the content.
*/
title?: string;

/**
* toc is the HTML table of contents of the content.
*/
Expand Down Expand Up @@ -121,7 +126,7 @@ export async function readFSItems(
const { body, toc } = renderMd(md);
contents.set(
name.join(NAME_SEPARATOR),
{ md, body, toc, playground },
{ md, body, title, toc, playground },
);

// Store the item in the items array.
Expand Down
4 changes: 2 additions & 2 deletions routes/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export default function App({ Component, url }: PageProps) {
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>jsonx | Documentation</title>
<meta property="og:title" content="jsonx | Documentation" />
<meta property="og:description" content="Learn how to use jsonx." />
<link rel="stylesheet" href="/global.css" />
</head>
<body>
<Nav path={toPath(url.pathname)} />

<Component />

<Foot />
</body>
</html>
Expand Down

0 comments on commit dce07dd

Please sign in to comment.