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

feat(pages): add LastUpdateAuthor & LastUpdateTime & editUrl #10032

Merged
merged 20 commits into from
Apr 16, 2024

Conversation

OzakIOne
Copy link
Contributor

@OzakIOne OzakIOne commented Apr 9, 2024

Motivation

Provide two options in pages showLastUpdateAuthor, showLastUpdateTime and editUrl which like in docs, show the time the page was last updated and also who updated it

This only works for markdown pages

pages: {
  editUrl: ({locale, pagesPath}) => {
    if (locale !== defaultLocale) {
      return `https://crowdin.com/project/docusaurus-v2/${locale}`;
    }
    return `https://github.com/facebook/docusaurus/edit/main/website/src/pages/${pagesPath}`;
  },
  showLastUpdateAuthor: true,
  showLastUpdateTime: true,
}

Test Plan

Deploy, tests, dogfood

Test links

Deploy preview: https://deploy-preview-10032--docusaurus-2.netlify.app/tests

Related issues/PRs

#9954

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 9, 2024
Copy link

netlify bot commented Apr 9, 2024

[V2]

Name Link
🔨 Latest commit 287bf0b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/661d5e1e3addcc0008ea79da
😎 Deploy Preview https://deploy-preview-10032--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 configuration.

Copy link

github-actions bot commented Apr 9, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 56 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 68 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 71 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 61 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 70 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

github-actions bot commented Apr 9, 2024

Size Change: +157 B (0%)

Total Size: 1.05 MB

Filename Size Change
website/build/assets/js/main.********.js 811 kB +157 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 91.2 kB
website/build/assets/css/styles.********.css 113 kB
website/build/index.html 38 kB

compressed-size-action

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Apr 11, 2024
@OzakIOne OzakIOne marked this pull request as ready for review April 11, 2024 16:24
@OzakIOne OzakIOne added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Apr 11, 2024
Copy link

argos-ci bot commented Apr 11, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 🧿 Changes detected (Review) 3 changed Apr 15, 2024, 5:13 PM

Copy link
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 almost ready, but:

  • need to also support editUrl 🎁
  • need docs
  • need unit tests + fix existing snapshots
  • need to dogfood

Copy link
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.

Almost good!

Would like to test this on the dogfood plugins too, meta row UI should appear on these pages:

https://deploy-preview-10032--docusaurus-2.netlify.app/tests/pages/

Comment on lines +134 to +163
function getPagesEditUrl() {
const pagesPathRelative = path.relative(
pagesDirPath,
path.resolve(pagesSourceAbsolute),
);

if (typeof editUrl === 'function') {
return editUrl({
pagesDirPath: posixPath(path.relative(siteDir, pagesDirPath)),
pagesPath: posixPath(pagesPathRelative),
permalink,
locale: i18n.currentLocale,
});
} else if (typeof editUrl === 'string') {
const isLocalized =
pagesDirPath === contentPaths.contentPathLocalized;
const fileContentPath =
isLocalized && options.editLocalizedFiles
? contentPaths.contentPathLocalized
: contentPaths.contentPath;

const contentPathEditUrl = normalizeUrl([
editUrl,
posixPath(path.relative(siteDir, fileContentPath)),
]);

return getEditUrl(pagesPathRelative, contentPathEditUrl);
}
return undefined;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wonder if we could find a way to deduplicate/extract that complexity to utils? 🤔

website/docs/api/plugins/plugin-content-pages.mdx Outdated Show resolved Hide resolved
website/docusaurus.config.ts Outdated Show resolved Hide resolved
website/_dogfooding/dogfooding.config.ts Outdated Show resolved Hide resolved
Comment on lines 184 to 193
editUrl: getItemEditUrl({
editUrl,
itemDirPath: pagesDirPath,
itemSourceAbsolute: pagesSourceAbsolute,
permalink,
i18n,
options,
siteDir,
contentPaths,
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

😄 maybe that was a bad idea, if we can only use it on the pages plugin and not all other plugins it's probably not worth it to extract to docusaurus utils 😅 (didn't see at first that the edit URL fn all have different param names)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. 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.

3 participants