-
-
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(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 ↗︎
|
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 almost ready, but:
- need to also support editUrl 🎁
- need docs
- need unit tests + fix existing snapshots
- need to dogfood
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.
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.
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? 🤔
editUrl: getItemEditUrl({ | ||
editUrl, | ||
itemDirPath: pagesDirPath, | ||
itemSourceAbsolute: pagesSourceAbsolute, | ||
permalink, | ||
i18n, | ||
options, | ||
siteDir, | ||
contentPaths, | ||
}), |
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.
😄 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
,showLastUpdateTime
andeditUrl
which 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