Skip to content
Snippets Groups Projects
Commit bf299d19 authored by alexandre.caldato's avatar alexandre.caldato
Browse files

now update variable to update the commit info in the footer

parent 8088a7e0
No related branches found
No related tags found
No related merge requests found
## Latest Commit
**Branch name:** main
**Message:** Merge remote-tracking branch 'origin/main'
**Author:** alexandre.caldato
**Date:** 2023-06-01 19:13:51
/* 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;
}
{% 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 %}
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)
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment