gjtorikian / jekyll-last-modified-at

A Jekyll plugin to show the last_modified_at time of a post.
MIT License
244 stars 39 forks source link

On watch, every single file calls out to Git #24

Closed gjtorikian closed 10 years ago

gjtorikian commented 10 years ago

Pre-0.3.0, Jekyll sites would crash with this plugin and --watch. Now, they remain, but generation takes a really long time, because every single file needs a Git call to check the time.

@parkr Is there a way to run a plugin once, before the server starts up, and not every time an auto-regeneration occurs? If not, the only thing I can think of is to preserve some kind of hash, like @matches[absolute_path_to_article] = last_change, and just not even attempt the last_modified_at check if the file was checked once before.

parkr commented 10 years ago

You can keep a hash if you want on the Determinator maybe? {"path" => Time}?

gjtorikian commented 10 years ago

I understood maybe five of those words.

So a Hash is kept, and then what? "Rerun Determinator if Time > 45 minutes" ?

parkr commented 10 years ago

@gjtorikian Sure, or just keep an ongoing cache of all the dates (unformatted of course) and don't rebuild anything in the current process. That would ensure, when using --watch, that git is only ever called once per page per process (not each time the listener rebuilds).

That hardly makes sense to me in words. Sorry I suck at words today.

gjtorikian commented 10 years ago

:heart:

gjtorikian commented 10 years ago

I think the sexy rewrite nullified this. I can no longer reproduce the error.

parkr commented 10 years ago

YAYYYY :tada: sexy = perf

gjtorikian commented 10 years ago

Still an issue.

parkr commented 10 years ago

Are you using {{ page.last_modified_at }} or {% last_modified_at %}? The latter will spawn a multitude of processes, whereas the former will cache at the page level so each subsequent call to it on the page just returns the already-computed value.

gjtorikian commented 10 years ago

The latter, though maybe I should switch to the former? Either way the problem needed to be fixed.

parkr commented 10 years ago

Definitely use page.last_modified_at as often as possible. I think you'll find it doesn't thrash your system as much. :smile:

AnandLA commented 9 years ago

How do I install this as a plugin within jekyll ... I created a _plugin directory and git cloned into it now what ?

888ba8 commented 3 years ago

@AnandLA @parkr @gjtorikian I can only use

{% last_modified_at %}

If I try to include {% page.last_modified_at %} in my layout, I get the following error, when I try to bundle exec jekyll build: Liquid syntax error (line 1): Unknown tag 'page' in /_layouts/page.html

How to fix this please?

mraible commented 3 years ago

I'm experiencing a similar issue to @888ba8.

Liquid Exception: No such file or directory - /Users/mraible/dev/path/to/blog/tags/android/index.html does not exist! in /_layouts/tag.html
jekyll 3.9.0 | Error:  No such file or directory - /Users/mraible/dev/path/to/blog/_source/blog/tags/android/index.html does not exist!

If I remove {{ page.last_modified_at }} and replace it with {% last_modified_at %}, I get the same error.

Anyone figure out a way to add "Last updated" to a Jekyll blog? I tried a few other solutions, but none seem to work.