-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
feat(blog): add LastUpdateAuthor & LastUpdateTime #9912
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: +130 B (0%) Total Size: 992 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start 👍
We still need to:
- refactor, share code
- add tests
- implement a uniform footer design
- support structured data (Blog posts should be able to display last update date #8657 (comment))
packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts
Outdated
Show resolved
Hide resolved
packages/docusaurus-theme-classic/src/theme/BlogPostItem/Header/Info/index.tsx
Outdated
Show resolved
Hide resolved
@@ -28,6 +28,9 @@ const BlogPostFrontMatterAuthorSchema = Joi.object({ | |||
const FrontMatterAuthorErrorMessage = | |||
'{{#label}} does not look like a valid blog post author. Please use an author key or an author object (with a key and/or name).'; | |||
|
|||
const FrontMatterLastUpdateErrorMessage = | |||
'{{#label}} does not look like a valid front matter FileChange object. Please use a FileChange object (with an author and/or date).'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is the historical message, but honestly, I doubt users will understand it 😅
Not sure mentioning FileChange
is super useful, we just need users to know they should provide a date or an author attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type FrontMatterLastUpdate = {
author?: string;
date?: Date | string;
};
As author seems to be only a string I wonder removing author key or an author object
(with a key and/or name)
So it would be something like this :
const FrontMatterAuthorErrorMessage =
'{{#label}} does not look like a valid blog post author. Please use a string (maybe insert example?).';
const FrontMatterLastUpdateErrorMessage =
'{{#label}} does not look like a valid front matter date. Please use a string or date (maybe insert example?).';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As author seems to be only a string I wonder removing author key or an author object (with a key and/or name)
const FrontMatterAuthorErrorMessage = '{{#label}} does not look like a valid blog post author. Please use a string (maybe insert example?).';
I think you mislead blog post authors and last update author: those are different concepts
https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog#authors
Blog post authors (not just a single one) can be objects, strings (keys)
export type BlogPostFrontMatterAuthor = Author & {
/**
* Will be normalized into the `imageURL` prop.
*/
image_url?: string;
/**
* References an existing author in the authors map.
*/
key?: string;
};
export type BlogPostFrontMatterAuthors =
| string
| BlogPostFrontMatterAuthor
| (string | BlogPostFrontMatterAuthor)[];
Only the last update author is just a string, so your new validation error message proposal is not good.
const FrontMatterLastUpdateErrorMessage = '{{#label}} does not look like a valid front matter date. Please use a string or > date (maybe insert example?).';
Not good either, the last update is not a "date", but an object that can have either (or both) a date attribute (Date | string
) and an author (string
) attribute.
The message doesn't have to explain the types IMHO, just mention that the overall object shape is wrong and valid attribute names. Yaml will auto-convert strings to Dates depending on the format so mentioning it accept both Date + string is kind of overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good progress
Pre-flight checklist
Motivation
Provide two options in blog
showLastUpdateAuthor
andshowLastUpdateTime
which like in docs, show the time the blog was last updated and also who updated itTest Plan
docusaurus-utils-validation/validationSchemas.test.ts
=>frontMatterLastUpdateSchema schema
docusaurus-plugin-content-blog/index.test.ts
=>last update
docusaurus-utils/lastUpdateUtils.test.ts
=>readLastUpdateData
Test links
Blog preview
Blog Content Documentation
Related issues/PRs
Fix #8657