Skip to content

Commit b1fd950

Browse files
committed
Address PR review feedback
- Remove eager loading support from LazyImage; use plain img in Authors - Fix guides landing page detection (handle with/without trailing slash) - Add build-time error for guides missing title in frontmatter - Add jobTitle field to authors.json, use it directly instead of regex - Make proficiencyLevel configurable via frontmatter (default: Intermediate) - Add proficiencyLevel and keywords to CustomDocFrontMatter type - Remove unnecessary type casts in Metadata component
1 parent a8d216a commit b1fd950

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

docs/authors.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"Paweł Lachowski": {
33
"name": "Paweł Lachowski",
44
"title": "Technical Writer @ RavenDB",
5+
"jobTitle": "Technical Writer",
56
"url": null,
67
"image_url": "https://ravendb.net/wp-content/uploads/2024/11/Default-author-thumbnail-150x150.png",
78
"socials": {}
89
},
910
"Omer Ratsaby": {
1011
"name": "Omer Ratsaby",
1112
"title": "DevOps Engineer @ RavenDB",
13+
"jobTitle": "DevOps Engineer",
1214
"url": null,
1315
"image_url": "https://ravendb.net/wp-content/uploads/2024/11/Default-author-thumbnail-150x150.png",
1416
"socials": {}

src/components/Common/LazyImage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import ThemedImage, { Props as ThemedImageProps } from "@theme/ThemedImage";
55
export interface LazyImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
66
imgSrc?: string | { light: string; dark: string };
77
minContentHeight?: number;
8-
loading?: "lazy" | "eager";
98
}
109

1110
export default function LazyImage({
@@ -15,7 +14,6 @@ export default function LazyImage({
1514
className,
1615
style,
1716
minContentHeight = 100,
18-
loading = "lazy",
1917
...props
2018
}: LazyImageProps) {
2119
const [isLoaded, setIsLoaded] = useState(false);
@@ -47,7 +45,7 @@ export default function LazyImage({
4745
className={clsx(className, "transition-opacity duration-300", !isLoaded ? "opacity-0" : "opacity-100")}
4846
onLoad={() => setIsLoaded(true)}
4947
onError={() => setIsLoaded(true)}
50-
loading={loading}
48+
loading="lazy"
5149
/>
5250
</span>
5351
);

src/theme/DocItem/Authors/index.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from "react";
22
import { useDoc } from "@docusaurus/plugin-content-docs/client";
33
import authorsData from "@site/docs/authors.json";
44
import { Icon } from "@site/src/components/Common/Icon";
5-
import LazyImage from "@site/src/components/Common/LazyImage";
65
import { IconName } from "@site/src/typescript/iconName";
76

87
type Platform = "x" | "github" | "linkedin" | "email";
@@ -80,13 +79,7 @@ export default function DocItemAuthors() {
8079
{author && (
8180
<div className="docAuthor">
8281
{author.imageURL && (
83-
<LazyImage
84-
src={author.imageURL}
85-
alt={author.name}
86-
className="docAuthorImg"
87-
minContentHeight={32}
88-
loading="eager"
89-
/>
82+
<img src={author.imageURL} alt={author.name} className="docAuthorImg" loading="eager" />
9083
)}
9184
<div>
9285
<div className="docAuthorName">

src/theme/DocItem/Metadata/index.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ export default function MetadataWrapper(props: Props): ReactNode {
2525
canonicalUrl = canonicalUrl.concat("/");
2626
}
2727

28-
const isGuide = permalink.startsWith("/guides/") && !permalink.endsWith("/guides/");
29-
const description = metadata.description || (frontMatter.description as string) || "";
28+
const guidesLandingPaths = ["/guides", "/guides/"];
29+
const isGuide = permalink.startsWith("/guides/") && !guidesLandingPaths.includes(permalink);
30+
const description = metadata.description || frontMatter.description || "";
31+
32+
if (isGuide && !metadata.title) {
33+
throw new Error(`Guide "${permalink}" is missing a required "title" in frontmatter.`);
34+
}
35+
3036
const title = metadata.title || "";
3137

32-
const authorKey = frontMatter.author as string | undefined;
38+
const authorKey = frontMatter.author;
3339
const authorInfo = authorKey ? authorsData[authorKey as keyof typeof authorsData] : null;
34-
const publishedAt = frontMatter.publishedAt as string | undefined;
35-
const keywords = frontMatter.keywords as string[] | undefined;
40+
const publishedAt = frontMatter.publishedAt;
41+
const keywords = frontMatter.keywords;
42+
const proficiencyLevel = frontMatter.proficiencyLevel || "Intermediate";
3643

3744
const ogImageUrl = `${baseUrl}/img/social-card.jpg`;
3845

@@ -60,9 +67,9 @@ export default function MetadataWrapper(props: Props): ReactNode {
6067
"@type": "Person",
6168
name: authorInfo.name,
6269
...(authorInfo.url ? { url: authorInfo.url } : {}),
63-
...(authorInfo.title
70+
...(authorInfo.jobTitle
6471
? {
65-
jobTitle: authorInfo.title.replace(/ @ .*$/, ""),
72+
jobTitle: authorInfo.jobTitle,
6673
worksFor: {
6774
"@type": "Organization",
6875
name: "RavenDB",
@@ -79,7 +86,7 @@ export default function MetadataWrapper(props: Props): ReactNode {
7986
url: "https://ravendb.net",
8087
logo: { "@type": "ImageObject", url: ogImageUrl },
8188
},
82-
proficiencyLevel: "Intermediate",
89+
proficiencyLevel,
8390
})
8491
: null;
8592

src/typescript/docMetadata.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface CustomDocFrontMatter extends DocFrontMatter {
1010
icon?: IconName;
1111
image?: string | { light: string; dark: string };
1212
publishedAt?: string;
13+
proficiencyLevel?: string;
14+
keywords?: string[];
1315
}
1416

1517
type CustomDocContextValue = Omit<DocContextValue, "frontMatter" | "metadata"> & {

0 commit comments

Comments
 (0)