-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Add customize highlight.theme custom path support #517
Add customize highlight.theme custom path support #517
Conversation
@huang-x-h Hi. Sorry for the delay here. I am currently on vacation. I will have a thorough review of this as soon as I can. |
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 the PR @huang-x-h ! Please have a look at the suggestions in the comments. If you would not be available to fix this, just let us know and we can take over 😄
lib/core/Head.js
Outdated
const highlightTheme = highlightConfig.theme || 'default'; | ||
|
||
if (highlight.theme.indexOf('/') > -1) { | ||
highlight = highlight.theme; |
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.
It's not a good idea to let the theme be either a string or a URL as this leads to confusing configuration. It's better to add a new field in highlight
object called themeUrl
and the code here uses it directly instead of building up the URL from the version and theme. Do remember to add this new URL to the siteConfig
documentation.
Define a new variable highlightThemeURL
instead. Don't reassign a value of a different type to the highlight
variable.
// Use user-provided themeUrl if it exists, else construct one from version and theme.
let highlightThemeURL = highlight.themeUrl || `//cdnjs.cloudflare.com/ajax/libs/highlight.js/${highlight.version}/styles/${highlight.theme}.min.css`;
// Use highlightThemeURL in the `<link>`.
lib/core/Head.js
Outdated
const highlightVersion = highlightConfig.version || highlightDefaultVersion; | ||
const highlightTheme = highlightConfig.theme || 'default'; | ||
|
||
if (highlight.theme.indexOf('/') > -1) { |
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.
This is not a very strong check. There's no guarantee that themes cannot have slashes in it in the future. Refer to comment below about using a themeUrl
field as a check.
lib/core/Head.js
Outdated
const highlightTheme = highlightConfig.theme || 'default'; | ||
|
||
if (highlight.theme.indexOf('/') > -1) { | ||
highlight = highlight.theme; |
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.
Define a new variable highlightURL
instead. Don't reassign a value of a different type to the highlight
variable.
@@ -33,12 +33,6 @@ class Site extends React.Component { | |||
(this.props.url || 'index.html'); | |||
let docsVersion = this.props.version || 'current'; | |||
|
|||
const highlightDefaultVersion = '9.12.0'; |
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 removing this 👍
aa713dc
to
fa36d9d
Compare
@yangshun thank you for your review, it's fixed. |
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.
@JoelMarcey Please have a final look
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 great to me. Should go out in the next release!
Motivation
Add customize highlight.theme custom path support. Fixes #428
eg:
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Test success on local
Related PRs
N/A