feat(pages): add LastUpdateAuthor & LastUpdateTime & editUrl#10032
feat(pages): add LastUpdateAuthor & LastUpdateTime & editUrl#10032
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: +157 B (0%) Total Size: 1.05 MB
ℹ️ View Unchanged
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
slorber
left a comment
There was a problem hiding this comment.
Looks almost ready, but:
- need to also support editUrl 🎁
- need docs
- need unit tests + fix existing snapshots
- need to dogfood
slorber
left a comment
There was a problem hiding this comment.
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/
| 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; | ||
| } |
There was a problem hiding this comment.
Wonder if we could find a way to deduplicate/extract that complexity to utils? 🤔
| editUrl: getItemEditUrl({ | ||
| editUrl, | ||
| itemDirPath: pagesDirPath, | ||
| itemSourceAbsolute: pagesSourceAbsolute, | ||
| permalink, | ||
| i18n, | ||
| options, | ||
| siteDir, | ||
| contentPaths, | ||
| }), |
There was a problem hiding this comment.
😄 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)
Motivation
Provide two options in pages
showLastUpdateAuthor,showLastUpdateTimeandeditUrlwhich like in docs, show the time the page was last updated and also who updated itThis only works for markdown pages
Test Plan
Deploy, tests, dogfood
Test links
Deploy preview: https://deploy-preview-10032--docusaurus-2.netlify.app/tests
Related issues/PRs
#9954