From 9e17a45c5513d22d3c964b8ccf041f86488d51f1 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Mon, 18 Nov 2024 04:24:59 +0100 Subject: [PATCH] navigation should not be defined in config.toml it moves to content/navigation.yml advantage: changes affect immediate reload when previewing --- config.toml | 44 ------------------- content/navigation.yml | 75 +++++++++++++++++++++++++++++++++ templates/navigation-logic.html | 18 ++++---- 3 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 content/navigation.yml diff --git a/config.toml b/config.toml index 8bf792c9..f1f4eee5 100644 --- a/config.toml +++ b/config.toml @@ -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 diff --git a/content/navigation.yml b/content/navigation.yml new file mode 100644 index 00000000..223b86fc --- /dev/null +++ b/content/navigation.yml @@ -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/ diff --git a/templates/navigation-logic.html b/templates/navigation-logic.html index 34377f66..0e6d60a9 100644 --- a/templates/navigation-logic.html +++ b/templates/navigation-logic.html @@ -1,19 +1,21 @@ -{% for item in config.extra.navigation %} +{% set data = load_data(path="content/navigation.yml") %} + +{% for link in data.navigation %}
  • {% 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 %} - {{ item.name }} + {{ link.name }} {% if contains_dropdown %} {% endif %} @@ -24,7 +26,7 @@