Skip to content

Conversation

@simonprickett
Copy link
Contributor

@simonprickett simonprickett commented Oct 20, 2021

This PR implements the first step for for adding authors by allowing author bylines to be configured per page. Closes #103

You add an authors array in your front matter like so:

---
id: index-hacktoberfest
title: Hacktoberfest 2021 at Redis
sidebar_label: Hacktoberfest 2021
slug: /hacktoberfest/
authors: [suze,simon]
---

Then you add details of each author to docusaurus.config.js each being an object like this:

  ...
  customFields: {
    authors: {
      simon: {
        name: 'Simon Prickett',
        link: 'https://twitter.com/simon_prickett',
        title: 'Manager, Developer Advocacy',
        image: 'profile_pic_simon_prickett.jpg'
      },
      suze: {
        name: 'Suze Shardlow',
        link: 'https://twitter.com/SuzeShardlow',
        title: 'Developer Community Manager'
      }
    }
  },
  ...

If no image is present for an author, a default fallback silhouette image will be used. link can be any link you want for now... long term the idea is we'd link to an author page and have a bio and socials about each author there.

I then overrode the DocItem component from the theme, and added extra JSX to render these values in a really basic way to prove it works... we can style these more in a future PR and also create a page per author with their bio and articles they have written.

Here's an example of what it looks like. The Hacktoberfest page has authors set on it as an example. If none are set, the component doesn't render anything and the page won't have the author information.

I've also updated the README to cover how to add an author.

Screen Shot 2021-10-27 at 9 22 39 PM

@simonprickett simonprickett self-assigned this Oct 20, 2021
@simonprickett simonprickett linked an issue Oct 20, 2021 that may be closed by this pull request
@simonprickett simonprickett added the enhancement New feature or request label Oct 27, 2021
@simonprickett simonprickett marked this pull request as ready for review October 27, 2021 20:54
Copy link
Contributor

@ajeetraina ajeetraina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonprickett simonprickett merged commit 7a1257c into master Oct 28, 2021
@simonprickett simonprickett deleted the add-authors branch October 28, 2021 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add author byline, bio and pic to articles

3 participants