Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce taxonomy equivalent of menu map #1187

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common-docs/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title="Help us doc!"
description="This is a [🅷🆄🅶🅾](https://gohugo.io/)-based platform called [🌱common](https://github.com/CodeYourFuture/curriculum/tree/main/common-theme)"
map=["theme", "content", "community"]
menus_to_map=["theme", "content", "community"]
menu=["syllabus"]
+++
7 changes: 5 additions & 2 deletions common-docs/content/common-theme/front-matter/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ src="common-theme/front-matter/blocks/blocks"
name="Emoji"
src="common-theme/front-matter/blocks/emoji"
[[blocks]]
name="Map"
src="common-theme/front-matter/blocks/map"
name="Taxonomy map"
src="common-theme/front-matter/blocks/taxonomy-map"
[[blocks]]
name="Menu map"
src="common-theme/front-matter/blocks/menu-map"
[[blocks]]
name="Menus, menu_level"
src="common-theme/front-matter/blocks/menu"
Expand Down
17 changes: 0 additions & 17 deletions common-docs/content/common-theme/front-matter/blocks/map/index.md
Original file line number Diff line number Diff line change
@@ -1,17 +0,0 @@
+++
title = 'Map'
time = 2
emoji= '🗺️'
[build]
render = 'never'
list = 'local'
publishResources = false
+++

A map is an ordered slice of menus. It's to show a "map" view of the syllabus, broken down into grouped modules. As with everything in this design, the point is to clarify what happens and in what order.

It's just for the index page, and the front matter is a list of the menu names that should be included in the map, in the order they should appear.

```toml
map = ["menuName", "menuName"]
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
+++
title = 'Menu map'
time = 2
emoji= '🗺️'
[build]
render = 'never'
list = 'local'
publishResources = false
+++

A menu map is an ordered slice of menus. It's to show a "map" view of the syllabus, broken down into grouped modules. As with everything in this design, the point is to clarify what happens and in what order.

It's just for the index page, and the front matter is a list of the menu names that should be included in the map, in the order they should appear.

If you want to attach metadata to each menu item (e.g. to add a description), you probably want a Taxonomy map.

```toml
menus_to_map = ["menuName", "menuName"]
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
+++
title = 'Taxonomy map'
time = 2
emoji= '🗺️'
[build]
render = 'never'
list = 'local'
publishResources = false
+++

A taxonomy map is an ordered slice of terms within a taxonomy. It's to show a "map" view of the syllabus, broken down into grouped modules, with extra per-module metadata attached to the term. As with everything in this design, the point is to clarify what happens and in what order.

It's just for the index page, and the front matter is a list of the menu names that should be included in the map, in the order they should appear.

```toml
taxonomy_to_map = "modules"
```
6 changes: 5 additions & 1 deletion common-theme/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
{{ . }}
</section>
{{ end }}
{{ if .Params.map }}
{{ if .Params.menus_to_map }}
{{ partial "map-menu.html" .Params.menus_to_map }}
{{ else if .Params.map }}
illicitonion marked this conversation as resolved.
Show resolved Hide resolved
{{ partial "map.html" . }}
illicitonion marked this conversation as resolved.
Show resolved Hide resolved
{{ else if .Params.taxonomy_to_map }}
{{ partial "map-taxonomy.html" .Params.taxonomy_to_map }}
{{ else }}
<ol class="c-timeline c-timeline--card">
{{- range site.Menus.syllabus }}
Expand Down
2 changes: 1 addition & 1 deletion common-theme/layouts/partials/card.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ $BaseURL := .Page.Parent.Permalink }}
<a class="c-card" href="{{ relURL .URL }}">
<a class="c-card" href="{{ relURL .Page.RelPermalink }}">
<h3 class="c-card__title">{{ .Name }}</h3>
{{ with .Page.Description }}
<p class="c-card__description">{{ . }}</p>
Expand Down
34 changes: 34 additions & 0 deletions common-theme/layouts/partials/map-common.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{/*
Expects a slice[dict] param containing an ordered list of dicts with the following keys, one per section in the map to render:
* title (string) - The heading to display for the section.
* values (slice[Page]) - A slice of Pages, one per page in the section which should be listed.
*/}}

