Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixel998 committed Feb 20, 2025
1 parent 979ef4f commit b57ef9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const path = require("node:path");
const fs = require("node:fs");
const yaml = require("js-yaml");
const { DateTime } = require("luxon");
const { execSync } = require("node:child_process");

//-----------------------------------------------------------------------------
// Eleventy Config
Expand Down Expand Up @@ -159,11 +160,19 @@ module.exports = eleventyConfig => {
value1.concat(value2),
);

eleventyConfig.addFilter("fileLastUpdated", filepath => {
eleventyConfig.addFilter("gitLastUpdated", filepath => {
// Only check git history in production
if (CONTEXT) {
try {
const stats = fs.statSync(filepath);
return stats.mtime;
const date = execSync(`git log -1 --format=%cD ${filepath}`, {
encoding: "utf-8",
}).trim();

if (!date) {
return null;
}

return new Date(date);
} catch {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/_includes/partials/post-sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h2 class="post__sidebar-module__title">Contributors</h2>
{% endfor %}
</div>

{% set file_last_updated = page.inputPath | fileLastUpdated %}
{% set last_updated = page.date if file_last_updated and file_last_updated < page.date else file_last_updated %}
{% set git_last_updated = page.inputPath | gitLastUpdated %}
{% set last_updated = page.date if git_last_updated and git_last_updated < page.date else git_last_updated %}
{% if last_updated %}
<div class="post__sidebar-module">
<h2 class="post__sidebar-module__title">Last Updated On</h2>
Expand Down

0 comments on commit b57ef9a

Please sign in to comment.