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

Multiple Authors? #126

Open
kthecoder opened this issue Mar 23, 2021 · 4 comments
Open

Multiple Authors? #126

kthecoder opened this issue Mar 23, 2021 · 4 comments
Assignees

Comments

@kthecoder
Copy link

Is it possible to have a different authors for each page. So that posts can be set to different authors defined in the pages Front-Matter. And have a default author in case you want to delete an author from the data set? If its not implemented, how hard would it be to add a connection to a JSON, XML, or Database to reference the correct author?

@bennyxguo
Copy link
Owner

@kthecoder
I would say this is a good idea. If multi-author is added, the author info would probably be setup in the config file, then you can set the post author on the post Front-Matter. If the author's "username" matches, it will be displayed as the post author, if not will fallback to the blog's main author.

I would say this is definitely achievable!

I am working on a complete new version of this theme. This feature I would first add it to the new theme call "ObsidiaNext". I will get back to this comment once the new theme releases. Which would me very soon!

@kcn3388
Copy link
Contributor

kcn3388 commented Mar 25, 2021

@kthecoder multiple author is possible. you can modify the code in /layout/_partial/post/article.ejs to allow another author and his avatar.
Here is the code.

line 121 (possible)
<p><%- page.author || config.author %></p>
<img src="<%- page.avatar || theme.avatar %>" height=300 width=300></img>

Of course, you need to add the variable to the front-matter of your markdown file. For example,

---
title: xxx
date: 2021-03-23 14:40:48
author: KMurasaki
avatar: /img/avatar/KMurasaki.jpg
slogan: "xxx"

You can see other modification in my commit.
commit

@bennyxguo
Copy link
Owner

@kthecoder multiple author is possible. you can modify the code in /layout/_partial/post/article.ejs to allow another author and his avatar.

Nice! Feel free to submit a PR if you have added or fix anything of this theme. Happy to see your contributions!~

@kcn3388
Copy link
Contributor

kcn3388 commented Mar 25, 2021

@TriDiamond Well, since I do other personal modify which may not suit for this project, I think it's better that I post the code here and you commit. The key code of modified article.ejs with comment is here:

                <div class="subbox">
<! -- here is the code for another author, you need to declare the link of the custom avatar in your front-matter -->
                    <img src="<%- page.avatar || theme.avatar %>" height=300 width=300></img>
<! -- here is the another author's name, also need to declare in front-matter -->
                    <p><%- page.author || config.author %></p>
<! -- custom slogan, same as above -->
                    <span><%- page.slogan || theme.descriptionOne %></span>
                    <dl>
<! -- here is used to show custom social media. IMPORTANT: YOU MUST DECLARE "3RDPARTY" AND "SOCIALS.PAGE" IN THE RULE WHICH I WILL MENTION IN THE FRONT-MATTER PART. -->
<! -- since a new variable is "false" at default, blog's owner's article have no need to add "3rdparty" in your article -->
                        <% if (page.3rdparty == false){%>
                        <dd><a href="<%- theme.socials.github %>" target="_blank"><span
                                    class=" iconfont icon-github"></span></a></dd>
                        <dd><a href="<%- theme.socials.twitter %>" target="_blank"><span
                                    class=" iconfont icon-twitter"></span></a></dd>
                        <dd><a href="<%- theme.socials.bilibili %>" target="_blank"><span
                                    class=" iconfont icon-bilibili"></span></a></dd>
                        <% } %>
<! -- since other author's social media may not the same as owner's, I only add one personal page for other author. you can modify it as your wish -->
                        <% if (page.3rdparty == true){%>
                        <dd></dd>
                        <dd><a href="<%- page.socials.page %>" target="_blank"><span
                                    class=" iconfont icon-page"></span></a></dd>
                        <dd></dd>
                        <% } %>
                    </dl>
                </div>

template of the front-matter:

---
title: Title 1
date: 2021-03-23 14:40:48
author: Author1
avatar: https://custom.avatar
slogan: "test"
<! -- IMPROTANT: WHEN "3RDPARTY" IS TRUE, YOU MUST ADD SOCIALS LIKE THE FOLLOWING WAY -->
3rdparty: true
socials:
    page: https://personal.link
categories: 
    - c1
    - c2
tags:
    - t1
    - t2
cover:
    - https://custom.cover
preview: 136
---

If any bug you can @me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants