-
-
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(v2): add edit url in post page #2524
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 8e26f99 |
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.
Need tests.
Hi @lex111. Do I need to implement jest tests? What type of test do you suggest? |
See test below as an example. docusaurus/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.ts Lines 63 to 89 in 32c1a92
|
packages/docusaurus-theme-classic/src/theme/BlogPostPage/index.js
Outdated
Show resolved
Hide resolved
|
||
function EditPage({url}) { | ||
return ( | ||
<div> |
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.
Remove redundant div
.
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.
Thank you, this looks really good. But let's not touch the docs theme markup (extracting the utility function is fine, but leave the markup duplicated). We don't want to create too many theme components.
Few more things:
- Document the new option in
website/docs/using-plugins.md
under the docs plugin section 😄 - Add this option into the default templates (can be done in a follow up PR)
@@ -13,6 +13,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | |||
import useBaseUrl from '@docusaurus/useBaseUrl'; | |||
import DocPaginator from '@theme/DocPaginator'; | |||
import useTOCHighlight from '@theme/hooks/useTOCHighlight'; | |||
import EditPage from '@theme/EditPage'; |
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.
Just copy and paste this component, don't make a new component for this edit button. Anyway it should probably be called EditButton
if we wanted to make it a component.
@@ -26,12 +29,10 @@ function BlogPostPage(props) { | |||
isBlogPostPage> | |||
<BlogPostContents /> | |||
</BlogPostItem> | |||
{(metadata.nextItem || metadata.prevItem) && ( | |||
<EditPage url={editUrl} /> |
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.
Just duplicate the SVG and the <a>
30bfe7b
to
112f42b
Compare
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.
I made some changes, let's merge this first.
You can make a follow up PR to add showReadingTime
and editUrl
to the templates 😁
Motivation
Fix #2501
Add label option to edit page in blog as in doc
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
go to a post page
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)