<div class="c-map">
<h1 class="e-heading c-map__start is-none--lt-container">👉🏾</h1>
{{ range $i, $section := index . "sections" }}
{{ $sectionTitle := index $section "title" }}
{{ $sectionValues := index $section "values" }}
<section class="c-map__block">
<h2 class="e-heading c-map__title">
📍{{ $i }}:
{{ $sectionTitle }}
</h2>
<ol class="c-map__timeline">
{{/* Check if a menu for the current map section exists */}}
{{ if $sectionValues }}
{{/* Range over the items in the menu */}}
{{ range $iterator, $module := $sectionValues }}
<li
class="c-map__stop"
style="--layer:{{ sub (len $sectionValues) (add $iterator 1) }}">
{{ partial "card.html" $module }}
</li>
{{ end }}
{{ else }}
<li>No items found for {{ $sectionTitle }}</li>
{{ end }}
</ol>
</section>
{{ end }}
</div>
12 changes: 12 additions & 0 deletions common-theme/layouts/partials/map-menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{/* Expects slice[string] param which is the name of the menus to render as sections. */}}

{{ $sections := slice }}

{{ range $menuName := . }}
{{ $section := dict "title" $menuName "values" (index site.Menus $menuName) }}
{{ $sections = append $section $sections }}
{{ end }}

{{ $params := dict "sections" $sections }}

{{ partial "map-common.html" $params }}
20 changes: 20 additions & 0 deletions common-theme/layouts/partials/map-taxonomy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{/* Expects string param which is the (plural) name of the taxonomy to render. */}}

{{ $taxonomy_to_map := . }}

{{ $sections := slice }}

{{/* You can't ask for a taxonomy to be sorted by weight, so we need to get weights and iterate ourselves - see https://discourse.gohugo.io/t/list-custom-taxonomy-terms-in-a-specific-order-not-alphabetical/18145/5 */}}
{{ $terms := site.GetPage (printf "/%s" $taxonomy_to_map) }}
{{ range $termPage := $terms.Pages.ByWeight }}
{{ $termID := path.BaseName $termPage.Path }}
{{ $termTitle := $termPage.Title }}
{{ $values := index (index site.Taxonomies $taxonomy_to_map) $termID }}

{{ $section := dict "title" $termTitle "values" $values }}
{{ $sections = append $section $sections }}
{{ end }}

{{ $params := dict "sections" $sections }}

{{ partial "map-common.html" $params }}
34 changes: 5 additions & 29 deletions common-theme/layouts/partials/map.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
{{ with .Params.map }}
<div class="c-map">
<h1 class="e-heading c-map__start is-none--lt-container">👉🏾</h1>
{{ range $i, $currentMapSectionName := . }}
{{ $currentMapSectionModules := index site.Menus $currentMapSectionName }}
<section class="c-map__block">
<h2 class="e-heading c-map__title">
📍{{ $i }}:
{{ $currentMapSectionName }}
</h2>
<ol class="c-map__timeline">
{{/* Check if a menu for the current map section exists */}}
{{ if $currentMapSectionModules }}
{{/* Range over the items in the menu */}}
{{ range $iterator, $module := $currentMapSectionModules }}
<li
class="c-map__stop"
style="--layer:{{ sub (len $currentMapSectionModules) (add $iterator 1) }}">
{{ partial "card.html" $module }}
</li>
{{ end }}
{{ else }}
<li>No items found for {{ $currentMapSectionName }}</li>
{{ end }}
</ol>
</section>
{{ end }}
</div>
{{ end }}
{{/* Expects Page as a param, and that the page will have a .Params.map which contains a slice[string] of menus to render as sections. */}}

