mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 15:07:17 +02:00
feat: allow blog authors email (#6783)
This commit is contained in:
parent
7ec44bb32c
commit
6cbc58943e
14 changed files with 53 additions and 15 deletions
|
@ -222,6 +222,7 @@ module.exports = {
|
||||||
],
|
],
|
||||||
'react/jsx-filename-extension': OFF,
|
'react/jsx-filename-extension': OFF,
|
||||||
'react/jsx-key': [ERROR, {checkFragmentShorthand: true}],
|
'react/jsx-key': [ERROR, {checkFragmentShorthand: true}],
|
||||||
|
'react/jsx-no-useless-fragment': [ERROR, {allowExpressions: true}],
|
||||||
'react/jsx-props-no-spreading': OFF,
|
'react/jsx-props-no-spreading': OFF,
|
||||||
'react/no-array-index-key': OFF, // We build a static site, and nearly all components don't change.
|
'react/no-array-index-key': OFF, // We build a static site, and nearly all components don't change.
|
||||||
'react/no-unstable-nested-components': [WARNING, {allowAsProps: true}],
|
'react/no-unstable-nested-components': [WARNING, {allowAsProps: true}],
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
"title": "Docusaurus maintainer",
|
"title": "Docusaurus maintainer",
|
||||||
"url": "https://sebastienlorber.com",
|
"url": "https://sebastienlorber.com",
|
||||||
"image_url": "https://github.com/slorber.png",
|
"image_url": "https://github.com/slorber.png",
|
||||||
"twitter": "sebastienlorber"
|
"twitter": "sebastienlorber",
|
||||||
|
"email": "lorber.sebastien@gmail.com"
|
||||||
},
|
},
|
||||||
"yangshun": {
|
"yangshun": {
|
||||||
"name": "Yangshun Tay",
|
"name": "Yangshun Tay",
|
||||||
|
|
|
@ -12,6 +12,7 @@ slorber:
|
||||||
url: https://sebastienlorber.com
|
url: https://sebastienlorber.com
|
||||||
image_url: https://github.com/slorber.png
|
image_url: https://github.com/slorber.png
|
||||||
twitter: sebastienlorber
|
twitter: sebastienlorber
|
||||||
|
email: lorber.sebastien@gmail.com
|
||||||
|
|
||||||
yangshun:
|
yangshun:
|
||||||
name: Yangshun Tay
|
name: Yangshun Tay
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
slorber:
|
slorber:
|
||||||
name: Sébastien Lorber
|
name: Sébastien Lorber
|
||||||
title: Docusaurus maintainer
|
title: Docusaurus maintainer
|
||||||
|
email: lorber.sebastien@gmail.com
|
||||||
|
url: https://sebastienlorber.com
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
slorber:
|
slorber:
|
||||||
name: Sébastien Lorber (translated)
|
name: Sébastien Lorber (translated)
|
||||||
title: Docusaurus maintainer (translated)
|
title: Docusaurus maintainer (translated)
|
||||||
|
email: lorber.sebastien@gmail.com
|
||||||
|
|
|
@ -77,6 +77,7 @@ Array [
|
||||||
</author>
|
</author>
|
||||||
<author>
|
<author>
|
||||||
<name>Sébastien Lorber (translated)</name>
|
<name>Sébastien Lorber (translated)</name>
|
||||||
|
<email>lorber.sebastien@gmail.com</email>
|
||||||
</author>
|
</author>
|
||||||
</entry>
|
</entry>
|
||||||
</feed>",
|
</feed>",
|
||||||
|
@ -238,6 +239,7 @@ Array [
|
||||||
<pubDate>Fri, 14 Dec 2018 00:00:00 GMT</pubDate>
|
<pubDate>Fri, 14 Dec 2018 00:00:00 GMT</pubDate>
|
||||||
<description><![CDATA[Happy birthday! (translated)]]></description>
|
<description><![CDATA[Happy birthday! (translated)]]></description>
|
||||||
<content:encoded><![CDATA[<p>Happy birthday!</p>]]></content:encoded>
|
<content:encoded><![CDATA[<p>Happy birthday!</p>]]></content:encoded>
|
||||||
|
<author>lorber.sebastien@gmail.com (Sébastien Lorber (translated))</author>
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>",
|
</rss>",
|
||||||
|
|
|
@ -177,6 +177,7 @@ describe('loadBlog', () => {
|
||||||
name: 'Yangshun Tay (translated)',
|
name: 'Yangshun Tay (translated)',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
email: 'lorber.sebastien@gmail.com',
|
||||||
key: 'slorber',
|
key: 'slorber',
|
||||||
name: 'Sébastien Lorber (translated)',
|
name: 'Sébastien Lorber (translated)',
|
||||||
title: 'Docusaurus maintainer (translated)',
|
title: 'Docusaurus maintainer (translated)',
|
||||||
|
|
|
@ -24,6 +24,7 @@ const AuthorsMapSchema = Joi.object<AuthorsMap>().pattern(
|
||||||
url: URISchema,
|
url: URISchema,
|
||||||
imageURL: URISchema,
|
imageURL: URISchema,
|
||||||
title: Joi.string(),
|
title: Joi.string(),
|
||||||
|
email: Joi.string(),
|
||||||
})
|
})
|
||||||
.rename('image_url', 'imageURL')
|
.rename('image_url', 'imageURL')
|
||||||
.or('name', 'imageURL')
|
.or('name', 'imageURL')
|
||||||
|
|
|
@ -57,9 +57,7 @@ async function generateBlogFeed({
|
||||||
});
|
});
|
||||||
|
|
||||||
function toFeedAuthor(author: Author): FeedAuthor {
|
function toFeedAuthor(author: Author): FeedAuthor {
|
||||||
// TODO ask author emails?
|
return {name: author.name, link: author.url, email: author.email};
|
||||||
// RSS feed requires email to render authors
|
|
||||||
return {name: author.name, link: author.url};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await mapAsyncSequential(blogPosts, async (post) => {
|
await mapAsyncSequential(blogPosts, async (post) => {
|
||||||
|
|
|
@ -21,6 +21,7 @@ declare module '@docusaurus/plugin-content-blog' {
|
||||||
imageURL?: string;
|
imageURL?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
email?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BlogPostFrontMatter = {
|
export type BlogPostFrontMatter = {
|
||||||
|
|
|
@ -6,19 +6,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Link from '@docusaurus/Link';
|
import Link, {type Props as LinkProps} from '@docusaurus/Link';
|
||||||
import type {Props} from '@theme/BlogPostAuthor';
|
import type {Props} from '@theme/BlogPostAuthor';
|
||||||
|
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
function MaybeLink(props: LinkProps): JSX.Element {
|
||||||
|
if (props.href) {
|
||||||
|
return <Link {...props} />;
|
||||||
|
}
|
||||||
|
return <>{props.children}</>;
|
||||||
|
}
|
||||||
|
|
||||||
export default function BlogPostAuthor({author}: Props): JSX.Element {
|
export default function BlogPostAuthor({author}: Props): JSX.Element {
|
||||||
const {name, title, url, imageURL} = author;
|
const {name, title, url, imageURL, email} = author;
|
||||||
|
const link = url || (email && `mailto:${email}`) || undefined;
|
||||||
return (
|
return (
|
||||||
<div className="avatar margin-bottom--sm">
|
<div className="avatar margin-bottom--sm">
|
||||||
{imageURL && (
|
{imageURL && (
|
||||||
<Link className="avatar__photo-link avatar__photo" href={url}>
|
<span className="avatar__photo-link avatar__photo">
|
||||||
<img className={styles.image} src={imageURL} alt={name} />
|
<MaybeLink href={link}>
|
||||||
</Link>
|
<img className={styles.image} src={imageURL} alt={name} />
|
||||||
|
</MaybeLink>
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{name && (
|
{name && (
|
||||||
|
@ -28,9 +38,9 @@ export default function BlogPostAuthor({author}: Props): JSX.Element {
|
||||||
itemScope
|
itemScope
|
||||||
itemType="https://schema.org/Person">
|
itemType="https://schema.org/Person">
|
||||||
<div className="avatar__name">
|
<div className="avatar__name">
|
||||||
<Link href={url} itemProp="url">
|
<MaybeLink href={link} itemProp="url">
|
||||||
<span itemProp="name">{name}</span>
|
<span itemProp="name">{name}</span>
|
||||||
</Link>
|
</MaybeLink>
|
||||||
</div>
|
</div>
|
||||||
{title && (
|
{title && (
|
||||||
<small className="avatar__subtitle" itemProp="description">
|
<small className="avatar__subtitle" itemProp="description">
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
---
|
---
|
||||||
tags: [paginated-tag]
|
tags: [paginated-tag]
|
||||||
|
authors:
|
||||||
|
- name: Josh-Cena1
|
||||||
|
- name: Josh-Cena2
|
||||||
|
image_url: https://github.com/Josh-Cena.png
|
||||||
|
- name: Josh-Cena3
|
||||||
|
url: https://github.com/Josh-Cena
|
||||||
|
- name: Josh-Cena4
|
||||||
|
email: sidechen2003@gmail.com
|
||||||
---
|
---
|
||||||
|
|
||||||
# Post with duplicate title
|
# Post with duplicate title
|
||||||
|
|
|
@ -3,6 +3,7 @@ JMarcey:
|
||||||
title: Technical Lead & Developer Advocate at Facebook
|
title: Technical Lead & Developer Advocate at Facebook
|
||||||
url: http://twitter.com/JoelMarcey
|
url: http://twitter.com/JoelMarcey
|
||||||
image_url: https://github.com/JoelMarcey.png
|
image_url: https://github.com/JoelMarcey.png
|
||||||
|
email: jimarcey@gmail.com
|
||||||
twitter: JoelMarcey
|
twitter: JoelMarcey
|
||||||
|
|
||||||
slorber:
|
slorber:
|
||||||
|
@ -11,6 +12,7 @@ slorber:
|
||||||
url: https://sebastienlorber.com
|
url: https://sebastienlorber.com
|
||||||
image_url: https://github.com/slorber.png
|
image_url: https://github.com/slorber.png
|
||||||
twitter: sebastienlorber
|
twitter: sebastienlorber
|
||||||
|
email: lorber.sebastien@gmail.com
|
||||||
|
|
||||||
yangshun:
|
yangshun:
|
||||||
name: Yangshun Tay
|
name: Yangshun Tay
|
||||||
|
@ -18,15 +20,18 @@ yangshun:
|
||||||
url: https://github.com/yangshun
|
url: https://github.com/yangshun
|
||||||
image_url: https://github.com/yangshun.png
|
image_url: https://github.com/yangshun.png
|
||||||
twitter: yangshunz
|
twitter: yangshunz
|
||||||
|
email: tay.yang.shun@gmail.com
|
||||||
|
|
||||||
lex111:
|
lex111:
|
||||||
name: Alexey Pyltsyn
|
name: Alexey Pyltsyn
|
||||||
title: Open-source enthusiast
|
title: Open-source enthusiast
|
||||||
url: https://github.com/lex111
|
url: https://github.com/lex111
|
||||||
image_url: https://github.com/lex111.png
|
image_url: https://github.com/lex111.png
|
||||||
|
email: lex@php.net
|
||||||
|
|
||||||
Josh-Cena:
|
Josh-Cena:
|
||||||
name: Joshua Chen
|
name: Joshua Chen
|
||||||
title: Working hard on Docusaurus
|
title: Working hard on Docusaurus
|
||||||
url: https://joshcena.com/
|
url: https://joshcena.com/
|
||||||
image_url: https://github.com/josh-cena.png
|
image_url: https://github.com/josh-cena.png
|
||||||
|
email: sidachen2003@gmail.com
|
||||||
|
|
|
@ -185,7 +185,7 @@ date: 2021-09-13T18:00
|
||||||
|
|
||||||
## Blog post authors {#blog-post-authors}
|
## Blog post authors {#blog-post-authors}
|
||||||
|
|
||||||
Use the `authors` front matter field to declare blog post authors.
|
Use the `authors` front matter field to declare blog post authors. An author should have at least a `name` or an `image_url`. Docusaurus uses information like `url`, `email`, and `title`, but any other information is allowed.
|
||||||
|
|
||||||
### Inline authors {#inline-authors}
|
### Inline authors {#inline-authors}
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ authors:
|
||||||
title: Co-creator of Docusaurus 1
|
title: Co-creator of Docusaurus 1
|
||||||
url: https://github.com/JoelMarcey
|
url: https://github.com/JoelMarcey
|
||||||
image_url: https://github.com/JoelMarcey.png
|
image_url: https://github.com/JoelMarcey.png
|
||||||
|
email: jimarcey@gmail.com
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -215,6 +216,7 @@ authors:
|
||||||
title: Co-creator of Docusaurus 1
|
title: Co-creator of Docusaurus 1
|
||||||
url: https://github.com/JoelMarcey
|
url: https://github.com/JoelMarcey
|
||||||
image_url: https://github.com/JoelMarcey.png
|
image_url: https://github.com/JoelMarcey.png
|
||||||
|
email: jimarcey@gmail.com
|
||||||
- name: Sébastien Lorber
|
- name: Sébastien Lorber
|
||||||
title: Docusaurus maintainer
|
title: Docusaurus maintainer
|
||||||
url: https://sebastienlorber.com
|
url: https://sebastienlorber.com
|
||||||
|
@ -259,6 +261,7 @@ jmarcey:
|
||||||
title: Co-creator of Docusaurus 1
|
title: Co-creator of Docusaurus 1
|
||||||
url: https://github.com/JoelMarcey
|
url: https://github.com/JoelMarcey
|
||||||
image_url: https://github.com/JoelMarcey.png
|
image_url: https://github.com/JoelMarcey.png
|
||||||
|
email: jimarcey@gmail.com
|
||||||
|
|
||||||
slorber:
|
slorber:
|
||||||
name: Sébastien Lorber
|
name: Sébastien Lorber
|
||||||
|
@ -353,6 +356,12 @@ website/i18n/[locale]/docusaurus-plugin-content-blog/authors.yml
|
||||||
|
|
||||||
An author, either declared through front matter or through the authors map, needs to have a name or an avatar, or both. If all authors of a post don't have names, Docusaurus will display their avatars compactly. See [this test post](/tests/blog/2022/01/20/image-only-authors) for the effect.
|
An author, either declared through front matter or through the authors map, needs to have a name or an avatar, or both. If all authors of a post don't have names, Docusaurus will display their avatars compactly. See [this test post](/tests/blog/2022/01/20/image-only-authors) for the effect.
|
||||||
|
|
||||||
|
:::caution Feed generation
|
||||||
|
|
||||||
|
[RSS feeds](#feed) require the author's email to be set for the author to appear in the feed.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Reading time {#reading-time}
|
## Reading time {#reading-time}
|
||||||
|
|
||||||
Docusaurus generates a reading time estimation for each blog post based on word count. We provide an option to customize this.
|
Docusaurus generates a reading time estimation for each blog post based on word count. We provide an option to customize this.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue