Browse Source

Change style of deactivated nav link

This is the link for the current page.
master
Andreas Linz 2 years ago
parent
commit
b2b1cb8e46
Signed by: alinz GPG Key ID: 9BF39809C9DA580C
2 changed files with 18 additions and 6 deletions
  1. +9
    -3
      build/klingt.net/assets/tiny.css
  2. +9
    -3
      build/klingt.net/template.py

+ 9
- 3
build/klingt.net/assets/tiny.css View File

@ -33,13 +33,19 @@ nav ul {
nav ul li {
margin: 0 0 .333em 0;
padding: .15em 0;
}
.nav-item {
text-transform: capitalize;
text-transform: capitalize;
}
a.nav-item-deactivated {
color: lightseagreen;
pointer-events: none;
}
.logo {
width: 3em;
margin: 1.5em auto;
width: 3em;
margin: 1.5em auto;
}

+ 9
- 3
build/klingt.net/template.py View File

@ -11,13 +11,19 @@ def title_from_filename(fname: str) -> str:
return os.path.splitext(fname)[0].replace('-', ' ')
def nav_item(page, current_page):
nav_item = '<li><a href="{item_href}" class="{classes}" disabled>{item_text}</a></li>'
a_classes = ['nav-item']
if page == current_page:
a_classes.append('nav-item-deactivated')
return nav_item.format(item_href=page, item_text=title_from_filename(page), classes=' '.join(a_classes))
def template_pages(pages: dict, template: str, dest_path: str):
nav_item = '<li><a href="{item_href}" class="nav-item">{item_text}</a></li>'
for page, text in pages.items():
title = title_from_filename(page)
other_pages = [ p for p in pages.keys() if p != page ]
nav = ''.join([ nav_item.format(item_href=p, item_text=title_from_filename(p)) for p in other_pages ])
nav = ''.join([ nav_item(p, page) for p in pages])
templated_page = template.format(title=title, nav=nav, content=text)
with open(os.path.join(dest_path, page), 'w') as f:

Loading…
Cancel
Save