Code Monkey home page Code Monkey logo

jekyll-last-modified-at's Introduction

Last Modified At Plugin

A liquid tag for Jekyll to indicate the last time a file was modified.

This plugin determines a page's last modified date by checking the last Git commit date of source files. In the event Git is not available, the file's mtime is used.

Setting up

Open your Gemfile in your Jekyll root folder and add the following:

group :jekyll_plugins do
  gem "jekyll-last-modified-at"
end

Add the following to your site's _config.yml file

plugins:
  - jekyll-last-modified-at

# Optional. The default date format, used if none is specified in the tag.
last-modified-at:
    date-format: '%d-%b-%y'

Usage

There are a few ways to use this gem.

You can place the following tag somewhere within your layout:

{% last_modified_at %}

By default, this creates a time format matching "%d-%b-%y" (like "04-Jan-14").

You can also choose to pass along your own time format. For example:

{% last_modified_at %Y:%B:%A:%d:%S:%R %}

That produces "2014:January:Saturday:04."

You can also call the method directly on a Jekyll "object," like so:

{{ page.last_modified_at }}

To format such a time, you'll need to rely on Liquid's date filter:

{{ page.last_modified_at | date: '%Y:%B:%A:%d:%S:%R' }}

(It's generally more performant to use the page.last_modified_at version of this plugin.)

jekyll-last-modified-at's People

Contributors

arretx avatar bkeepers avatar chuckhoupt avatar dirtyf avatar gjtorikian avatar jayvdb avatar msh100 avatar parkr avatar socram8888 avatar sparanoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jekyll-last-modified-at's Issues

Is this gem still compatible with the latest releases of Jekyll?

Hi,

I have attempted to include this gem on my Jekyll site (source) by adding <time datetime="{{ page.last_modified_at | date:"%r, %A %d %B %Y" }}" itemprop="dateModified"><br/><b>Last modified</b>: {{ page.last_modified_at | date:"%I:%M %p %A, %d %B %Y" }}</time> to my _layouts/post.html file and I included the jekyll-last-modified-at gem in my _config.yml file as shown in the README of this repo and even though it is included in http://fusion809.github.io/2016/01/07/comparison-of-free-operating-systems/ as you can see the last modified field is left blank. The only way it gets a value is I assign it manually in the front matter of the post. Correct me if I am wrong but isn't this plugin meant to get the last modified date from Git?

Thanks for your time,
Brenton

jekyll 3.4 support

If I hack the gemspec, v1.0.0 seems to work fine with jekyll 3.4 - is there any willingness to bump the gemspec? Is there a test suite which needs to run?

Strange problem on Jekyll 4.0.0 version

Hello!

Please, let me ask one question. I faced a strange problem.

I installed a plugin. Then I go to my post.md, and write: {% last_modified_at %}.

And there I get the error: Liquid Exception: No such file or directory - etc... Here is a screenshot of the problem: http://i.imgur.com/v3EgzGe.png

Here is my code: http://i.imgur.com/hJ5vdEW.png. But, if I put before {% last_modified_at %} any text, there is no error, screenshot: http://i.imgur.com/bDaK7i9.png

Why I faced with this problem? And how I can resolve it?

Sorry for bad English, I'm still learning. Believe, that you understand me.

Dates work locally, but not when served with AWS

Using this code in one of my include files
{{ page.last_modified_at | date: '%B %d, %Y' }}
to show the user the last time the article was updated. The jekyll-last-modified-at plugin works like a charm locally and shows the file mod date in my page html. However, when I push it up to the AWS server, the live site marks every article with January 01, 1970.

Any ideas how to remedy this? Think it's a bug or part of my build setup?

Project Specs:
Jekyll 3.8.5
Bundler 1.16.0
Gem 2.6.11
jekyll-last-modified-at 1.1.0

Sort collection by last_modified_at

I'm trying to use this value to sort a custom collection called docs.

{% assign sorted_docs = site.docs | sort: 'last_modified_at' | reverse %}
This causes:

Liquid Exception: Liquid error (line 6): comparison of Array with Array failed in index.md
Error: Liquid error (line 6): comparison of Array with Array failed
Error: Run jekyll build --trace for more information.

The same happens if I remove the reverse. But it doesn't happen if I use other field to sort it (like title).

Since it isn't documented I'm not sure if this can be used for sorting, should it work?

On watch, every single file calls out to Git

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.

Inconsistent results when running inside a Travis container

Hi,

I used the plug-in successfully, until yesterday, when I moved the build to Travis (https://travis-ci.org/gnuarmeclipse/gnuarmeclipse.github.io-source).

My pages (and my posts) have a 'Last modified on' timestamp, implemented like:

<p class="page-footer">Last modified on {{ page.last_modified_at | date: '%c %Z' }}.</p>

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/_layouts/page.html

For example the pages/about.md is dated Oct 3, 2015, and all pages generated before the move to Travis looked ok.

After the move, with each Travis run, these values change to strange dates from 2016:

-<p class="page-footer">Last modified on Sat Oct  3 17:33:27 2015 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:27:16 2016 UTC.</p>

(from commit gnuarmeclipse/gnuarmeclipse.github.io@bfaed63#diff-a7224db13f3a49096aa27c1876d1a947)

-<p class="page-footer">Last modified on Fri Oct 28 17:27:16 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:29:18 2016 UTC.</p>

(from commit gnuarmeclipse/gnuarmeclipse.github.io@d2b296c#diff-a7224db13f3a49096aa27c1876d1a947)

-<p class="page-footer">Last modified on Fri Oct 28 17:29:18 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:29:57 2016 UTC.</p>

(from commit gnuarmeclipse/gnuarmeclipse.github.io@55e15df#diff-a7224db13f3a49096aa27c1876d1a947)

and so on, to the last commit

-<p class="page-footer">Last modified on Fri Oct 28 18:07:56 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 18:08:47 2016 UTC.</p>

(from commit gnuarmeclipse/gnuarmeclipse.github.io@5fb489e#diff-a7224db13f3a49096aa27c1876d1a947)

I have no idea where these wrong dates come from.

The Travis script is apparently benign, it runs jekyll via bundle:

cd "${slug}"
bundle exec jekyll build --destination "${site}"

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/scripts/travis.linux.sh

The Gemfile explicitly asks for 1.0.0

jekyll-last-modified-at (>= 1.0.0)

and the Gemfile.lock` confirms this:

    jekyll-last-modified-at (1.0.0)
      jekyll (~> 3.2.1)
      posix-spawn (~> 0.3.9)

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/Gemfile.lock

Any suggestion on what can be so wrong?

Unfortunately this problem prevents me to continue use Travis, and forces me to revert to manual local builds. :-(

{{ page.last_modified_at | date }}

Hi!
First of all, this is the best Gem ever.
Secondly, I found a bug/issue? I usually solve things on my own, but I cannot figure this out.

If I use this:

{{ page.last_modified_at | date: '%-m/%-d/%y at %-I:%M:%S %p' }}

... I expect this out of it: 8/20/14 at 6:00:34 PM

But instead, I get this: 8/20/14 at 12:00:00 AM

No matter what, the time is always 12:00AM. Why?


{% last_modified_at %-m/%-d/%y at %-I:%M:%S %p %}

This^ seems to output just fine in any given page, but I need to get last modified dates in a for loop.

Formatted date tests fail depending on timezone

On my local machine, in TZ Asia/Jakarta, I see four test failures. I am fairly confident that is because Time.strftime emits local time, and I am thus seeing off-by-one days because of my timezone.

These errors can be reproduced by adding timezone: Asia/Jakarta to ./spec/fixtures/_config.yml, and fixed by setting it to timezone: UTC.

$ bundle exec rspec ./spec/jekyll-last-modified-at/determinator_spec.rb
F....F....

Failures:

  1) Jekyll::LastModifiedAt::Determinator knows the last modified date of the file in question
     Failure/Error: expect(subject.formatted_last_modified_date).to eql("15-Jan-14")
     
       expected: "15-Jan-14"
            got: "16-Jan-14"
     
       (compared using eql?)
     # ./spec/jekyll-last-modified-at/determinator_spec.rb:10:in `block (2 levels) in <top (required)>'

  2) Jekyll::LastModifiedAt::Determinator#to_s returns the formatted date
     Failure/Error: expect(subject.to_s).to eql("15-Jan-14")
     
       expected: "15-Jan-14"
            got: "16-Jan-14"
     
       (compared using eql?)
     # ./spec/jekyll-last-modified-at/determinator_spec.rb:41:in `block (3 levels) in <top (required)>'

$ bundle exec rspec ./spec/plugins/last_modified_at_spec.rb
FF...

Failures:

  1) Last Modified At Tag A committed post file has last revised date
     Failure/Error: expect(@post.output).to match /Article last updated on 03-Jan-14/
     
       expected "<html>\n  <head>\n    <title>last-modified-at</title>\n  </head>\n  <body>\n    <span class=\"last-modified-at\">Article last updated on 04-Jan-14</span>\n\n    <p>Yay.</p>\n\n  </body>\n</html>\n" to match /Article last updated on 03-Jan-14/
       Diff:
       @@ -1,2 +1,12 @@
       -/Article last updated on 03-Jan-14/
       +<html>
       +  <head>
       +    <title>last-modified-at</title>
       +  </head>
       +  <body>
       +    <span class="last-modified-at">Article last updated on 04-Jan-14</span>
       +
       +    <p>Yay.</p>
       +
       +  </body>
       +</html>
       
     # ./spec/plugins/last_modified_at_spec.rb:12:in `block (3 levels) in <top (required)>'

  2) Last Modified At Tag A committed post file passes along last revised date format
     Failure/Error: expect(@post.output).to match /Article last updated on 2014:January:Saturday:04/
     
       expected "<html>\n  <head>\n    <title>last-modified-at-with-format</title>\n  </head>\n  <body>\n    <span cl...\">Article last updated on 2014:January:Sunday:05</span>\n\n    <p>Yay.</p>\n\n  </body>\n</html>\n" to match /Article last updated on 2014:January:Saturday:04/
       Diff:
       @@ -1,2 +1,12 @@
       -/Article last updated on 2014:January:Saturday:04/
       +<html>
       +  <head>
       +    <title>last-modified-at-with-format</title>
       +  </head>
       +  <body>
       +    <span class="last-modified-at">Article last updated on 2014:January:Sunday:05</span>
       +
       +    <p>Yay.</p>
       +
       +  </body>
       +</html>
       
     # ./spec/plugins/last_modified_at_spec.rb:17:in `block (3 levels) in <top (required)>'

Jekyll::Tags::IncludeTagError on Bundler?

Hi there,

Would you please have a look at jekyll/jekyll/issues/3389?
Jekyll::Tags::IncludeTagError on Bundler might be caused by this plugin.

This error occurs in _includes/head_tag.html, included in _layouts/default.html, but it doesn't in one which is not included in it and inserted in _layout/default.html directly. Maybe a problem with directories?

Thanks!

Compatibility issues with Jekyll 2.4?

I just upgraded to Jekyll 2.4 yesterday, and I noticed that the "last modified" text at the bottom of each page is no longer updating when I save. For example, a page I just edited is still showing September 5, 2014 rather than September 18, 2014.

I editing my layout file to see if the plugin was still functioning:
Original: {% last_modified_at %B %d, %Y %}
Edited: {% last_modified_at %}

The output changed styles to Last Updated: 05-Sep-14, but the old date was still shown.

{{ post.last_modified_at }}

I would love if the time of last update could be made available as part of a post/pages data.

Specifically, it would be nice to use this to include the time of last update in a sitemap.
jekyll/jekyll-sitemap#18

Am I correct that this is nor currently implemented?

Date shows locally but not on github pages

When I am running locally, I correctly see the date at the bottom of the page, but when I publish it on github pages, it's completely blank:

image

my default.html layout:

<div class="col"><p>Last Modified at {{ page.last_modified_at | date: '%-d %B %Y %r' }}</p></div>

my config:

plugins:
  - jekyll-last-modified-at

# Optional. The default date format, used if none is specified in the tag.
last-modified-at:
    date-format: '%d-%b-%y'

my gem:

# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"
gem 'jekyll', '~> 4.0'

group :jekyll_plugins do
    gem "jekyll-last-modified-at"
  end

Date formatting does not work

I used gem install jekyll-last-modified-at to get version 1.2.1 of this plugin. For testing, In inserted this into a raw HTML file (not using any layouts or whatever, and with a trivial YAML header):

<ul>
<li>{% last_modified_at %}</li>
<li>{% last_modified_at %Y:%B:%A:%d:%S:%R %}</li>
<li>{{ page.last_modified_at }}</li>
<li>{{ page.last_modified_at | date: '%Y:%B:%A:%d:%S:%R' }}</li>
</ul>

These are simply the inputs from the README. But to my surprise, I got this output:

  • 15-Jan-16
  • 15-Jan-16
  • 2016-01-15 12:27:07 +0100
  • 2016:January:Friday:15:07:12:27

So the format string for last_modified_at is not actually having an effect...

Reserved characters in filename

Whilst I'm trying to install this plugin on Windows, I run into this problem:

error: unable to create file spec/fixtures/_posts/1984-03-06-command.md|whoami>.bogus: Invalid argument

This is because that filename are using a reserved character and Windows doesn't like that

improving render performance via PATH_CACHE usage and bulk `git log ...` call

I have a site with ~1300 documents and wanted to improve its render performance.

Two main observations:

  • PATH_CACHE is only read for formatted_last_modified_date, and not for last_modified_at_time
  • it looks like calls to git log ... scale linearly with the number of documents using last_modified_at within a liquid tag

re: PATH_CACHE usage
By aligning PATH_CACHE usage in both formatted_last_modified_date and last_modified_at_time the initial site render will be unaffected, but subsequent renders (e.g. after site reset when jekyll detects a change while running jekyll serve) will see improvement.

Pros:

  • very minimal patch footprint
  • regeneration time for ~1300 documents went from ~28s to ~4s

Caveats:

  • initial generation is unaffected
  • some users may have come to expect / depend on a "live" call to git log or mtime. Changing this would serve them cached time data
  • it was unclear to me if there was reason for the separation; I may have missed something!

An example of this implementation is at https://github.com/klandergren/jekyll-last-modified-at/tree/use-path-cache

re: git log ... calls scaling w/ number of documents
Both initial site render and subsequent renders will see improvement if we replace the 1:1 calls with a single git log call and cache its data. The call ends up fast enough that we can flush the cache during reset so users will always have a freshly determined last_modified_at (presumed to be preferable).

Pros:

  • feature-gated / off by default
  • initial generation and regeneration time for ~1300 documents went from ~28s to ~4s

Caveats:

  • larger patch footprint than PATH_CACHE usage
  • it is plausible that site with very large git log histories (e.g. lots of commits, lots of file churn, or both) would run into issues here. The repo I tested with has ~1800 commits without a lot of file churn. It would be possible to store the paths passed to Determinator.new and stop reading the git log when every file has been encountered, but it would be a messy implementation.
  • some users may have come to expect cached data for the formatted last_modified_at
  • some users may have a large number of uncommitted files (e.g. be using jekyll without a git repo) and the time saved by caching mtime data between rerenders is significant. I don't think this is probable but at least wanted to mention it.

An example of this implementation is at https://github.com/klandergren/jekyll-last-modified-at/tree/cache-git-information

I will open each of these improvement approaches as separate pull requests so you can evaluate.

Thanks for creating this plugin!

Travis build errors with jekyll 3.5+

All tests are failing

https://travis-ci.org/jayvdb/jekyll-last-modified-at/builds/348084091
https://travis-ci.org/jayvdb/jekyll-last-modified-at/jobs/348077039

  1) Jekyll::LastModifiedAt::Determinator knows the last modified date of the file in question
     Failure/Error:
       @site = Jekyll::Site.new(Jekyll.configuration({
         "source"      => @fixtures_path.to_s,
         "destination" => @dest.to_s,
         "plugins"     => @plugins_src
       }))
     
     NoMethodError:
       private method `select' called for #<String:0x0000000321b850>
     # ./vendor/bundle/ruby/2.1.0/gems/jekyll-3.7.3/lib/jekyll/plugin_manager.rb:31:in `require_gems'
     # ./vendor/bundle/ruby/2.1.0/gems/jekyll-3.7.3/lib/jekyll/plugin_manager.rb:22:in `conscientious_require'
     # ./vendor/bundle/ruby/2.1.0/gems/jekyll-3.7.3/lib/jekyll/site.rb:113:in `setup'
     # ./vendor/bundle/ruby/2.1.0/gems/jekyll-3.7.3/lib/jekyll/site.rb:34:in `initialize'
     # ./spec/spec_helper.rb:40:in `new'
     # ./spec/spec_helper.rb:40:in `block (2 levels) in <top (required)>'

Requires you to be in Jekyll's site

I'm running a post-receive hook on my server in order to build my personal site, parkermoore.de. It runs jekyll build in whatever directory it cares to, and I specify the --source and --destination parameters in the hook. This plugin seems to break when it is executed from outside the site source, which is a problem. Is there a git switch or something that we can use to direct git to the proper git dir?

~/code/parkermoore.de$ git push
Counting objects: 10, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 373 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: fatal: destination path '/tmp/parkermoore.de' already exists and is not an empty directory.
remote: Configuration file: /tmp/parkermoore.de/_config.yml
remote:             Source: /tmp/parkermoore.de
remote:        Destination: /var/www/parkermoore.de
remote:       Generating... fatal: /tmp/parkermoore.de/portfolio.html: '/tmp/parkermoore.de/portfolio.html' is outside repository
remote: fatal: /tmp/parkermoore.de/404.md: '/tmp/parkermoore.de/404.md' is outside repository
remote: fatal: /tmp/parkermoore.de/projects.md: '/tmp/parkermoore.de/projects.md' is outside repository
remote: fatal: /tmp/parkermoore.de/resume.md: '/tmp/parkermoore.de/resume.md' is outside repository
remote: fatal: /tmp/parkermoore.de/index.md: '/tmp/parkermoore.de/index.md' is outside repository
remote: done.
To [email protected]:parkermoore.de.git
   8008533..85c1966  master -> master

Releeeeaases?

Would love to have access to some sort of changelog so I can make a quick decision about whether to upgrade, what I'll have to fix in my code, etc. :)

Deprecation warning in Jekyll 3.0.0

Deprecation: Collection#each should be called on the #docs array directly.

Called by /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-last-modified-at-0.3.4/lib/jekyll-last-modified-at/generator.rb:7:in `block in generate'.

Unix time for static files (rather than Git time)

It seems that, for pages and posts, the modified time is when they were committed to the Git repo.

Unless I am misunderstanding somethinh, it seems that for static files the modified time is what the file system has stored rather than when it was committed to the repo. Is there a reason for this?

Have I done something wrong? (Quite likely)

Use POSIX::Spawn?

In tmm1's talk at Ruby Kaigi, he talked about the inception of the posix-spawn gem as a much faster way to shell out to a subprocess, because it doesn't copy the memory of the current process. Not sure if Open3 already has the optimization, but posix-spawn might offer some performance gain.

jekyll-last-modified-at plugin makes all posts to articles

I am using the jekyll-last-modified-at plugin together with jekyll-seo-tag. That automatically sets the date attribute based on the last changed date.

Unfortunately that turns all website content into og:type article (see line 46 in https://github.com/jekyll/jekyll-seo-tag/blob/master/lib/template.html).

That doesn't make any sense - and I can't even override it. Therefore I'd strongly recommend not to assume just because a page has a date that it's an article. Shat should be only set by hand if type is article.

Deprecation warning for posts in Jekyll 3.1.3

Hi there,

After I installed this plugin, I get the following deprecation warning:

Deprecation: posts.each should be changed to posts.docs.each.
                    Called by /Users/svetlana/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/jekyll-last-modified-at-0.3.4/lib/jekyll-last-modified-at/generator.rb:7:in `block in generate'.

I don't know if it's the same thing, as in issue #37 that has already been reported.

Plugin not working (possibly broke by commit 51396fed3f9634b2df5f042299a19d9fba5163f4)

Hi there,

I packaged a lot of the Jekyll plugins for Debian GNU/Linux. I'm using Jekyll (3.8.3) myself and enabled the jekyll-last-modified-at plugin. But still page.last_modified_at stayed empty and {% last_modified_at %} was unrecognized. When I began to look into the issue I found that neither of the module classes gets loaded. In commit 51396fe the line Tag ; Hook was removed from jekyll-last-modified-at.rb. Was it intentional? Seems this is the culprit. Re-adding this line makes the plugin functional again.

Feature request: first-posted-at

First, thanks for this excellent plugin!

This is a feature request to add a "Originally created on" or page.first-posted-at, as a complement to page.last-modified-at.

I can see the git log -n 1 command that can be easily modified but don't know enough ruby to make all the modifications needed to expose a new function such as page.first-posted-at. I see @gjtorikian is looking for maintainers already. So if anyone is willing to give me some pointers on how to structure the modifications, I can take a go at it.

Thank you!

Trouble adding this to a jekyllbootstrap blog

I've added the "gems" attribute like this in my _config.yml:

gems:
  - jekyll-last-modified-at

And added:

{% last_modified_at %}

To my post template (twitter/post.html)

But the page fails to build:

"The tag last_modified_at in _includes/themes/twitter/post.html is not a recognized Liquid tag."

How do I fix this? Should the gem be installed in some way?

Gemspec version differs from GitHub release version

The current version of this plugin is 1.3.0, which is declaed in version.rb and used in the .gemspec file.

But the last release version on GitHub is 1.1.0.

This gave me some trouble, because I only looked at the GitHub release version when adding this gem to my Gemfile with a pessimistic version operator, and Jekyll's build failed.

Could you please release a new version on GitHub?

A little help please...

Hi,
Trying to get this working on a local copy of some github pages using jekyll and the leap-day template

I've added
plugins:

  • jemoji
  • jekyll-mentions
  • jekyll-last-modified-at

to _config .yml and run gem update, but when I run bundle I can't see Jekyll-last-modified-at listed. jemoji and jekyll-mentions are both there, but not jekyll-last-modified-at.
only error I'm seeing is this gem update

ERROR:  Error installing did_you_mean:
        did_you_mean requires Ruby version >= 2.5.0dev.
Gems updated: did_you_mean

Is it related?

Date Display Customization?

I noticed that the date is displayed only as %d-%b-%y, and there's no way to customize it. I think it'd be useful for it to be customizable. Here are the three approaches I think might be wise:

  • This filter returns just the Time object, and users can pass them to the date filter and customize the output
  • Users can set a default value in their _config.yml that is then used to parse the Time object into a string. Would apply to all output, so they'd have to really like this display.
  • A combination of the two, where if the default is nil, then we return Time otherwise, we render it as a String

Thoughts?

How to get at one piece of data...

The following:

{% assign page_list = site.pages %}

{{page_list[0]}}

Results in showing me the first page in my list of pages. In the key/value pairs that result, there is one that has the information I need, but it's buried in @to_liquid= at the end.

If I want to sort the pages by date, I get an error when I add the sort filter to the assign. How can I get "last_modified_at"=>2018-07-07 09:42:44 -0700 to be the key/value pair instead of all of that other stuff?

“last_modified_at”=>#<Jekyll::LastModifiedAt::Determinator:0x00000002a25858 @site_source=”/var/www/newvalleyresources”, @page_path=”404.md”, @opts={}, @article_file_path=”/var/www/newvalleyresources/404.md”, @is_git_repo=true, @top_level_git_directory=”/var/www/newvalleyresources/.git”, @relative_path_from_git_dir=”404.md”, @to_liquid=2018-07-07 09:41:44 -0700>

Compatible with GitHub Page

Hi,

I wonder if this plugin works with GitHub Page?

Also, could you please add a installation section on README.MD for Jekyll newbie?

Many thanks
Yi

Consider page dependencies?

I have several pages in my site, whose content is generated based on YAML data in _data, or which display the items of a collection. Currently, only changes to the page source itself are reflected by page.last_modified_at. I would like page.last_modified_at to reflect when the page content changes due to changes in the underlying data / collection (such that the jekyll-sitemap plugin generates correct <lastmod> tags).

Is this feature currently supported, or planned?

If it's not yet supported, I would be willing to take a look into this issue myself, if you could give me some guidance.

I'm looking for maintainers/sponsors

People not only use this project, but depend on it. After building open source software for over a decade, I'm always surprised when that happens.

Unfortunately, I don't really use Jekyll as often as I used to, and I don't really have a need for this plugin. There are quite a few open issues representing thorny problems; I'm (passively) looking for contributors to help maintain the repo.

Alternatively, a GitHub Sponsorship would be nice to show your appreciation and will motivate me to work on this (and other plugins) more. Stars can't pay the rent I'm afraid.

Please improve the docs

This Gem is pretty sweet, and has been mentioned in the Jekyll SEO Tag issues by @pathawks. But the docs don't talk much about how it actually works (e.g. leveraging GitHub commits). Could this information be added to the README?

GitHub pages shows newer date

I'm trying to add the last modified date to the pages on my website.
But on GitHub pages it says that the page was recently updated, even though I last updated it in September.

  • Local

    Screenshot 2023-11-01 at 16 00 03
  • Published

    Screenshot 2023-11-01 at 16 00 08

Any ideas to fix this?

Option to disable git

There may be times when the mtime is correct, even if it is in a git repo, so it should be possible to indicate that is the desired date instead of invoking git to obtain the same information.

Example, using https://github.com/rosylilly/git-set-mtime once after a git clone, so all parts of the subsequent build can benefit from using a correct mtime.

All dates are the same

Am i doing something wrong, not sure.

So i'm using the {{ page.last_modified_at | date: "%b %-d, %Y at %r" }}, it shows in all posts properly but the date is the same, even tho i didn't edit any of the pages yet.

I tried again with editing a page to see if the date will change but it's still the same. Should i change something ?

Dependency Error: Yikes!

I'm new to jekyll and ruby, so please help me out because I'm not really sure what I'm missing here. Per the docs, I've added this to _config.yml

gems:
  - jekyll-last-modified-at

I even took the extra undocumented step of trying to install the gem.

bash-4.3# gem install jekyll-last-modified-at

Successfully installed jekyll-last-modified-at-1.0.1
Parsing documentation for jekyll-last-modified-at-1.0.1
Done installing documentation for jekyll-last-modified-at after 0 seconds
1 gem installed

bash-4.3# bundle

Using public_suffix 2.0.5
Using colorator 1.1.0
Using ffi 1.9.18
Using forwardable-extended 2.6.0
Using sass 3.4.23
Using rb-fsevent 0.9.8
Using kramdown 1.13.2
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.11.1
Using safe_yaml 1.0.4
Using bundler 1.14.6
Using addressable 2.5.1
Using rb-inotify 0.9.8
Using pathutil 0.14.0
Using jekyll-sass-converter 1.5.0
Using listen 3.0.8
Using jekyll-watch 1.5.0
Using jekyll 3.4.0
Bundle complete! 2 Gemfile dependencies, 19 gems now installed.
Use bundle show [gemname] to see where a bundled gem is installed.

All seems to install OK, but it just fails to build and serve.

bash-4.3# bundle exec jekyll serve

fetch http://mirror.envygeeks.io/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://mirror.envygeeks.io/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
fetch http://mirror.envygeeks.io/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://mirror.envygeeks.io/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://mirror.envygeeks.io/alpine/edge/main/x86_64/APKINDEX.tar.gz
OK: 255 MiB in 72 packages
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using public_suffix 2.0.5
Using colorator 1.1.0
Using ffi 1.9.18
Using forwardable-extended 2.6.0
Using sass 3.4.23
Using rb-fsevent 0.9.8
Using kramdown 1.13.2
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.11.1
Using safe_yaml 1.0.4
Using bundler 1.14.6
Using addressable 2.5.1
Using rb-inotify 0.9.8
Using pathutil 0.14.0
Using jekyll-sass-converter 1.5.0
Using listen 3.0.8
Using jekyll-watch 1.5.0
Using jekyll 3.4.0
Bundle updated!
Configuration file: /srv/jekyll/_config.yml
Configuration file: /srv/jekyll/_config.yml
Dependency Error: Yikes! It looks like you don't have jekyll-last-modified-at or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll-last-modified-at' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.4.0 | Error: jekyll-last-modified-at

Deprecate {% last_modified_at %}

In the readme it says:

(It's generally more performant to use the page.last_modified_at version of this plugin.)

Reading through things, it looks like page.last_modified_at is calculate as page meta across all documents, whatever you do.

Why have two ways to do the same thing? Why not (at the next major version), only support the meta version? That way you have half the invocations to maintain, and users are always use the more performant method.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.