-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix Edit on GitHub #1853
fix Edit on GitHub #1853
Conversation
build.js
Outdated
const contents = file.contents.toString().replace(/<h1>(.+)<\/h1>/, ($1, $2) => { | ||
return `<a class="edit-link" href="${url}">Edit on GitHub</a> <h1>${$2}</h1>` | ||
const contents = file.contents.toString().replace(/<h1(.*?)>(.*?)<\/h1>/, ($1, $2, $3) => { | ||
return `<a class="edit-link" href="${url}">Edit on GitHub</a> <h1>${$3}</h1>` |
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.
perhaps h1
props should be hold. like this:
return `<a class="edit-link" href="${url}">Edit on GitHub</a> <h1${$2}>${$3}</h1>`
build.js
Outdated
@@ -185,8 +185,8 @@ function githubLinks (options) { | |||
const file = files[path] | |||
const url = `https://github.com/nodejs/nodejs.org/edit/master/locale/${options.locale}/${path.replace('.html', '.md')}` | |||
|
|||
const contents = file.contents.toString().replace(/<h1>(.+)<\/h1>/, ($1, $2) => { | |||
return `<a class="edit-link" href="${url}">Edit on GitHub</a> <h1>${$2}</h1>` | |||
const contents = file.contents.toString().replace(/<h1(.*?)>(.*?)<\/h1>/, ($1, $2, $3) => { |
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.
The callback signature was a bit misleading, should be (match, $1, $2)
.
You can also get rid of the first capture group (since it's unused). /<h1[^>]+>(.*?)<\/h1>/
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.
Thanks for your help. So I don't need to change it anymore right ?
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.
Yes, we're good now. ;)
@ZYSzys, when you open a PR there's a checkbox named "Allow edits from maintainers." git push https://github.com/zys-contribs/nodejs.org edit-on-github |
@refack Understand now, thanks very much! |
Now:
After fixed,
Edit on GitHub
shows at right side.