From: Ralf Jung Date: Wed, 7 Oct 2015 14:44:03 +0000 (+0200) Subject: use the Jekyll pages information to create the menu X-Git-Url: https://git.ralfj.de/web.git/commitdiff_plain/bc8bbcf168afb52ec0bdd219122e8b817c361468?ds=sidebyside;hp=e8acdb6709352f474fd6855afc62044798388bcc use the Jekyll pages information to create the menu --- diff --git a/_config.yml b/_config.yml index be1260f..83ead92 100644 --- a/_config.yml +++ b/_config.yml @@ -1,25 +1,10 @@ # Site settings -title: ralfj.de url: "https://www.ralfj.de" blog: title: "Ralf's Ramblings" description: "Ralf rambling on things" -structure: - - url: "/" - title: "ralfj.de" - structure: - - url: "projects/" - title: "Projects" - structure: - - url: "lilass/" - title: LiLaSS - - url: "schsh/" - title: schsh - - url: "cs/" - title: "Research" - defaults: - scope: path: "" # all files in the project diff --git a/_includes/menu-level.html b/_includes/menu-level.html index 0b25bd7..5f5ac46 100644 --- a/_includes/menu-level.html +++ b/_includes/menu-level.html @@ -1,12 +1,6 @@ - \ No newline at end of file +{% endfor %}--> \ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html index 5fe8d4d..cff4389 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -5,28 +5,29 @@ - {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %} + {{ page.title }} {% if page.excerpt %}{% endif %} {% capture canonicalurl %}{{ page.url | replace:'index.html','' }}{% endcapture %} - {% if page.rss or page.layout == 'post' %}{% endif %} + {% if page.rss or page.layout == 'post' %}{% endif %}
-

{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}

+

{{ page.title }}

- {{ content }} + {{ content }}
diff --git a/_plugins/menu.rb b/_plugins/menu.rb new file mode 100644 index 0000000..317db0c --- /dev/null +++ b/_plugins/menu.rb @@ -0,0 +1,40 @@ +module Jekyll + module MenuFilter + def menu(input, displayurl) + def create_menu(pages, base, displayurl) + result = Array.new + for page in pages + cururl = page['url'].sub('/index.html', '') + if cururl.start_with?(base) and cururl.count('/') == base.count('/') + # figure out CSS class + if cururl == displayurl + css_class = 'current' + elsif cururl.start_with?(displayurl) + css_class = 'child' + elsif displayurl.start_with?(cururl) + css_class = 'parent' + else + css_class = 'sibling' + end + # create menu node + menu_node = { 'url' => page['url'], 'title' => page['title'], 'class' => css_class } + # potentially recurse + if (css_class == 'parent' or css_class == 'current') + sub_nodes = create_menu(pages, cururl + "/", displayurl) + if sub_nodes.size > 0 + menu_node['sub'] = sub_nodes + end + end + # store menu node + result.push(menu_node) + end + end + result + end + + create_menu(input, "", displayurl.sub('/index.html', '')) + end + end +end + +Liquid::Template.register_filter(Jekyll::MenuFilter) diff --git a/feed.xml b/feed.xml index 0405375..05bc7f0 100644 --- a/feed.xml +++ b/feed.xml @@ -7,7 +7,7 @@ layout: null {{ site.blog.title | xml_escape }} {{ site.blog.description | xml_escape }} {{ site.url }}/ - + {{ site.time | date_to_rfc822 }} {{ site.time | date_to_rfc822 }} Jekyll v{{ jekyll.version }} @@ -16,8 +16,8 @@ layout: null {{ post.title | xml_escape }} {{ post.content | xml_escape }} {{ post.date | date_to_rfc822 }} - {{ post.url | prepend: site.baseurl | prepend: site.url }} - {{ post.url | prepend: site.baseurl | prepend: site.url }} + {{ post.url | prepend: site.url }} + {{ post.url | prepend: site.url }} {% for tag in post.tags %} {{ tag | xml_escape }} {% endfor %} diff --git a/index.html b/index.html index 326d043..c46238c 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,5 @@ --- +title: ralfj.de ---

Willkommen