HyunSeob / hexo-theme-overdose

⚠ Caution: you could be overdosed with this theme.
MIT License
135 stars 30 forks source link

Add support for multiple authors #56

Open ApplePie420 opened 4 years ago

ApplePie420 commented 4 years ago

We have 2 writers on our blog, and all posts appears to be made by me. Is there any way or possibility to add support for multiple authors? For example, in .md header: author: author1

yayitazale commented 3 years ago

+1

yayitazale commented 3 years ago

We have 2 writers on our blog, and all posts appears to be made by me. Is there any way or possibility to add support for multiple authors? For example, in .md header: author: author1

I achieved the multi-autor doing the following:

Go to the theme's config file and create two new author profile entrys. You can add each authors info on each profile:

profile1: author: Author 1 Name image: /images/avatar1.jpg link: /about description: social: github: facebook: linkedin: instagram: twitter: rss: /atom.xml

profile2: author: Author 2 Name image: /images/avatar2.jpg link: /about description: social: github: facebook: linkedin: instagram: twitter: rss: /atom.xml

Then go to the \themes\overdose\layout\includes\article.pug

Delete this:

And add this:

if page.author && page.author === 'profile1' .articleauthor( itemscope itemprop="author" itemtype="https://schema.org/Person") img.articleauthorimage( src=theme.profile1.image alt=theme.profile1.author) a.articleauthorlink( href=theme.profile.link title=About ${theme.profile1.author} rel="author" )= theme.profile1.author p.articleauthordesc= theme.profile1.description .articleauthorsocials each url, label in theme.profile1.social if url a.articleauthorsocialsitem( href=url title=label target="_blank") i(class=fa fa-${label}) meta(itemprop="name" content=theme.profile1.author) else if page.author && page.author === 'profile2' .articleauthor( itemscope itemprop="author" itemtype="https://schema.org/Person") img.articleauthorimage( src=theme.profile2.image alt=theme.profile2.author) a.articleauthor__link( href=theme.profile_2.link title=About ${theme.profile2.author} rel="author" )= theme.profile2.author p.articleauthordesc= theme.profile2.description .articleauthorsocials each url, label in theme.profile2.social if url a.articleauthorsocials__item( href=url title=label target="_blank") i(class=fa fa-${label}) meta(itemprop="name" content=theme.profile2.author)

Now you only need to add the following entry on each post or page where you want to add a writters profile:

author: profile1 or author: profile2

If you don't add any author it will be empty.

You can also add more authors with the same logic.

If you wanna see it working, my blog is under this configuration now (with two authors): https://firstcommit.dev/