-
Notifications
You must be signed in to change notification settings - Fork 3.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
Major fixes for External URL option. #1500
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c5894cc
Merge pull request #7 from iissnan/master
ivan-nginx a6ea914
Bug: Remove redundant symbols. [2] #1494
ivan-nginx c8ee845
FIX: not found `hexo-util` with base hexo install.
ivan-nginx 6d82ed9
ADD: jshint camelcase.
ivan-nginx edf9803
ADD: open link js file loading when `exturl: true`
ivan-nginx d023b1d
FIX: loading `exturl` css only if true in config.
ivan-nginx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script type="text/javascript" src="{{ url_for(theme.js) }}/src/exturl.js?v={{ theme.version }}"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it
var util = require(hexo.base_dir + 'node_modules/hexo-util');
?My local environment information:
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 path to the
hexo-util
, on clean install all work.node_modules
will nothexo-ulil
. Buthexo-util
will be inhexo
subdir.hexo-util
with cusom command, module will be innode_modules
, not inhexo
node-modules.I don't undestand why Tommy do that, but there is 2 different path on same
hexo-util
.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.
According to the algorithm of installing a package with npm,
hexo-util
should be installed in the site'snode_modules
instead of Hexo's. In this case, it should be OK to userequire('hexo-util')
in tag scripts directly.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, it is. But, if
hexo-util
is standart hexo module inhexo
subdir, why need to separate this to external module?Anyway, u tested it? All should be worked fine on clean install.
If user will install
hexo-util
as external moduke, no matter, tag will use internalhexo-util
.What the question, VI? I don't understand.
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.
Please take a look at npm v3 Dependency Resolution. For this case,
hexo-util
is a dependency of Hexo, but is will be installed innode_module
just alone withhexo
module (not in the sub-directory ofhexo
module).I tested it with latest stable Node.js and NPM and the issue reporter has tested it as well.
So the question is that users who use npm lower than version 3 will encounter the error
hexo-util
module not found.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.
My version at test it:
And
hexo-util
was not found, yes. But if was defined only variable (was in 1st my version, before this fix).In this fix, there is:
hexo.base_dir
- global hexo variable with ABSOLUTE path to root dir (where is source, public, node_modules, etc).hexo-util
directory with all needed modules into this.If Hexo in root dir in linux, for example, expected path something like this:
/root/hexo/node_modules/hexo/node_modules/hexo-util
- this will be used, not/root/hexo/node_modules/hexo-util
.U can test it by uncomment
//console.log(util);
string atscripts/tags/exturl.js
file.hexo-util module is present in internal Hexo folder anyway, no matter what version NPM u have. So, with that fix module will use path to the internal module and will work on all versions and all platforms, i think.
No, this not need to reccomend. I repeat, in standart hexo repository always
will be hexo-util internal module. So, i just point absolute path with location to him.
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.
No.
hexo-util
module would not exist in thehexo/node_modules/
directory if using NPM whose version is above 3 to install hexo.Please see the following testing result:
Install with NPM 2 (The version that you used)
Install with NPM 3
You could see that,
hexo-util
module does not exist in thehexo/node_modules
directory when installed with NPM 3. So the solution for this issue is that we could just userequire('hexo-util')
in the tag scripts and inform users to upgrade their NPM or install missing modules (hexo-util
in this case) if errors occur to simplify the process.For your information, the following is what I did in this testing:
The content of
info.sh
file is: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.
Try to reproducte it:
And install under the following guide: https://hexo.io/
Yep, that's right. So, we stay this update for
require(hexo.base_dir + 'node_modules/hexo/node_modules/hexo-util');
Or we rollback to the
require('hexo-util');
?