Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blog): authors page #10216

Merged
merged 125 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
269eaaa
feat(blog): authors page
OzakIOne Jun 13, 2024
f734a90
fix build
OzakIOne Jun 13, 2024
29b3a64
refactor: apply lint autofix
OzakIOne Jun 13, 2024
f1a4427
fix typo
OzakIOne Jun 14, 2024
1792c78
refactor: apply lint autofix
OzakIOne Jun 14, 2024
e1c0e5e
fix tests
OzakIOne Jun 14, 2024
20e5f29
fix tests
OzakIOne Jun 14, 2024
d018eb6
fix typecheck
OzakIOne Jun 14, 2024
f29b69a
update styles
OzakIOne Jun 14, 2024
cb4cc78
fix test?
OzakIOne Jun 16, 2024
6e66bc7
revert
OzakIOne Jun 16, 2024
fc7f7d0
remove socials & support unnamed author
OzakIOne Jun 17, 2024
cac2f99
remove duplication and inline check
OzakIOne Jun 17, 2024
65db409
feat: permalink support
OzakIOne Jun 18, 2024
a6dbf71
feat: author description
OzakIOne Jun 18, 2024
2f725cb
spread properties
OzakIOne Jun 19, 2024
8bf3e4f
refactor
OzakIOne Jun 19, 2024
2f69b6d
refactor: image base url
OzakIOne Jun 19, 2024
80f368a
refactor: types
OzakIOne Jun 19, 2024
574d45a
style: use blog post author ui
OzakIOne Jun 19, 2024
ff32178
fix bug when permalink is other author key with slash
OzakIOne Jun 19, 2024
d4f892f
refactor
OzakIOne Jun 19, 2024
788b198
refactor: apply lint autofix
OzakIOne Jun 19, 2024
16b0dbf
refactor
OzakIOne Jun 20, 2024
5c789b3
refactor remove pageAuthor prop, use author instead
OzakIOne Jun 20, 2024
151f49f
Revert "refactor remove pageAuthor prop, use author instead"
OzakIOne Jun 20, 2024
0a35323
move authorsUtils to blog
OzakIOne Jun 23, 2024
ce545b0
Merge branch 'main' into ozaki/mediaShareButtons
slorber Jun 24, 2024
da37991
Refactor blog author pages code and types
slorber Jun 24, 2024
d6df47c
move useBlogPostsPlural & listByLetters
OzakIOne Jun 25, 2024
6258f80
move for consistency with tags components
OzakIOne Jun 25, 2024
cf5f2ea
update theme path
OzakIOne Jun 25, 2024
6fcd67f
fix test
OzakIOne Jun 25, 2024
6b62c98
fix tests
OzakIOne Jun 25, 2024
485435d
Merge branch 'main' into ozaki/mediaShareButtons
OzakIOne Jun 27, 2024
ba12369
fix type
OzakIOne Jun 27, 2024
ad66da7
typecheck
OzakIOne Jun 28, 2024
f538f5f
refactor: move logic in contentLoaded
OzakIOne Jul 1, 2024
a4fdaf1
move code
OzakIOne Jul 1, 2024
ece683a
Merge branch 'main' into ozaki/mediaShareButtons
OzakIOne Jul 1, 2024
aec2154
fix typecheck
OzakIOne Jul 1, 2024
44c426a
fix authorinput type mismatch
slorber Jul 2, 2024
051f473
Merge remote-tracking branch 'origin/ozaki/mediaShareButtons' into oz…
slorber Jul 2, 2024
e85a803
fix types
slorber Jul 2, 2024
a9bf820
little refactors
slorber Jul 2, 2024
6a1ff0a
refactor (pagination not working)
OzakIOne Jul 8, 2024
ae795a3
pagination
OzakIOne Jul 9, 2024
d4a64bb
refactor
OzakIOne Jul 9, 2024
66d457b
refactor list letter & permalink collision
OzakIOne Jul 9, 2024
b8a5ae9
remove authorKey fallback for name
OzakIOne Jul 9, 2024
9d6d8d6
review
OzakIOne Jul 9, 2024
5893259
fix test
OzakIOne Jul 9, 2024
c280f02
refactor: apply lint autofix
OzakIOne Jul 9, 2024
78ab5ca
refactor review
OzakIOne Jul 9, 2024
12962f4
refactor
OzakIOne Jul 10, 2024
5693caf
fix tests
OzakIOne Jul 10, 2024
2e1fc03
refactor
OzakIOne Jul 10, 2024
232c4ac
refactor
OzakIOne Jul 10, 2024
bef4e4d
remove unused key
OzakIOne Jul 10, 2024
bb8e554
refactor: apply lint autofix
OzakIOne Jul 10, 2024
e29650d
autolint
OzakIOne Jul 10, 2024
8e51453
refactor: apply lint autofix
OzakIOne Jul 10, 2024
e5c2f38
Merge branch 'main' into ozaki/mediaShareButtons
OzakIOne Jul 11, 2024
72c3923
refactor
OzakIOne Jul 12, 2024
a3c75ed
refactor
OzakIOne Jul 12, 2024
0a739e1
Merge branch 'main' into ozaki/mediaShareButtons
OzakIOne Jul 12, 2024
4d370b9
refactor: apply lint autofix
OzakIOne Jul 12, 2024
1c410e1
refactor
OzakIOne Jul 15, 2024
3823d22
refactor: apply lint autofix
OzakIOne Jul 15, 2024
36ad47e
refactor
OzakIOne Jul 15, 2024
45e7c38
UI test
OzakIOne Jul 17, 2024
0c5a122
fix test
OzakIOne Jul 17, 2024
00fc21d
ui test
OzakIOne Jul 22, 2024
e2d6aab
Merge branch 'main' into ozaki/mediaShareButtons
slorber Jul 25, 2024
9d7ee53
move useBlogPostsPlural to internal
slorber Jul 25, 2024
a092d1d
add useful groupBlogPostsByAuthorKey comment
slorber Jul 25, 2024
6044010
add tests for groupBlogPostsByAuthorKey
slorber Jul 25, 2024
0260a3b
narrow typing for AuthorsMap
slorber Jul 25, 2024
3a86873
rename checkAuthorsMapPermalinkCollisions
slorber Jul 25, 2024
4f48e9e
refactor getDataFileData to readDataFile
slorber Jul 25, 2024
12d72c6
move relevant tests to authorsMap test file
slorber Jul 25, 2024
9553099
remove useless function
slorber Jul 25, 2024
ca2afb3
rename toAuthorItemProp
slorber Jul 25, 2024
7268707
revert generic listByLetters generic util
slorber Jul 25, 2024
493f3d7
revert generic listByLetters generic util
slorber Jul 25, 2024
30d076b
bad import
slorber Jul 26, 2024
e4da374
useless label
slorber Jul 26, 2024
50f209c
rename test file to match impl
slorber Jul 26, 2024
9d47ed1
remove useless lastUpdated in test output
slorber Jul 26, 2024
bd1c3d1
remove useless lastUpdated in test output
slorber Jul 26, 2024
64fa38d
add integration test for localized blog author page permalink
slorber Jul 26, 2024
519d2a9
refactor: apply lint autofix
slorber Jul 26, 2024
7927b5d
commit typo
slorber Jul 26, 2024
3b6845d
Merge remote-tracking branch 'origin/ozaki/mediaShareButtons' into oz…
slorber Jul 26, 2024
ccfc506
refactor: apply lint autofix
slorber Jul 26, 2024
befb552
refactor blog translations - introduce AuthorWithKey type
slorber Jul 26, 2024
7376f6f
docs: add authors page section
OzakIOne Jul 26, 2024
c6b2695
Merge remote-tracking branch 'origin/ozaki/mediaShareButtons' into oz…
slorber Jul 26, 2024
1025362
simplify routes => sync code
slorber Jul 26, 2024
295f7a1
add authorsListPath to global blog metadata bundle
slorber Jul 26, 2024
cbd14e3
rename things for consistency
slorber Jul 26, 2024
8620ef4
rename things for consistency
slorber Jul 26, 2024
de0119f
remove useless typedefs
slorber Jul 26, 2024
9d9a845
refactor blog theme components organization
slorber Jul 26, 2024
7aaa68b
paginateBlogPosts should generate first page even when there's 0 items
slorber Jul 26, 2024
2b26fbd
Dogfood custom author page permalink
slorber Jul 26, 2024
2425144
remove unused css
slorber Jul 26, 2024
ad929c0
rename ThemeClassNames for consistency
slorber Jul 26, 2024
12b3956
move count outside link
slorber Jul 26, 2024
0ebe271
polish display code
slorber Jul 26, 2024
66bb85b
swizzle config
slorber Jul 29, 2024
ea494ca
fix changelog plugin
slorber Jul 29, 2024
3cd4f9f
feat: Add authors page configuration option to the blog plugin
OzakIOne Jul 29, 2024
63f8785
docs: clarify explanation
OzakIOne Jul 29, 2024
a23f8ec
refactor: apply lint autofix
OzakIOne Jul 29, 2024
ab48912
Merge branch 'main' into ozaki/mediaShareButtons
slorber Aug 1, 2024
de556c9
docs, rename authorsPagePath to authorsBasePath
slorber Aug 1, 2024
75dd81f
useful comment on BlopAuthor
slorber Aug 1, 2024
b3196f5
simplify authors pages doc
slorber Aug 1, 2024
25546d4
simplify authors pages doc
slorber Aug 1, 2024
35e704d
simplify authors pages doc
slorber Aug 1, 2024
e19765d
simplify authors pages doc
slorber Aug 1, 2024
c632270
Add missing plugin options
slorber Aug 1, 2024
8b97d27
Add Authors File api ref
slorber Aug 1, 2024
0b8b103
Polish CSS of blog authors pages
slorber Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: author description
  • Loading branch information
