Skip to content

Commit

Permalink
feat: add key setting for navigation.header and nav_key setting f…
Browse files Browse the repository at this point in the history
…or page layout, resolve kitian616#127
  • Loading branch information
kitian616 committed Jan 11, 2019
1 parent 492be40 commit 05f3ee7
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 32 deletions.
6 changes: 3 additions & 3 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
{%- include snippets/get-nav-url.html path=page.url -%}
{%- assign _page_url = __return -%}
{%- include snippets/get-string-from-locale-config.html locale=_item.titles -%}
{%- if _nav_url == _page_url -%}
<li class="navigation__link navigation__link--active"><a href="{{ _nav_url }}">{%- if _item.title -%}{{ _item.title }}{%- else -%}{{ __return }}{%- endif -%}</a></li>
{%- if _nav_url == _page_url or page.nav_key and _item.key and page.nav_key == _item.key -%}
<li class="navigation__item navigation__item--active"><a href="{{ _nav_url }}">{%- if _item.title -%}{{ _item.title }}{%- else -%}{{ __return }}{%- endif -%}</a></li>
{%- else -%}
<li class="navigation__link"><a href="{{ _nav_url }}">{%- if _item.title -%}{{ _item.title }}{%- else -%}{{ __return }}{%- endif -%}</a></li>
<li class="navigation__item"><a href="{{ _nav_url }}">{%- if _item.title -%}{{ _item.title }}{%- else -%}{{ __return }}{%- endif -%}</a></li>
{%- endif -%}
{%- endfor -%}
{%- if site.search.provider -%}
Expand Down
43 changes: 27 additions & 16 deletions _sass/components/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@
.header--dark {
@extend .text--dark;
background: rgba(#000, .15);
.navigation__item--active {
&::after {
@include split-line(bottom, 4px, $text-color-theme-dark);
}
}
}

.header--light {
@extend .text--light;
background: rgba(#fff, .15);
.navigation__item--active {
&::after {
@include split-line(bottom, 4px, $text-color-theme-light);
}
}
}

.header__title {
Expand Down Expand Up @@ -89,21 +99,22 @@
display: none;
}
}
.navigation__link {
&::after {
display: block;
margin-bottom: -4px;
content: "";
@include split-line(bottom, 4px, transparent);
}
}
.navigation__link--active {
a {
@include link-colors($main-color-1, $main-color-1);
}
&::after {
@include split-line(bottom, 4px, $main-color-1);
}
}
}
}

.navigation__item {
&::after {
display: block;
margin-bottom: -4px;
content: "";
@include split-line(bottom, 4px, transparent);
}
}
.navigation__item--active {
a {
@include link-colors($main-color-1, $main-color-1);
}
&::after {
@include split-line(bottom, 4px, $main-color-1);
}
}
24 changes: 19 additions & 5 deletions docs/_config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,21 @@ collections_dir: docs
collections:
docs:
output: true
page:
sample_page:
output: true
articles:
sample_articles:
output: true
languages:
sample_languages:
output: true

defaults:
## home
- scope:
path: "test"
values:
articles:
excerpt_type: html
## posts
- scope:
path: ""
type: posts
Expand All @@ -231,20 +233,31 @@ defaults:
show_subscribe: true
pageview: true
lightbox: true
## samples
- scope:
path: ""
type: articles
type: sample_page
values:
nav_key: samples
- scope:
path: ""
type: sample_articles
values:
nav_key: samples
show_date: false
- scope:
path: ""
type: languages
type: sample_languages
values:
layout: article
nav_key: samples
show_date: false
## docs
- scope:
path: "_docs/en"
values:
layout: article
nav_key: docs
sidebar:
nav: docs-en
license: true
Expand All @@ -257,6 +270,7 @@ defaults:
path: "_docs/zh"
values:
layout: article
nav_key: docs
sidebar:
nav: docs-zh
license: true
Expand Down
24 changes: 19 additions & 5 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,21 @@ collections_dir: docs
collections:
docs:
output: true
page:
sample_page:
output: true
articles:
sample_articles:
output: true
languages:
sample_languages:
output: true

defaults:
## home
- scope:
path: "test"
values:
articles:
excerpt_type: html
## posts
- scope:
path: ""
type: posts
Expand All @@ -233,20 +235,31 @@ defaults:
show_subscribe: true
pageview: true
# lightbox: true
## samples
- scope:
path: ""
type: articles
type: sample_page
values:
nav_key: samples
- scope:
path: ""
type: sample_articles
values:
nav_key: samples
show_date: false
- scope:
path: ""
type: languages
type: sample_languages
values:
layout: article
nav_key: samples
show_date: false
## docs
- scope:
path: "_docs/en"
values:
layout: article
nav_key: docs
sidebar:
nav: docs-en
license: true
Expand All @@ -259,6 +272,7 @@ defaults:
path: "_docs/zh"
values:
layout: article
nav_key: docs
sidebar:
nav: docs-zh
license: true
Expand Down
2 changes: 2 additions & 0 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ header:
url: /test/
- title: Docs
url: /docs/en/quick-start
key: docs
- title: Samples
url: /samples.html
key: samples
- title: Archive
url: /archive.html
- title: About
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/samples.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<div class="layout--articles">
<section class="my-5">
<header><h2 id="page-layout">Page Layout</h2></header>
{%- include article-list.html articles=site.page type='grid' -%}
{%- include article-list.html articles=site.sample_page type='grid' -%}
</section>

<section class="my-5">
<header><h2 id="articles-layout">Articles(Home) Layout</h2></header>
{%- include article-list.html articles=site.articles type='grid' -%}
{%- include article-list.html articles=site.sample_articles type='grid' -%}
</section>

<section class="my-5">
<header><h2 id="languages">Languages</h2></header>
{%- include article-list.html articles=site.languages type='grid' size='sm' -%}
{%- include article-list.html articles=site.sample_languages type='grid' size='sm' -%}
</section>
</div>

0 comments on commit 05f3ee7

Please sign in to comment.