Skip to content

Commit

Permalink
Docs0 v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleperilli committed Mar 9, 2024
1 parent 3e6284d commit 0fecf1b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/fetch-commit-dates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: fetch-commit-dates

on:
push:
branches:
- main
paths-ignore:
- '_data/commit_dates.json'

jobs:

fetch-commit-dates:
if: ${{ !startsWith(github.event.head_commit.committer.name, 'GitHub Actions') }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to get full commit history

- name: Run Ruby script
run: ruby fetch-commit-dates.rb

- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Update file dates"
title: "[auto] Update file dates"
body: "Automated action to update modified file dates to the latest commit date."
branch: "actions/update-file-dates"
base: main
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Docs0 Changelog

## 1.0.3 (2024-03-09)
- Add automatic file modified date

## 1.0.2 (2024-03-08)
- Add unlisted property

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Parameters:
- **draft:** (optional) set ***true*** to show a notice that the document is not completed (note that this notice appears automatically if the document is empty or if it contains a <todo></todo> tag. Set ***nodraft: true*** to avoid displaying the notice.
- **date:** set the creation date of the document.
- **modified:** set the date of the last modification of the document.
> Note that the last modified date is automatically updated when the document is modified and pushed to the repository. Use this parameter only if you need to set a specific date.
- **order:** set a string to be used to sort the document in the navigation menu - check existing files to know how sorting works. In general, if the page is the child of a node, it is necessary to insert the order attribute of the parent node plus a slash ***/*** and a number (if you want to give a static position) or a sanitized version of the title (without spaces and special characters - if you want to use alphabetical sorting). Note that numbers come before letters (as they are placed before in the ASCII table); if you want that they are placed after letters, you need to enclose them in curly braces: e.g. ***zzz*** is after ***01*** but before ***{01}***.
- **toc:** (optional) set ***false*** to hide the automatic table of contents.
- **toc_h_min:** (optional) set the minimum heading level to include in the table of contents. This setting is set at the site level in the `_config.yml`. Default is 2.
Expand Down
6 changes: 5 additions & 1 deletion _includes/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
{% if page.modified %}
{{ page.modified | date: "%b %d, %Y" }}
{% else %}
{{ page.date | date: "%b %d, %Y" }}
{% if site.data.commit_dates[page.path] %}
{{ site.data.commit_dates[page.path] | date: "%b %d, %Y" }}
{% else %}
{{ page.date | date: "%b %d, %Y" }}
{% endif %}
{% endif %}
</div>
{% endif %}
Expand Down
15 changes: 15 additions & 0 deletions fetch-commit-dates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'json'
require 'fileutils'

# Create _data folder if it doesn't exist
data_folder = '_data'
Dir.mkdir(data_folder) unless File.exists?(data_folder)

last_commits = {}
`git ls-files -- '*.md'`.each_line do |file|
file.chomp!
commit_date = `git log -1 --format='%ad' --date=iso -- "#{file}"`.chomp
last_commits[file] = commit_date
end

File.write(File.join(data_folder, 'commit_dates.json'), JSON.pretty_generate(last_commits))
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Docs0",
"version": "1.0.2",
"lastUpdated": "2024-03-08",
"version": "1.0.3",
"lastUpdated": "2024-03-09",
"scripts": {
"run (incremental)": "bundle exec jekyll serve --incremental --port 4001",
"run (full)": "bundle exec jekyll serve --port 4001"
Expand Down

0 comments on commit 0fecf1b

Please sign in to comment.