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
|
slorber
left a comment
There was a problem hiding this comment.
Looks like a good start 👍
We still need to:
- refactor, share code
- add tests
- implement a uniform footer design
- support structured data (#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
| '{{#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.
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.
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.
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.
Pre-flight checklist
Motivation
Provide two options in blog
showLastUpdateAuthorandshowLastUpdateTimewhich like in docs, show the time the blog was last updated and also who updated itTest Plan
docusaurus-utils-validation/validationSchemas.test.ts=>frontMatterLastUpdateSchema schemadocusaurus-plugin-content-blog/index.test.ts=>last updatedocusaurus-utils/lastUpdateUtils.test.ts=>readLastUpdateDataTest links
Blog preview
Blog Content Documentation
Related issues/PRs
Fix #8657