aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/article.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/article.py b/src/article.py
index a35b431..fc73edd 100644
--- a/src/article.py
+++ b/src/article.py
@@ -8,6 +8,7 @@ import typing
import markdown
import yaml
import markupsafe
+import subprocess
logger = logging.getLogger(__name__)
@@ -140,8 +141,14 @@ class ArticleGenerator:
article_args[
'url'] = f'{"/" if article_args["web_dir"] else ""}{"/".join(article_args["web_dir"])}/{article_args["name"]}'
- article_args['modified'] = datetime.datetime.utcfromtimestamp(os.path.getmtime(path)).replace(
- tzinfo=datetime.datetime.now().astimezone().tzinfo)
+ # Get article modified date time from git commit
+ article_args['modified'] = datetime.datetime.fromisoformat(subprocess.run(
+ ['git', 'log', '-1', '--pretty=format:%ci', pathlib.Path(path).relative_to(self.articles_path)],
+ cwd=self.articles_path, capture_output=True, text=True).stdout)
+
+ # Get article modified date time from file system
+ # article_args['modified'] = datetime.datetime.utcfromtimestamp(os.path.getmtime(path)).replace(
+ # tzinfo=datetime.datetime.now().astimezone().tzinfo)
with open(path, 'r') as file:
source = file.read()