{{/* This is legacy support which we will deprecate at some point. */}}
{{ warnf "Using the map param is deprecated - rename this param to menus_to_map" }}
{{ partial "map-menu.html" .Params.map }}
2 changes: 1 addition & 1 deletion org-cyf-guides/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ description = 'A collection of guides, references, resources that do not belong
emoji= '📚'
menu=["syllabus"]
weight=1
map=['volunteers', 'learners', 'everyone']
menus_to_map=['volunteers', 'learners', 'everyone']
+++
2 changes: 1 addition & 1 deletion org-cyf-itd/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
title="Intro to Digital"
description="How to participate in the Intro to Digital programme as a learner or teacher"
menu="main"
map=['start here', 'steps', 'workshops']
menus_to_map=['start here', 'steps', 'workshops']
+++
2 changes: 1 addition & 1 deletion org-cyf-itp/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title="Intro to Programming"
map=["start here", "programming", "next steps"]
menus_to_map=["start here", "programming", "next steps"]
description="New? Lost? [Quickstart](how-this-works/prep/#overview)"
emoji= "🧑🏿‍🏫"
+++
2 changes: 1 addition & 1 deletion org-cyf-piscine/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ description = 'In teams and on your own, build working software with tests. Expl
layout = 'module'
emoji= '🐠'
menu = ['syllabus', 'next steps']
map=['entry', 'sprints', 'assessment']
menus_to_map=['entry', 'sprints', 'assessment']
+++
2 changes: 1 addition & 1 deletion org-cyf-tracks/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title="Tracks"
map=["start here", "from itp", "from sdc"]
taxonomy_to_map = "track_kinds"
description="Short, focused courses walking you towards specific careers"
emoji= "👣"
+++
2 changes: 1 addition & 1 deletion org-cyf-tracks/content/cloud/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title = 'Cloud'
description = 'Deploy and manage cloud infrastructure; explore containers, pipelines, load balancing, traffic, integration and security; define infrastructure as code'
layout = 'module'
emoji= '☁️'
menu = 'from sdc'
track_kinds = ["jobs-after-sdc"]
+++
2 changes: 1 addition & 1 deletion org-cyf-tracks/content/coming-soon/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title = 'Coming Soon'
description = 'ITP tracks are coming soon...'
layout = 'module'
emoji= '👷🏽‍♀️'
menu = "from itp"
track_kinds = ["jobs-after-itp"]
+++

## In development:
Expand Down
2 changes: 1 addition & 1 deletion org-cyf-tracks/content/portfolio/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ title = 'Portfolio'
description = 'Build great projects; work in teams; polish our profiles; get great jobs in tech'
layout = 'module'
emoji= '🧑🏾‍🚀'
menu = 'from sdc'
track_kinds = ["jobs-after-sdc"]
+++
2 changes: 1 addition & 1 deletion org-cyf-tracks/content/react/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ title = 'React'
description = 'Explore frameworks, libraries, and declarative programming with React; Develop unit testing with Testing Library; Build a dynamic web application in an Agile team'
layout = 'module'
emoji= '🪄'
menu = 'from sdc'
track_kinds = ["self-study"]
weight='6'
+++
4 changes: 4 additions & 0 deletions org-cyf-tracks/content/track_kinds/jobs-after-itp/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
title = "Jobs after ITP"
weight = 2
+++
4 changes: 4 additions & 0 deletions org-cyf-tracks/content/track_kinds/jobs-after-sdc/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
title = "Jobs after SDC"
weight = 3
+++
4 changes: 4 additions & 0 deletions org-cyf-tracks/content/track_kinds/self-study/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
title = "Self-study"
weight = 1
+++
3 changes: 3 additions & 0 deletions org-cyf-tracks/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ baseURL = "https://tracks.codeyourfuture.io/"
[[module.imports.mounts]]
source = "content"
target = "content/how-this-works"

[taxonomies]
track_kind = "track_kinds"
2 changes: 1 addition & 1 deletion org-cyf/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title="Our Courses"
map=["start here", "selection", "trainees", "fellowships"]
menus_to_map=["start here", "selection", "trainees", "fellowships"]
description="Free training for good jobs in tech [📅 2024/25](https://docs.google.com/spreadsheets/d/1qNxf44_vbNKU1KeFozGX7Kt1QxmTtU6Bf9tOh1sTUuc/edit?gid=1346767713#gid=1346767713)"
emoji= "🧑🏿‍🏫👨🏽‍🎓"
+++
Loading