Closed twatzl closed 5 years ago
Only to "fix" the order of calling of "generators",
add .sort()
into lib/hexo/index.js
of hexo.
diff --git a/lib/hexo/index.js b/lib/hexo/index.js
index b181db1..d941c6a 100644
--- a/lib/hexo/index.js
+++ b/lib/hexo/index.js
@@ -326,7 +326,7 @@ Hexo.prototype._runGenerators = function() {
const { log } = this;
// Run generators
- return Promise.map(Object.keys(generators), key => {
+ return Promise.map(Object.keys(generators).sort(), key => {
const generator = generators[key];
return Reflect.apply(generator, this, [siteLocals]).then(data => {
Of course, this is quite HACKY!
By specification of JavaScript,
the order of the return value of Object.keys()
is unpredictable.
So it might seem random.
Basically, I think that any "generator" should not depend on the order of calling. So I think this hack will not be promoted to a Pull Request.
@twatzl Could you try to debug your generator with this hack?
Sorry. I migrated my blog to the hugo software since opening this issue, since it has native support for multi language blogs.
I have not written that generator, but from what I remember it relied on all other content being generated first and then would create multiple versions of the blog for each language by replacing some placeholders.
Hello,
sorry it is me again, but it seems there are quite a few points not covered by the documentation so I am getting stuck again and again.
I recently had this problem debugging, now I managed to debug the Issue and it seems that the cause of my issues is the generator https://github.com/Jamling/hexo-generator-i18n which I am using. It seems that the generator needs to be invoked as the last generator.
I have attached you two logs from yesterday where I tried generating my webpage. The first one failed, the second one which was run just seconds later succeeded. The main difference seems to be the order in which the generators were invoked.
Now my question is: Is there anyway to control the order in which the generators are called? It seems to be random.
Or is there a better i18n generator which I could use?