~xdavidwu/xdavidwu.link

f4869f79c44fe13e046a085315e431604ebff7fa — Michael Rose 9 years ago cf086c3
Use data file to maintain site navigation
- Remove top navigation links from _config.yml
3 files changed, 21 insertions(+), 16 deletions(-)

M _config.yml
A _data/navigation.yml
M _includes/_navigation.html
M _config.yml => _config.yml +0 -13
@@ 32,19 32,6 @@ google_verify:
# https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here
bing_verify:

# Links to include in top navigation
# For external links add external: true
links:
  - title: About
    url: /about/
  - title: Posts
    url: /posts/
  - title: Theme Setup
    url: /theme-setup/
  - title: Made Mistakes
    url: http://mademistakes.com
    external: true

# http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone:    America/New_York
future:      true

A _data/navigation.yml => _data/navigation.yml +13 -0
@@ 0,0 1,13 @@
# Site navigation links

- title: About
  url: /about/

- title: Sample Posts
  url: /posts/

- title: Theme Setup
  url: /theme-setup/

- title: Made Mistakes
  url: http://mademistakes.com
\ No newline at end of file

M _includes/_navigation.html => _includes/_navigation.html +8 -3
@@ 5,9 5,14 @@
	<div class="top-navigation">
		<nav role="navigation" id="site-nav" class="nav">
		    <ul>
		        {% for link in site.links %}
				<li><a href="{% if link.external %}{{ link.url }}{% else %}{{ site.url }}{{ link.url }}{% endif %}" {% if link.external %}target="_blank"{% endif %}>{{ link.title }}</a></li>
		        {% endfor %}
		        {% for link in site.data.navigation %}
					    {% if link.url contains 'http' %}
					        {% assign domain = '' %}
					        {% else %}
					        {% assign domain = site.url %}
					    {% endif %}
					    <li><a href="{{ domain }}{{ link.url }}" {% if link.url contains 'http' %}target="_blank"{% endif %}>{{ link.title }}</a></li>
					  {% endfor %}
		    </ul>
		</nav>
	</div><!-- /.top-navigation -->