Skip to content

Commit 4352105

Browse files
committed
revert deleted files
1 parent d9de779 commit 4352105

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

src/theme/DocItem/Content/index.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import React from "react";
2+
import clsx from "clsx";
3+
import { ThemeClassNames } from "@docusaurus/theme-common";
4+
import { useDoc } from "@docusaurus/plugin-content-docs/client";
5+
import Heading from "@theme/Heading";
6+
import MDXContent from "@theme/MDXContent";
7+
import TopSection from "@site/src/components/topSection";
8+
import { useLocation } from "@docusaurus/router";
9+
/**
10+
Title can be declared inside md content or declared through
11+
front matter and added manually. To make both cases consistent,
12+
the added title is added under the same div.markdown block
13+
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
14+
15+
We render a "synthetic title" if:
16+
- user doesn't ask to hide it with front matter
17+
- the markdown content does not already contain a top-level h1 heading
18+
*/
19+
function useSyntheticTitle() {
20+
const { metadata, frontMatter, contentTitle } = useDoc();
21+
const shouldRender = !frontMatter.hide_title && typeof contentTitle === "undefined";
22+
if (!shouldRender) {
23+
return null;
24+
}
25+
return metadata.title;
26+
}
27+
export default function DocItemContent({ children }) {
28+
const { frontMatter } = useDoc();
29+
const syntheticTitle = useSyntheticTitle();
30+
const location = useLocation();
31+
return (
32+
<div className={clsx(ThemeClassNames.docs.docMarkdown, "markdown")}>
33+
{syntheticTitle && (
34+
<header>
35+
<Heading as="h1">{syntheticTitle}</Heading>
36+
{(frontMatter.langSwitcher || frontMatter.dbSwitcher) && (
37+
<section className="top-section">
38+
<TopSection
39+
location={location}
40+
langSwitcher={frontMatter?.langSwitcher}
41+
dbSwitcher={frontMatter?.dbSwitcher}
42+
slug={frontMatter?.slugSwitch}
43+
/>
44+
</section>
45+
)}
46+
{frontMatter.completion_time && (
47+
<div className="completion-time-wrapper">
48+
<div className="completion-time-container">{frontMatter.completion_time}</div>
49+
</div>
50+
)}
51+
</header>
52+
)}
53+
<MDXContent>
54+
{children}{" "}
55+
{frontMatter.community_section && (
56+
<div>
57+
<br />
58+
<h2>Stay connected with Prisma</h2>
59+
<p>
60+
Continue your Prisma journey by connecting with{" "}
61+
<a href="https://www.prisma.io/community" target="_blank">
62+
{" "}
63+
our active community
64+
</a>
65+
. Stay informed, get involved, and collaborate with other developers:
66+
<br />
67+
<ul>
68+
<li>
69+
<a
70+
href="https://pris.ly/x?utm_source=docs&utm_medium=generated_text_cta"
71+
target="_blank"
72+
>
73+
Follow us on X
74+
</a>{" "}
75+
for announcements, live events and useful tips.
76+
</li>
77+
<li>
78+
<a
79+
href="https://pris.ly/discord?utm_source=docs&utm_medium=generated_text_cta"
80+
target="_blank"
81+
>
82+
Join our Discord
83+
</a>{" "}
84+
to ask questions, talk to the community, and get active support through
85+
conversations.
86+
</li>
87+
<li>
88+
<a
89+
href="https://pris.ly/youtube?utm_source=docs&utm_medium=generated_text_cta"
90+
target="_blank"
91+
>
92+
Subscribe on YouTube
93+
</a>{" "}
94+
for tutorials, demos, and streams.
95+
</li>
96+
<li>
97+
<a
98+
href="https://pris.ly/github?utm_source=docs&utm_medium=generated_text_cta"
99+
target="_blank"
100+
>
101+
Engage on GitHub
102+
</a>{" "}
103+
by starring the repository, reporting issues, or contributing to an issue.
104+
</li>
105+
</ul>
106+
We genuinely value your involvement and look forward to having you as part of our
107+
community!
108+
</p>
109+
</div>
110+
)}
111+
</MDXContent>
112+
</div>
113+
);
114+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { PageMetadata } from "@docusaurus/theme-common";
3+
import { useDoc } from "@docusaurus/plugin-content-docs/client";
4+
5+
import type { DocFrontMatter } from "@docusaurus/plugin-content-docs";
6+
7+
type PrismaDocFrontMatter = DocFrontMatter & {
8+
metaTitle: string;
9+
metaDescription: string;
10+
};
11+
12+
export default function DocItemMetadata(): JSX.Element {
13+
const { metadata, frontMatter, assets } = useDoc();
14+
const prismaFrontMatter = frontMatter as PrismaDocFrontMatter;
15+
16+
const title = prismaFrontMatter.metaTitle ?? prismaFrontMatter.title ?? metadata.title;
17+
const description = prismaFrontMatter.metaDescription ?? metadata.description;
18+
const keywords = prismaFrontMatter.keywords;
19+
const image = assets.image ?? prismaFrontMatter.image;
20+
21+
return (
22+
<PageMetadata title={title} description={description} keywords={keywords} image={image}>
23+
<meta name="twitter:title" content={title} />
24+
<meta name="twitter:description" content={description} />
25+
</PageMetadata>
26+
);
27+
}

0 commit comments

Comments
 (0)