diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-09-18 22:05:48 +0200 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-09-18 22:05:48 +0200 |
| commit | 74cd345f76dd01034c804f75e7f16b42e9c0643c (patch) | |
| tree | b1105460df469168e052ec278bbb9b96a829ca33 /g2h/file.py | |
| parent | f2056d0a59cd7234610dd7da1ea2c3e2a4be0f00 (diff) | |
| download | git2hugo-74cd345f76dd01034c804f75e7f16b42e9c0643c.tar.gz | |
g2h: Add breadcrumb navigations to file and tree pages
Diffstat (limited to 'g2h/file.py')
| -rw-r--r-- | g2h/file.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/g2h/file.py b/g2h/file.py index 8f683cd..e07f251 100644 --- a/g2h/file.py +++ b/g2h/file.py @@ -1,5 +1,16 @@ import os +def generate_breadcrumbs(content_subdir, commit, dir, files): + breadcrumbs = '[/](/{})'.format(os.path.join(content_subdir, tree_join(commit, ''))) + subpath = '' + for segment in dir.split(os.sep): + if not segment or len(segment) == 0: + continue + subpath = os.path.join(subpath, sanitize_file_name(segment, files)) + breadcrumbs += '/[{}](/{})'.format(segment, os.path.join(content_subdir, tree_join(commit, subpath))) + return breadcrumbs + + def sanitize_file_name(file_name, files): if not file_name.startswith('.'): return file_name |