OzakIOne committed Jun 18, 2024
commit a6dbf715029fa70a8249ca18c098fe075a55dce7
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,7 @@ describe('blog plugin', () => {
permalink: '/blog/tags/global-tag-permalink (en)',
},
],
pageAuthors: [
{
email: '[email protected]',
name: 'Sébastien Lorber (translated)',
permalink: '/blog/authors/slorber',
title: 'Docusaurus maintainer (translated)',
key: 'slorber',
url: undefined,
},
],
pageAuthors: [],
prevItem: {
permalink: '/blog/date-matter',
title: 'date-matter',
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-blog/src/authors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const AuthorsMapSchema = Joi.object<AuthorsMap>()
email: Joi.string(),
generateAuthorPage: Joi.bool(),
permalink: Joi.string(),
description: Joi.string(),
})
.rename('image_url', 'imageURL')
.or('name', 'imageURL')
Expand Down
15 changes: 4 additions & 11 deletions packages/docusaurus-plugin-content-blog/src/blogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,8 @@ export function getBlogPageAuthors({
isUnlisted: (item: BlogPost) => item.metadata.unlisted,
});
return {
name: author.name,
url: author.url,
title: author.title,
email: author.email,
key: author.key,
...author,
items: authorVisibility.listedItems.map((item: BlogPost) => item.id),
permalink: author.permalink,
pages: author.permalink
? paginateBlogPosts({
blogPosts: authorVisibility.listedItems,
Expand Down Expand Up @@ -376,11 +371,9 @@ async function processBlogSourceFile(
});

const authors = getBlogPostAuthors({authorsMap, frontMatter, baseUrl});
const authorsBaseRoutePath = normalizeUrl([
baseUrl,
routeBasePath,
options.authorsPageBasePath,
]);
const authorsBaseRoutePath = options.authorsPageBasePath
? normalizeUrl([baseUrl, routeBasePath, options.authorsPageBasePath])
: '';

const pageAuthors = normalizeFrontMatterPageAuthors(
authorsBaseRoutePath,
Expand Down
15 changes: 2 additions & 13 deletions packages/docusaurus-plugin-content-blog/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ export function toPageAuthorsProp({
return Object.values(blogPageAuthors)
.filter((author) => !author.unlisted)
OzakIOne marked this conversation as resolved.
Show resolved Hide resolved
.map((author) => ({
name: author.name,
permalink: author.permalink,
...author,
count: author.items.length,
url: author.url,
email: author.email,
title: author.title,
key: author.key,
}));
}

Expand All @@ -71,14 +66,8 @@ export function toPageAuthorProp({
author: BlogPageAuthor;
}): AuthorModule {
return {
name: author.name,
permalink: author.permalink,
...author,
allAuthorsPath: blogAuthorsListPath,
OzakIOne marked this conversation as resolved.
Show resolved Hide resolved
count: author.items.length,
unlisted: author.unlisted,
url: author.url,
email: author.email,
title: author.title,
key: author.key,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,26 @@ import type {Props} from '@theme/BlogAuthorPage/Author';

import styles from './styles.module.css';

export default function Author({permalink, name, count}: Props): JSX.Element {
export default function Author({
permalink,
name,
count,
imageURL,
}: Props): JSX.Element {
return (
<Link
href={permalink}
className={clsx(
styles.author,
count ? styles.authorWithCount : styles.authorRegular,
)}>
{imageURL && (
<img
className={clsx('avatar__photo', styles.authorImage)}
src={imageURL}
alt={name}
/>
)}
{name}
{count && <span>{count}</span>}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@
padding: 0.1rem 0.4rem;
margin-left: 0.3rem;
}

.authorImage {
width: 1.5rem;
height: 1.5rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,12 @@ function BlogAuthorsPostsPageContent({
<header className="margin-bottom--xl">
<Heading as="h1">{title}</Heading>
<ul>
{author.title && <li>{author.title}</li>}
{author.email && (
<li>
<Link href={`mailto:${author.email}`}>{author.email}</Link>
</li>
)}
{author.url && (
<li>
<Link href={author.url}>Personal website</Link>
</li>
)}
{author.description && <li>{author.description}</li>}
</ul>
<Link href={author.allAuthorsPath}>
<Translate
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-theme-common/src/utils/authorsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import type {AuthorsListItem} from '@docusaurus/utils';

export const translateAuthorsPageTitle = (): string =>
translate({
id: 'theme.tags.tagsPageTitle',
message: 'Tags',
description: 'The title of the tag list page',
id: 'theme.authors.authorsPageTitle',
message: 'Authors',
description: 'The title of the author list page',
});

export type AuthorLetterEntry = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"theme.tags.tagsPageTitle": "Tags",
"theme.tags.tagsPageTitle___DESCRIPTION": "The title of the tag list page",
"theme.authors.authorsPageLink": "View All Authors",
"theme.authors.authorsPageTitle": "Authors",
"theme.blog.authorTitle": "{nPosts} contributed by \"{authorName}\"",
"theme.unlistedContent.message": "This page is unlisted. Search engines will not index it, and only users having a direct link can access it.",
"theme.unlistedContent.message___DESCRIPTION": "The unlisted content banner message",
Expand Down
10 changes: 10 additions & 0 deletions packages/docusaurus-utils/src/authors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export type Author = {
// TODO add description
generateAuthorPage?: boolean;
permalink?: string;
description?: string;

/**
* Unknown keys are allowed, so that we can pass custom fields to authors,
* e.g., `twitter`.
Expand All @@ -48,7 +50,9 @@ export type PageAuthor = {
/** Permalink to this author's page, without the `/authors/` base path. */
permalink: string;

imageURL: string | undefined;
key: string | undefined;
description: string | undefined;
title: string | undefined;
email: string | undefined;
url: string | undefined;
Expand Down Expand Up @@ -93,6 +97,8 @@ function normalizeFrontMatterAuthor(
title: undefined,
email: undefined,
key: authorString,
description: undefined,
imageURL: undefined,
};
}

Expand All @@ -111,6 +117,8 @@ function normalizeFrontMatterAuthor(
title: author.title,
email: author.email,
key: author.key,
description: author.description,
imageURL: author.imageURL,
};
}

Expand All @@ -136,12 +144,14 @@ export function normalizeFrontMatterPageAuthors(
name: author.name || (author.key as string),
url: author.url,
title: author.title,
description: author.description,
email: author.email,
// TODO investigate if the user put a key in file what will happen
key: author.key as string,
permalink: author.permalink
? author.permalink
: _.kebabCase(author.key as string),
imageURL: author.imageURL,
}));

const authors = pageAuthors.map((author) =>
Expand Down
3 changes: 3 additions & 0 deletions website/blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ slorber:
github: slorber
email: [email protected]
generateAuthorPage: true
description: >
A freelance React and React-Native developer near Paris and Docusaurus maintainer. Also runs ThisWeekInReact.com, a newsletter to stay updated with the React ecosystem.


yangshun:
name: Yangshun Tay
Expand Down
Loading