feat(ui): add git version info display in header
- Display current branch/tag and commit hash in navbar center - Show dirty working directory indicator with yellow badge - Add automatic build info generation in Task workflow - Include build timestamp and user information - Style with responsive design (hidden on mobile) - Add .gitignore entries for generated build artifacts
This commit is contained in:
parent
69457ec964
commit
1d79ce85a5
8 changed files with 196 additions and 0 deletions
35
layouts/partials/version-info-script.html
Normal file
35
layouts/partials/version-info-script.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{{/* Inline JavaScript to add version info to navbar */}}
|
||||
{{ $buildInfo := .Site.Data.build_info }}
|
||||
{{ if $buildInfo }}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Find the navbar container
|
||||
const navbarContainer = document.querySelector('.td-navbar .container-fluid');
|
||||
if (!navbarContainer) return;
|
||||
|
||||
// Create version info element
|
||||
const versionDiv = document.createElement('div');
|
||||
versionDiv.className = 'navbar-version-info d-none d-md-flex align-items-center mx-3';
|
||||
versionDiv.style.flex = '1';
|
||||
versionDiv.style.justifyContent = 'center';
|
||||
|
||||
const versionText = {{ if $buildInfo.git_tag }}"{{ $buildInfo.git_tag }}"{{ else }}"{{ $buildInfo.git_branch }}"{{ end }};
|
||||
const commitHash = "{{ $buildInfo.git_commit_short }}";
|
||||
const isDirty = {{ $buildInfo.git_dirty }};
|
||||
|
||||
versionDiv.innerHTML = `
|
||||
<small class="text-light opacity-75">
|
||||
<span class="fw-bold">${versionText}</span>
|
||||
<span class="mx-1">@</span><code class="text-light bg-transparent border-0 p-0" style="font-size: 0.8rem;">${commitHash}</code>
|
||||
${isDirty ? '<span class="badge bg-warning text-dark ms-1 px-1" style="font-size: 0.6rem;">*</span>' : ''}
|
||||
</small>
|
||||
`;
|
||||
|
||||
// Insert version info between brand and nav items
|
||||
const navScroll = navbarContainer.querySelector('.td-navbar-nav-scroll');
|
||||
if (navScroll) {
|
||||
navbarContainer.insertBefore(versionDiv, navScroll);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{{ end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue