aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeikka Kähkönen <veikka.kahkonen@corefactory.com>2017-08-29 20:53:49 +0300
committerVeikka Kähkönen <veikka.kahkonen@corefactory.com>2017-08-29 20:53:49 +0300
commita7564f0f846b2065099e62010e42419bf8f4bf1a (patch)
treeb51c7611f5e7328e4f7d2103637df041ba757264
parent496c7ae5ed5adb81e8a4d013b7cd7120b9cb62c7 (diff)
Add configurable navigation
-rw-r--r--_data/navi.yaml36
-rw-r--r--_includes/header.html37
-rw-r--r--_sass/_as-theme.scss7
3 files changed, 72 insertions, 8 deletions
diff --git a/_data/navi.yaml b/_data/navi.yaml
new file mode 100644
index 0000000..a316b14
--- /dev/null
+++ b/_data/navi.yaml
@@ -0,0 +1,36 @@
+items:
+ - title: Etusivu
+ href: /
+ - title: Kilta
+ href: /kilta
+ subnavi:
+ directory: kilta
+ items:
+ - title: Hallitus
+ href: hallitus.html
+ - title: Toimihenkilöt
+ href: toimihenkilot.html
+ - title: Viestintä
+ href: viestinta.html
+ - title: Jäsenyys
+ href: jasenyys.html
+ - title: Aski
+ href: aski.html
+ - title: Halloped
+ href: halloped.html
+ - title: GT
+ href: gt.html
+ #- title: Säätökerho
+ # href: saatokerho.html
+ - title: Opiskelu
+ href: /opiskelu.html
+ - title: Uudet opiskelijat
+ href: /phuksit.html
+ - title: Tapahtumat
+ href: /tapahtumat.html
+ - title: Yrityksille
+ href: /yrityksille.html
+ - title: Yhteystiedot
+ href: /yhteystiedot.html
+ - title: In English
+ href: /in-english.html
diff --git a/_includes/header.html b/_includes/header.html
index 813ff45..7a8b616 100644
--- a/_includes/header.html
+++ b/_includes/header.html
@@ -8,17 +8,38 @@
</h1>
</div>
<nav class="navigation header__navigation">
+ {% assign url_tokens = page.url | split: '/' %}
+ {% assign main_page_href = '/' | append: url_tokens[1] %}
+ {% assign subpage_href = url_tokens[2] %}
<ul>
- <li class="navigation__item"><a href="{{ '/' | prepend: site.baseurl}}">Etusivu</a></li>
- <li class="navigation__item"><a href="{{ '/kilta/' | prepend: site.baseurl }}">Kilta</a></li>
- <li class="navigation__item"><a href="{{ '/opiskelu/' | prepend: site.baseurl }}">Opiskelu</a></li>
- <li class="navigation__item"><a href="{{ '/phuksit/' | prepend: site.baseurl }}">Uudet opiskelijat</a></li>
- <li class="navigation__item"><a href="{{ '/tapahtumat/' | prepend: site.baseurl }}">Tapahtumat</a></li>
- <li class="navigation__item"><a href="{{ '/yrityksille/' | prepend: site.baseurl }}">Yrityksille</a></li>
- <li class="navigation__item"><a href="{{ '/yhteystiedot/' | prepend: site.baseurl }}">Yhteystiedot</a></li>
- <li class="navigation__item"><a href="{{ '/in-english/' | prepend: site.baseurl }}">In English</a></li>
+ {% if site.data.navi.items[0] %}
+ {% for item in site.data.navi.items %}
+ {% if item.href == main_page_href or item.href == main_page_href | concat: '/' %}
+ {% assign current_page = true %}
+ {% else %}
+ {% assign current_page = false %}
+ {% endif %}
+ <li class="navigation__item {% if current_page %}active{% endif %}">
+ <a href="{{ item.href }}">{{ item.title }}</a>
+ </li>
+ {% if current_page and item.subnavi %}
+ {% assign subnavi = item.subnavi %}
+ {% endif %}
+ {% endfor %}
+ {% endif %}
</ul>
</nav>
+ {% if subnavi %}
+ <nav id="navigation_sub" class="navigation header__navigation">
+ <ul>
+ {% for subitem in subnavi.items %}
+ <li class="navigation__item {% if subitem.href == subpage_href %}active{% endif %}">
+ <a href="{{ subitem.href }}">{{ subitem.title }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </nav>
+ {% endif %}
diff --git a/_sass/_as-theme.scss b/_sass/_as-theme.scss
index e17f605..119a6f3 100644
--- a/_sass/_as-theme.scss
+++ b/_sass/_as-theme.scss
@@ -78,6 +78,13 @@ body {
}
}
+.navigation__item.active {
+ font-weight: bold;
+}
+
+.navigation__item.active a {
+ color: $purple-color;
+}
.header__title {
padding-top: $spacing-unit/4;
padding-bottom: $spacing-unit/4;