Skip to content

Commit c18d98a

Browse files
ndcunninghamFrozenPandaz
authored andcommitted
docs(core): Add blog author details to nx-dev blog page (#23206)
This PR adds a context view for blog authors that displays details about their social. It will be show on the blog details page. Here is an example: ![Screenshot 2024-05-07 at 7 31 16 AM](https://github.com/nrwl/nx/assets/338948/3abb1cce-e4bd-400c-9a1b-151254630bef) ![Screenshot 2024-05-07 at 7 37 38 AM](https://github.com/nrwl/nx/assets/338948/042bf376-a33d-44a3-addd-812953dd4d65) (cherry picked from commit 5edc64a)
1 parent 975387b commit c18d98a

File tree

8 files changed

+140
-16
lines changed

8 files changed

+140
-16
lines changed

docs/blog/authors.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[
2+
{
3+
"name": "Juri Strumpflohner",
4+
"image": "/blog/images/Juri Strumpfloner.jpeg",
5+
"twitter": "juristr",
6+
"github": "juristr"
7+
},
8+
{
9+
"name": "Colum Ferry",
10+
"image": "/blog/images/Colum Ferry.jpeg",
11+
"twitter": "FerryColum",
12+
"github": "Coly010"
13+
},
14+
{
15+
"name": "Emily Xiong",
16+
"image": "/blog/images/Emily Xiong.jpeg",
17+
"twitter": "xiongemily",
18+
"github": "xiongemi"
19+
},
20+
{
21+
"name": "Isaac Mann",
22+
"image": "/blog/images/Isaac Mann.jpeg",
23+
"twitter": "mannisaac",
24+
"github": "isaacplmann"
25+
},
26+
{
27+
"name": "Katerina Skroumpelou",
28+
"image": "/blog/images/Katerina Skroumpelou.jpeg",
29+
"twitter": "psybercity",
30+
"github": "mandarini"
31+
},
32+
{
33+
"name": "Max Kless",
34+
"image": "/blog/images/Max Kless.jpeg",
35+
"twitter": "MaxKless",
36+
"github": "MaxKless"
37+
},
38+
{
39+
"name": "Victor Savkin",
40+
"image": "/blog/images/Victor Savkin.jpeg",
41+
"twitter": "victorsavkin",
42+
"github": "vsavkin"
43+
},
44+
{
45+
"name": "Zack DeRose",
46+
"image": "/blog/images/Zack DeRose.jpeg",
47+
"twitter": "zackderose",
48+
"github": "ZackDeRose"
49+
}
50+
]

nx-dev/data-access-documents/src/lib/blog.api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class BlogApi {
2121

2222
getBlogPosts(): BlogPostDataEntry[] {
2323
const files: string[] = readdirSync(this.options.blogRoot);
24+
const authors = JSON.parse(
25+
readFileSync(join(this.options.blogRoot, 'authors.json'), 'utf8')
26+
);
2427
const allPosts: BlogPostDataEntry[] = [];
2528

2629
for (const file of files) {
@@ -35,7 +38,9 @@ export class BlogApi {
3538
content,
3639
title: frontmatter.title ?? null,
3740
description: frontmatter.description ?? null,
38-
authors: frontmatter.authors ?? [],
41+
authors: authors.filter((author) =>
42+
frontmatter.authors.includes(author.name)
43+
),
3944
date: this.calculateDate(file, frontmatter),
4045
cover_image: frontmatter.cover_image
4146
? `/documentation${frontmatter.cover_image}` // Match the prefix used by markdown parser

nx-dev/data-access-documents/src/lib/blog.model.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type BlogPostDataEntry = {
22
title: string;
33
content: string;
44
description: string;
5-
authors: string[];
5+
authors: BlogAuthor[];
66
date: string;
77
cover_image: string | null;
88
tags: string[];
@@ -12,3 +12,10 @@ export type BlogPostDataEntry = {
1212
filePath: string;
1313
slug: string;
1414
};
15+
16+
export type BlogAuthor = {
17+
name: string;
18+
image: string;
19+
twitter: string;
20+
github: string;
21+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { BlogAuthor } from '@nx/nx-dev/data-access-documents/node-only';
2+
import { GithubIcon, TwitterIcon } from '@nx/nx-dev/ui-common';
3+
import Image from 'next/image';
4+
5+
interface AuthorDetailProps {
6+
author: BlogAuthor;
7+
}
8+
9+
export default function AuthorDetail({ author }: AuthorDetailProps) {
10+
return (
11+
<div className="space-between invisible absolute left-[65%] right-0 z-30 mt-2 flex w-60 translate-x-[-50%] items-center gap-4 rounded bg-slate-50 p-4 text-sm text-slate-700 opacity-0 shadow-lg ring-1 ring-slate-200 transition-all delay-75 duration-300 ease-in-out md:group-hover:visible md:group-hover:opacity-100 dark:bg-slate-900 dark:text-slate-400 dark:ring-slate-800">
12+
<span>
13+
<Image
14+
alt={author.name}
15+
title={author.name}
16+
loading="lazy"
17+
width="40"
18+
height="40"
19+
decoding="async"
20+
src={`/documentation/blog/images/authors/${author.name}.jpeg`}
21+
className="rounded-full ring-1 ring-white grayscale dark:ring-slate-900"
22+
/>
23+
</span>
24+
<span className="text-balance">{author.name}</span>
25+
<a
26+
href={`https://twitter.com/${author.twitter}`}
27+
aria-label={`Follow ${author.name} on X`}
28+
>
29+
<TwitterIcon aria-hidden="true" className="h-5 w-5" />
30+
</a>
31+
<a
32+
href={`https://github.com/${author.github}`}
33+
aria-label={`View ${author.name}'s GitHub profile`}
34+
>
35+
<GithubIcon aria-hidden="true" className="h-5 w-5" />
36+
</a>
37+
</div>
38+
);
39+
}

nx-dev/ui-blog/src/lib/authors.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
import Image from 'next/image';
2+
import AuthorDetail from './author-detail';
3+
import type { BlogAuthor } from '@nx/nx-dev/data-access-documents/node-only';
24

3-
export function BlogAuthors({ authors }: { authors: string[] }): JSX.Element {
5+
export function BlogAuthors({
6+
authors,
7+
}: {
8+
authors: BlogAuthor[];
9+
}): JSX.Element {
410
return (
5-
<div className="isolate flex items-center -space-x-2 overflow-hidden">
11+
<div className="relative isolate flex items-center -space-x-2">
612
{authors.map((author, index) => (
7-
<Image
8-
key={index}
9-
alt={author}
10-
title={author}
11-
loading="lazy"
12-
width="48"
13-
height="48"
14-
decoding="async"
15-
src={`/documentation/blog/images/authors/${author}.jpeg`}
16-
className="relative inline-block h-6 w-6 rounded-full ring-1 ring-white grayscale dark:ring-slate-900"
17-
/>
13+
<div key={index} className="group">
14+
<Image
15+
alt={author.name}
16+
title={author.name}
17+
loading="lazy"
18+
width="48"
19+
height="48"
20+
decoding="async"
21+
src={`/documentation/blog/images/authors/${author.name}.jpeg`}
22+
className="relative inline-block h-6 w-6 rounded-full ring-1 ring-white grayscale dark:ring-slate-900"
23+
/>
24+
<AuthorDetail author={author} />
25+
</div>
1826
))}
1927
</div>
2028
);

nx-dev/ui-blog/src/lib/more-blogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function MoreBlogs({ blogs }: MoreBlogsProps) {
4040
<span className="hidden w-2/12 flex-none sm:inline-block">
4141
{formattedDate}
4242
</span>
43-
<span className="hidden w-2/12 flex-none sm:inline-block">
43+
<span className="hidden flex-1 overflow-hidden sm:inline-block">
4444
<BlogAuthors authors={post.authors} />
4545
</span>
4646
</Link>

nx-dev/ui-common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export * from './lib/typography';
2020
export * from './lib/github-star-widget';
2121
export * from './lib/youtube.component';
2222
export * from './lib/image-theme';
23+
export * from './lib/twitter-icon';
2324
export { resourceMenuItems } from './lib/headers/menu-items';
2425
export { solutionsMenuItems } from './lib/headers/menu-items';
2526
export { eventItems } from './lib/headers/menu-items';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FC, SVGProps } from 'react';
2+
3+
export const TwitterIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
4+
<svg
5+
fill="currentColor"
6+
role="img"
7+
preserveAspectRatio="xMidYMid meet"
8+
viewBox="0 0 24 24"
9+
xmlns="http://www.w3.org/2000/svg"
10+
{...props}
11+
>
12+
<path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z" />
13+
</svg>
14+
);

0 commit comments

Comments
 (0)