Skip to content
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

Single File, Generate/ Deploy #2519

Closed
rahil471 opened this issue Apr 18, 2017 · 10 comments
Closed

Single File, Generate/ Deploy #2519

rahil471 opened this issue Apr 18, 2017 · 10 comments

Comments

@rahil471
Copy link

Can we only generate/deploy single file?
Eg:

  • I run hexo deploy/generate once. (This renders everything)
  • Now I'm only modifying a single _posts (creating a new article or editing it).
  • Now instead of having me to do hexo generate again it would be great if I could just place that new/edited article.
@NoahDragon
Copy link
Member

You could do so via hexo render command, however, a new post may also affect the archive, category, rss, tag, and index pages. Therefore, the hexo generate will help to handle all these relations.

https://hexo.io/docs/commands.html#render

@rahil471
Copy link
Author

Yes correct and that's why the render command does not suits my needs, also it does not apply the theme, only does a plain html conversion.

@NoahDragon
Copy link
Member

I got your idea. I thought renderer would apply the theme.

@NoahDragon NoahDragon mentioned this issue Apr 18, 2017
53 tasks
@rahil471
Copy link
Author

Great Thanks! Would be great if you could provide me some pointers, I'll send a PR once done.

@NoahDragon
Copy link
Member

Glad you would like to contribute. I think you could start with the ConsoleRender. Probably add a flag to make it render with themes. https://github.com/hexojs/hexo/blob/master/lib/plugins/console/render.js

@NoahDragon NoahDragon added this to the 4.0 milestone Apr 18, 2017
@rahil471
Copy link
Author

Cool, thanks!

@NoahDragon
Copy link
Member

Moreover, you also could take a look at how generate command rendering a post.

hexo/lib/hexo/index.js

Lines 382 to 390 in 4676ca2

for (var i = 0; i < layoutLength; i++) {
name = layout[i];
view = theme.getView(name);
if (view) {
log.debug('Rendering %s: %s', name, chalk.magenta(path));
return view.render(locals).then(saveCache);
}
}

@rahil471
Copy link
Author

Great that helps!

@rahil471
Copy link
Author

Hey There, I'm half way through it.
Got a question.
view.render function takes in locals as a parameter, but in our case we only need to render a single file from the cli. So what should that parameter be set to?

@NoahDragon
Copy link
Member

I think it should set to the path and file data.

hexo/lib/hexo/index.js

Lines 350 to 354 in 4676ca2

var path = route.format(item.path);
var data = item.data;
var layout = item.layout;
newRouteList.push(path);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants