- Do you want to request a feature or report a bug?
feature
- What is the current behavior?
Author name (person who wrote the blog post) is not displayed in the blog
- If the current behavior is a bug, please provide the steps to reproduce.
Looks like this feature is not added
- What is the expected behavior?
Most blog sites have the author name but missing here
According to me, it is not a NetlifyCMS issue. There are many possible reasons for this to occur:-
You might not have created a collection for Author Name. In the absence of it, there will be no author name added in the .md file leading to no author name displaying.
You might not have configured your site generator's theme to display the author name.
The recommended solution for your problem is to create a widget for author name in case your site has multiple authors. Or create a collection with a default name of author in case there is only one author.
I can create a collection for Author name and pass it but the whole idea is to use the name of the Author who logged in and posted the blog using Netlify Identity. For example, if a user logs on to mysite.netlify.com/admin and creates a new blog post, his name from the Netlify account should be displayed in the blog post.
Thanks
@StarAzure My answer to your other question is valid here as well -- Netlify CMS doesn't actually output the site at all. You will need to modify the site generator templates in your repository to change how the site actually looks.
What you are saying about 'how the site looks' makes sense BUT, how can I get the name of the Netlify account user who created the blog post from mysite.netlify.com/admin ?
Good question, thank you for your patience here! There is always the option of adding another field to the collection and having the author type their name in. If I understand you correctly, though, you'd rather have it just pull the name from the Identity account. That should be possible, but there are a few questions we would need to address, so maybe you can help us here:
What should we do in the case where there is no name set up on the Identity account (for example, they were invited via email)? Maybe in that case we should just have an empty field for the user to enter their name?
Assuming the name does exist in Identity, should we just prefill the field, and allow the user to edit it if they want to? Or should we just assume it is correct and not allow the user to modify or review the name on the post?
I am surprised nobody asked this before because users is a major part of CMS. People always click on users to find out their other posts. I come from Joomla/Wordpress usage for years so I will use it as example.
1) When a user is created by email invitation, they still have to complete their initial account set up by entering a username, name and password. Use should be able to edit/update their profile anytime.
2) The author name should always come from identity. For example if I post on facebook or google reviews, my name from my account is used and that can only be changed in the user account.
A better example is when you post here on Github, where does "tech4him1 commented" come from ?
User should be able to edit/update their profile anytime.
@bcomnes @erquhart Is it currently possible for users to edit/update their profile, or does that still need added?
The author name should always come from identity.
I agree.
@erquhart What do you think the best way to implement this would be? Maybe we could use some sort of "templating" as the default for a hidden widget?
Is it currently possible for users to edit/update their profile, or does that still need added?
Confused by the context here. Do you mean in the Netlify Identity service? You can update user properties using https://github.com/netlify/gotrue-js#update-a-user, but this sort of sounds like an integration detail between the cms and whatever site generator you are using.
@tech4him1 agreed, we've dug into default value templating in other issues, although I can't seem to find any of them at the moment. Making user info available for that makes sense.
Is this going anywhere? I'd also very much like this feature, even as just a pre-filled value for a field.
My current author field is just a simple field:
- {
label: 'Author',
name: 'author',
widget: 'string',
default: 'Daniel Dunderfelt',
}
Which does work, and I'm planning to replace it with a relation field and an author collection, but what if we could do this:
- {
label: 'Author',
name: 'author',
widget: 'string',
default: '{{user.name}}',
}
Which would result in the name of the currently logged-in user being populated in the field. The field would be left empty if there is no name to be found. Collections could also be assigned as "author" collections and {{user.id}} could auto-select the current author from the collection if the author field is a relation.
We have consensus that it's a desired feature, just need someone to implement and open a PR.
wow surprised to find this missing, regardless on how we handle our site author presentation we should be able to get at least an id from netlify that we can use to retrieve the user from a collection and pull the name from it, or what ever way we use to define an author.
Just a matter of someone doing something about it 馃檪. Otherwise I expect I or one of the other maintainers will eventually get to it. Lots of priorities to consider.
Sent with GitHawk
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Is this going anywhere? I'd also very much like this feature, even as just a pre-filled value for a field.
My current author field is just a simple field:- { label: 'Author', name: 'author', widget: 'string', default: 'Daniel Dunderfelt', }Which does work, and I'm planning to replace it with a relation field and an author collection, but what if we could do this:
- { label: 'Author', name: 'author', widget: 'string', default: '{{user.name}}', }Which would result in the name of the currently logged-in user being populated in the field. The field would be left empty if there is no name to be found. Collections could also be assigned as "author" collections and
{{user.id}}could auto-select the current author from the collection if the author field is a relation.
i tried with relation widget. it does not fetch authors from markdown file. looks like it is the only way
I'm just gonna leave a +1 on here. Would be great to fetch the logged in author's handle from Netlify Identity. A dropdown widget pulling from the authors collection is pretty clunky.
Yes please, it's much needed.
Something like this would be very useful. It falls in line with #3683 and #3684.
If an Authors collection is configured as @Mejanhaque mentioned, each Author should correspond directly with a Netlify account that has access to contribute to the site possibly via a user id. At that point if the entry has an authors select widget and you are creating a new entry, the current user should be pre-selected based on the Netlify Identity user id.
Is there any update of this feature. I am trying Netlify-cms is seem great. But I am stuck in this issue.
I think author should not manually enter author name or id ownself. It should added on post creation time by default.
Hi @rahadkc, I think you should be able to auto populate fields using the preSave event:
https://www.netlifycms.org/docs/beta-features/#registering-to-cms-events
e.g.
CMS.registerEventListener({
name: 'preSave',
handler: ({ entry }) => {
const author = JSON.parse(localStorage.getItem('netlify-cms-user')).name;
return entry.get('data').set('author', author);
},
});
HI @erezrokah
Thanks a lot for your answer. I didn't know I can get the author info from localstorage.
There are 'netlify-cms-user' and 'gotrue.use' more details info key stored.
It helps thanks.
Most helpful comment
What you are saying about 'how the site looks' makes sense BUT, how can I get the name of the Netlify account user who created the blog post from mysite.netlify.com/admin ?