summaryrefslogtreecommitdiffstats
path: root/g2h/file.py
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-09-18 22:05:48 +0200
committerChristoph Schlosser <christoph@linux.com>2025-09-18 22:05:48 +0200
commit74cd345f76dd01034c804f75e7f16b42e9c0643c (patch)
treeb1105460df469168e052ec278bbb9b96a829ca33 /g2h/file.py
parentf2056d0a59cd7234610dd7da1ea2c3e2a4be0f00 (diff)
downloadgit2hugo-74cd345f76dd01034c804f75e7f16b42e9c0643c.tar.gz
g2h: Add breadcrumb navigations to file and tree pages
Diffstat (limited to 'g2h/file.py')
-rw-r--r--g2h/file.py11
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