Skip to content

feat(content-docs): last_update front matter#7461

Merged
slorber merged 17 commits intofacebook:mainfrom
dpang314:main
Jun 1, 2022
Merged

feat(content-docs): last_update front matter#7461
slorber merged 17 commits intofacebook:mainfrom
dpang314:main

Conversation

@dpang314
Copy link
Copy Markdown
Contributor

@dpang314 dpang314 commented May 22, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This feature allows overriding Git history through front matter. It addresses part of #5691. It uses the API design mentioned here to be reused for created metadata and potentially a history.

Test Plan

Added unit tests for front matter configurations, including:

  • last_update front matter undefined
  • Author undefined but date valid
  • Author valid but date undefined
  • Invalid date strings
  • Both valid with varying date string formats

Created doc unit tests

  • Front matter overrides Git history
  • Front matter with only author uses Git history for date
  • Front matter with only date uses Git history for author
  • Front matter is not shown when config disables it

Dogfooding

  • Created new page with last update set with front matter

Test links

Deploy preview: https://deploy-preview-7461--docusaurus-2.netlify.app/
Dogfooding page: https://deploy-preview-7461--docusaurus-2.netlify.app/tests/docs/doc-with-last-update/
Documentation: https://deploy-preview-7461--docusaurus-2.netlify.app/docs/api/plugins/@docusaurus/plugin-content-docs/#markdown-front-matter

Related issues/PRs

#5691

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 22, 2022
@netlify
Copy link
Copy Markdown

netlify bot commented May 22, 2022

[V2]

Name Link
🔨 Latest commit f43af83
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62976fb09a4a4a00089a0dc3
😎 Deploy Preview https://deploy-preview-7461--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 22, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 55 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 76 🟢 99 🟢 100 🟢 100 🟢 90 Report

@Josh-Cena Josh-Cena added the pr: new feature This PR adds a new API or behavior. label May 22, 2022
@Josh-Cena Josh-Cena changed the title feat(content-docs): add last update front matter feat(content-docs): last_update front matter May 22, 2022
Copy link
Copy Markdown
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation and tests look very solid for me. Well done! Just a few nits.

Waiting for @slorber to comment on the API design.

Copy link
Copy Markdown
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there, well done!

let showedFileNotTrackedError = false;

export async function getFileLastUpdate(
export function getFileLastUpdate(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep this async, we'll likely make getFileCommitDate async in the future

last_update: Joi.object({
author: Joi.string(),
date: Joi.date().raw(),
}),
Copy link
Copy Markdown
Collaborator

@slorber slorber May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we allow empty last_update object? (no strong opinion, just curious to know what you think)

Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall 👍

Just small changes requested

@dpang314 dpang314 requested a review from slorber May 28, 2022 00:51
@dpang314 dpang314 requested a review from Josh-Cena May 28, 2022 00:51
Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks 👍

@slorber slorber merged commit 4f26a19 into facebook:main Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants