Skip to content

Commit

Permalink
navigation should not be defined in config.toml
Browse files Browse the repository at this point in the history
it moves to content/navigation.yml
advantage: changes affect immediate reload when previewing
  • Loading branch information
bast committed Nov 18, 2024
1 parent 9516a74 commit 9e17a45
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 52 deletions.
44 changes: 0 additions & 44 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,3 @@ twitter_image = "https://raw.githubusercontent.com/coderefinery/coderefinery-art
twitter_image_alt = "CodeRefinery. Teaching good-enough practices for comutational research. Workshops as open as your science should be."

plausible = { src = "https://plausible.cs.aalto.fi/js/script.js", domain = "coderefinery.org", github_ref = "refs/heads/main" }

navigation = [
{ name = "Home", target = "/" },
{ name = "Lessons", target = "/lessons/", items = [
{ name = "CodeRefinery lessons", target = "/lessons/" },
{ name = "Reusing", target = "/lessons/reusing/" },
{ name = "Other lessons we recommend", target = "/lessons/other/" },
] },
{ name = "Workshops and events", target = "/workshops/", items = [
{ name = "Upcoming and recent", target = "/workshops/upcoming/" },
{ name = "Past", target = "/workshops/past/" },
{ name = "The CodeRefinery teaching style", target = "/workshops/teaching-style/" },
{ name = "Request or run your own", target = "/workshops/request/" },
] },
{ name = "Tasks/roadmap", target = "/tasks/" },
{ name = "Join", target = "/join/", items = [
{ name = "Chat", target = "/join/chat/" },
{ name = "For individuals", target = "/join/individuals/" },
{ name = "For staff", target = "/join/staff/" },
{ name = "For organizations", target = "/join/organizations/" },
{ name = "Community teaching training", target = "/join/community-teaching-training/" },
{ name = "Meetings", target = "/join/meetings/" },
{ name = "Calendars", target = "/calendars/" },
{ name = "The CodeRefinery community", target = "/about/contributors/" },
{ name = "Code of conduct", target = "/about/code-of-conduct/" },
] },
{ name = "About", target = "/about/", items = [
{ name = "Project", target = "/about/project/" },
{ name = "History", target = "/about/history/" },
{ name = "The CodeRefinery community", target = "/about/contributors/" },
{ name = "Partners and sponsors", target = "/about/partners/" },
{ name = "Impact", target = "/about/impact/" },
{ name = "Statistics", target = "/about/statistics/" },
{ name = "Presentations", target = "/about/presentations/" },
{ name = "Articles and reports", target = "/about/reports/" },
{ name = "Newsletter", target = "/about/newsletter/" },
{ name = "Operations manuals (external link)", target = "https://coderefinery.github.io/manuals/" },
{ name = "Contact", target = "/about/contact/" },
] },
{ name = "News/blog", target = "/blog/" },
{ name = "GitLab repository", target = "/repository/" },
]

# search_engine_exclude = true
75 changes: 75 additions & 0 deletions content/navigation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
navigation:
- name: Home
target: /
- name: Lessons
target: /lessons/
items:
- name: CodeRefinery lessons
target: /lessons/
- name: Reusing
target: /lessons/reusing/
- name: Other lessons we recommend
target: /lessons/other/
- name: Workshops and events
target: /workshops/
items:
- name: Upcoming and recent
target: /workshops/upcoming/
- name: Past
target: /workshops/past/
- name: The CodeRefinery teaching style
target: /workshops/teaching-style/
- name: Request or run your own
target: /workshops/request/
- name: Tasks/roadmap
target: /tasks/
- name: Join
target: /join/
items:
- name: Chat
target: /join/chat/
- name: For individuals
target: /join/individuals/
- name: For staff
target: /join/staff/
- name: For organizations
target: /join/organizations/
- name: Community teaching training
target: /join/community-teaching-training/
- name: Meetings
target: /join/meetings/
- name: Calendars
target: /calendars/
- name: The CodeRefinery community
target: /about/contributors/
- name: Code of conduct
target: /about/code-of-conduct/
- name: About
target: /about/
items:
- name: Project
target: /about/project/
- name: History
target: /about/history/
- name: The CodeRefinery community
target: /about/contributors/
- name: Partners and sponsors
target: /about/partners/
- name: Impact
target: /about/impact/
- name: Statistics
target: /about/statistics/
- name: Presentations
target: /about/presentations/
- name: Articles and reports
target: /about/reports/
- name: Newsletter
target: /about/newsletter/
- name: Operations manuals (external link)
target: https://coderefinery.github.io/manuals/
- name: Contact
target: /about/contact/
- name: News/blog
target: /blog/
- name: GitLab repository
target: /repository/
18 changes: 10 additions & 8 deletions templates/navigation-logic.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{% for item in config.extra.navigation %}
{% set data = load_data(path="content/navigation.yml") %}

{% for link in data.navigation %}
<li>

{% set href = "#" %}
{% if item.target is defined %}
{% if item.target is starting_with("http") %}
{% set href = item.target %}
{% if link.target is defined %}
{% if link.target is starting_with("http") %}
{% set href = link.target %}
{% else %}
{% set href = get_url(path=item.target) %}
{% set href = get_url(path=link.target) %}
{% endif %}
{% endif %}

{% set contains_dropdown = item.items is defined %}
{% set contains_dropdown = link.items is defined %}

<a href="{{ href }}">
{{ item.name }}
{{ link.name }}
{% if contains_dropdown %}
<span uk-navbar-parent-icon></span>
{% endif %}
Expand All @@ -24,7 +26,7 @@
<div class="uk-navbar-dropdown">
{% endif %}
<ul class="uk-nav uk-navbar-dropdown-nav">
{% for subitem in item.items %}
{% for subitem in link.items %}
<li>
{% if subitem.target is starting_with("http") %}
<a href="{{ subitem.target }}" target="_blank">{{ subitem.name }}</a>
Expand Down

0 comments on commit 9e17a45

Please sign in to comment.