From 716a3903bbf93630cbbf09fa754d5d183cb3d6a6 Mon Sep 17 00:00:00 2001 From: Prakhar Verma Date: Mon, 30 Mar 2026 13:42:18 -0400 Subject: [PATCH] feat: Automate extraction and display of Git metadata Closes #4 - Implemented _plugins/git_metadata.rb to extract author, creation, and modified dates into frontmatter - Created _includes/components/footer.html to display metadata - Updated checkout action depth to fetch full history --- .github/workflows/jekyll.yml | 2 ++ _includes/components/footer.html | 48 ++++++++++++++++++++++++++++++++ _plugins/git_metadata.rb | 24 ++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 _includes/components/footer.html create mode 100644 _plugins/git_metadata.rb diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index 61f2d80..907a608 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -33,6 +33,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Ruby # https://github.com/ruby/setup-ruby/releases/tag/v1.207.0 uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 diff --git a/_includes/components/footer.html b/_includes/components/footer.html new file mode 100644 index 0000000..a38d1c8 --- /dev/null +++ b/_includes/components/footer.html @@ -0,0 +1,48 @@ +{% capture footer_custom %} + {%- include footer_custom.html -%} +{% endcapture %} +
+ diff --git a/_plugins/git_metadata.rb b/_plugins/git_metadata.rb new file mode 100644 index 0000000..14f9862 --- /dev/null +++ b/_plugins/git_metadata.rb @@ -0,0 +1,24 @@ +Jekyll::Hooks.register [:pages, :documents], :post_init do |doc| + path = doc.path + + if path && File.exist?(path) + # Fetch git history for this specific file + # %ad: author date, %an: author name + git_log = `git log --follow --format="%ad|%an" --date=iso-strict -- "#{path}" 2>/dev/null`.strip + + unless git_log.empty? + logs = git_log.split("\n") + + # First commit (oldest) = creation date + first_commit = logs.last.split('|') + doc.data["created_at"] ||= first_commit.first + + # Last commit (newest) = last modified date + last_commit = logs.first.split('|') + doc.data["last_modified_date"] ||= last_commit.first + + # Current author (last modifying author) + doc.data["author"] ||= last_commit.last + end + end +end