Skip to content

Commit

Permalink
mv navigation logic out of config.toml
Browse files Browse the repository at this point in the history
advantage of having it outside is that changes
can be previewed immediately
  • Loading branch information
bast committed Nov 19, 2024
1 parent cce5f4d commit c1ff21f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
12 changes: 0 additions & 12 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,4 @@ highlight_theme = "cheerfully-light"

[extra]

navigation = [
{ name = "Home", target = "/" },
{ name = "About us", target = "/about/" },
{ name = "Vision", target = "/vision/" },
{ name = "Courses", target = "/courses/" },
{ name = "Resources", target = "/resources/" },
{ name = "Projects", target = "/projects/" },
{ name = "Blog", target = "/blog/" },
{ name = "Testimonials", target = "/testimonials/" },
{ name = "Contact", target = "/contact/" },
]

twitter_image = "https://raw.githubusercontent.com/uit-no/rse/main/content/logo1.png"
19 changes: 19 additions & 0 deletions content/navigation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
navigation:
- name: Home
target: /
- name: About us
target: /about/
- name: Vision
target: /vision/
- name: Courses
target: /courses/
- name: Resources
target: /resources/
- name: Projects
target: /projects/
- name: Blog
target: /blog/
- name: Testimonials
target: /testimonials/
- name: Contact
target: /contact/
32 changes: 16 additions & 16 deletions templates/navigation.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{% set data = load_data(path="content/navigation.yml") %}

<nav class="uk-navbar-container uk-navbar-transparent" uk-navbar>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav uk-visible@s">
{% for item in config.extra.navigation %}
{% if item.target is starting_with("http") %}
<li><a href="{{ item.target }}" target="_blank">{{ item.name }}</a></li>
{% else %}
<li><a href="{{ get_url(path=item.target) }}">{{ item.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
<a href="#" class="uk-navbar-toggle uk-hidden@s" uk-navbar-toggle-icon uk-toggle="target: #sidenav"></a>
</div>
<ul class="uk-navbar-nav uk-visible@s">
{% for link in data.navigation %}
{% if link.target is starting_with("http") %}
<li><a href="{{ link.target }}" target="_blank">{{ link.name }}</a></li>
{% else %}
<li><a href="{{ get_url(path=link.target) }}">{{ link.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
<a href="#" class="uk-navbar-toggle uk-hidden@s" uk-navbar-toggle-icon uk-toggle="target: #sidenav"></a>
</nav>

<div id="sidenav" uk-offcanvas="flip: true" class="uk-offcanvas">
<div class="uk-offcanvas-bar">
<ul class="uk-nav">
{% for item in config.extra.navigation %}
{% if item.target is starting_with("http") %}
<li><a href="{{ item.target }}" target="_blank">{{ item.name }}</a></li>
{% for link in data.navigation %}
{% if link.target is starting_with("http") %}
<li><a href="{{ link.target }}" target="_blank">{{ link.name }}</a></li>
{% else %}
<li><a href="{{ get_url(path=item.target) }}">{{ item.name }}</a></li>
<li><a href="{{ get_url(path=link.target) }}">{{ link.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
Expand Down

0 comments on commit c1ff21f

Please sign in to comment.