From bf299d19c54de3aedfbd38f2e907b6d7f7e5eb17 Mon Sep 17 00:00:00 2001
From: "alexandre.caldato" <alexandre.caldato@sully-group.fr>
Date: Thu, 1 Jun 2023 20:19:19 +0200
Subject: [PATCH] now update variable to update the commit info in the footer

---
 docs/commit_info.md     | 11 -----------
 docs/css/extra.css      | 19 +++++++++++++++++++
 dsfr_theme/main.html    | 12 ++++++++++++
 generate_commit_info.py | 18 +++++++++---------
 mkdocs.yml              | 17 ++++++++++++++---
 5 files changed, 54 insertions(+), 23 deletions(-)
 delete mode 100644 docs/commit_info.md
 create mode 100644 docs/css/extra.css
 create mode 100644 dsfr_theme/main.html

diff --git a/docs/commit_info.md b/docs/commit_info.md
deleted file mode 100644
index c159130..0000000
--- a/docs/commit_info.md
+++ /dev/null
@@ -1,11 +0,0 @@
-## Latest Commit
-
-**Branch name:** main
-
-**Message:** Merge remote-tracking branch 'origin/main'
-
-
-**Author:** alexandre.caldato
-
-**Date:** 2023-06-01 19:13:51
-
diff --git a/docs/css/extra.css b/docs/css/extra.css
new file mode 100644
index 0000000..92d9509
--- /dev/null
+++ b/docs/css/extra.css
@@ -0,0 +1,19 @@
+/* This is for the footer to stick at the bottom */
+html, body {
+    display: flex;
+    flex-direction: column;
+    min-height: 100vh;
+    margin: 0;
+}
+
+footer {
+    margin-top: auto;
+    width: 100%;
+    position: absolute;
+    bottom: 0;
+    font-weight: 500;
+}
+
+li {
+    list-style: none;
+}
diff --git a/dsfr_theme/main.html b/dsfr_theme/main.html
new file mode 100644
index 0000000..0fe0ed0
--- /dev/null
+++ b/dsfr_theme/main.html
@@ -0,0 +1,12 @@
+{% extends "base.html" %}
+
+{% block footer %}
+<div class="commit-info">
+    <ul>
+        <li>Branch: {{ config.extra.commit_info.branch }}</li>
+        <li>Message: {{ config.extra.commit_info.message }}</li>
+        <li>Author: {{ config.extra.commit_info.author }}</li>
+        <li>Date: {{ config.extra.commit_info.date }}</li>
+    </ul>
+</div>
+{% endblock %}
diff --git a/generate_commit_info.py b/generate_commit_info.py
index 6ecb233..140d8d1 100644
--- a/generate_commit_info.py
+++ b/generate_commit_info.py
@@ -1,3 +1,4 @@
+import yaml
 from git import Repo
 
 
@@ -13,17 +14,16 @@ def get_git_commit_info(repo_path):
     }
 
 
-def generate_md_file(commit_info, output_file):
-    with open(output_file, 'w') as file:
-        file.write(f"## Latest Commit\n\n")
-        file.write(f"**Branch name:** {commit_info['branch']}\n\n")
-        file.write(f"**Message:** {commit_info['message']}\n\n")
-        file.write(f"**Author:** {commit_info['author']}\n\n")
-        file.write(f"**Date:** {commit_info['date']}\n\n")
+def write_commit_info_to_config(commit_info, config_file):
+    with open(config_file, 'r+') as file:
+        config = yaml.safe_load(file)
+        config['extra']['commit_info'] = commit_info
+        file.seek(0)
+        yaml.dump(config, file)
 
 
 if __name__ == "__main__":
     repo_path = '.'
-    output_file = 'docs/commit_info.md'
+    config_file = 'mkdocs.yml'
     commit_info = get_git_commit_info(repo_path)
-    generate_md_file(commit_info, output_file)
+    write_commit_info_to_config(commit_info, config_file)
diff --git a/mkdocs.yml b/mkdocs.yml
index 7606ae7..86bdda1 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,4 +1,15 @@
-site_name: My Docs
+extra:
+  commit_info:
+    author: alexandre.caldato
+    branch: main
+    date: '2023-06-01 19:50:17'
+    message: 'add script to generate commit md file'
+extra_css:
+- css/extra.css
 nav:
-  - Home: index.md
-  - Latest Commit: commit_info.md
+- Home: index.md
+- Latest Commit: commit_info.md
+site_name: My Docs
+theme:
+  custom_dir: dsfr_theme
+  name: mkdocs
-- 
GitLab