start honoring baseurl again; crazy hackery to get page-dependent computed (pre)titles
authorRalf Jung <post@ralfj.de>
Fri, 9 Oct 2015 18:11:11 +0000 (20:11 +0200)
committerRalf Jung <post@ralfj.de>
Fri, 9 Oct 2015 18:11:11 +0000 (20:11 +0200)
personal/_config.yml
personal/_includes/menu-level.html
personal/_includes/vars/blog-index.html [new file with mode: 0644]
personal/_includes/vars/blog-page.html [new file with mode: 0644]
personal/_layouts/default.html
personal/_layouts/page.html [deleted file]
personal/_plugins/readmes.rb
personal/blog/archive.html
personal/blog/index.html

index bf82a60d55ce3e9db0d784dc22f3602d092fd83f..e5d9a01487b9a238b7fc163ddf6481e12ff66fb2 100644 (file)
@@ -1,4 +1,5 @@
 # Site settings
+baseurl: ""
 url: "https://www.ralfj.de"
 permalink: "/blog/:year/:month/:day/:title.html"
 timezone: "Europe/Berlin"
@@ -23,13 +24,13 @@ defaults:
   - scope:
         path: "" # all files in the project
     values:
-        layout: "page"
+        layout: "default"
   - scope:
         path: ""
         type: "posts"
     values:
         rss: true
-        pretitle: "Ralf's Ramblings"
+        vars: "blog-page.html"
 
 # Build settings
 markdown: kramdown
index 03cdc1380b82f877e51b2f830d273004068c4b15..7e4e5ef38da33c662ca6893bf5de87a4b26c1e83 100644 (file)
@@ -1,5 +1,5 @@
 <ul><!--{% for item in include.menu %}
-    --><li class="{{ item.class }}"><a class="{{ item.class }}" href="{% if page.absolute_urls %}{{ site.url }}{% endif %}{{ item.url }}">{{ item.title }}</a></li><!--
+    --><li class="{{ item.class }}"><a class="{{ item.class }}" href="{{ site.baseurl }}{{ item.url }}">{{ item.title }}</a></li><!--
     {% if item.sub %}
         --><li class="sub">{% include menu-level.html menu=item.sub %}</li><!--
     {% endif %}
diff --git a/personal/_includes/vars/blog-index.html b/personal/_includes/vars/blog-index.html
new file mode 100644 (file)
index 0000000..e738b23
--- /dev/null
@@ -0,0 +1 @@
+{% assign title = site.blog.title %}
diff --git a/personal/_includes/vars/blog-page.html b/personal/_includes/vars/blog-page.html
new file mode 100644 (file)
index 0000000..a16df5a
--- /dev/null
@@ -0,0 +1 @@
+{% assign pretitle = site.blog.title %}
index 5d27d6c709f154e0f73167316327a49fab792c25..797739c84af2e5e1ac636f24d4e8452ea57b3c75 100644 (file)
@@ -5,13 +5,16 @@
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width">
 
-    <title>{% if page.pretitle %}{{ page.pretitle }} • {% endif %}{{ page.title }}</title>
-    {% if page.excerpt %}<meta name="description" content="{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}">{% endif %}
+    {% assign title = page.title %}
+    {% assign pretitle = page.pretitle %}
+    {% if page.vars %}{% include {{ page.vars | prepend: "vars/" }} %}{% endif %}
 
-    <link rel="stylesheet" href="{% if page.absolute_urls %}{{ site.url }}{% endif %}/style.css">
-    {% capture canonicalurl %}{{ page.url | replace:'index.html','' }}{% endcapture %}
-    <link rel="canonical" href="{{ canonicalurl | prepend: site.url }}">
-    {% if page.rss %}<link rel="alternate" type="application/rss+xml" title="{{ site.blog.title }}" href="/blog/feed.xml" />{% endif %}
+    <title>{% if pretitle %}{{ pretitle }} • {% endif %}{{ title }}</title>
+    {% if page.excerpt %}<meta name="description" content="{{ page.excerpt | newline_to_br | replace:'<br />',' ' | strip_html | strip_newlines | truncate: 160 }}">{% endif %}
+
+    <link rel="stylesheet" href="{{ site.baseurl }}/style.css">
+    <link rel="canonical" href="{{ site.url }}{{ site.baseurl }}{{ page.url | replace:'index.html','' }}">
+    {% if page.rss %}<link rel="alternate" type="application/rss+xml" title="{{ site.blog.title }}" href="{{ site.baseurl }}/blog/feed.xml" />{% endif %}
   </head>
 
   <body><div id="-frame">
     </nav>
   
     <article id="-content">
-        {{ content }}
+      {% comment %} Unfortunately, the variables we set above are not preserved for sub-layouts. So, we have to have all the layout here. {% endcomment %}
+      {% if pretitle %}
+        <header class="pretitle">
+          {% if page.date %}
+            <div class="side"><a href="{{ site.baseurl }}{{ page.url }}">Permalink</a> • {{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</div>
+          {% endif %}
+          <h1>{{ pretitle }}</h1>
+        </header>
+      {% endif %}
+
+      <header class="title">
+        <h1>{{ title }}</h1>
+      </header>
+
+      {{ content }}
     </article>
 
   </div></body>
diff --git a/personal/_layouts/page.html b/personal/_layouts/page.html
deleted file mode 100644 (file)
index 99737e0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
----
-layout: default
----
-{% if page.pretitle %}
-<header class="pretitle">
-  {% if page.date %}
-    <div class="side"><a href="{{ page.url }}">Permalink</a> • {{ page.date | date: "%b %-d, %Y" }}{% if page.author %} • {{ page.author }}{% endif %}{% if page.meta %} • {{ page.meta }}{% endif %}</div>
-  {% endif %}
-  <h1>{{ page.pretitle }}</h1>
-</header>
-{% endif %}
-
-<header class="title">
-  <h1>{{ page.title }}</h1>
-</header>
-
-{{ content }}
index f70258975415f5ad04b19f6e04aaf640373a5045..4360d767b1a93f3589a7f78e451fdc7dc4e1f3d6 100644 (file)
@@ -12,7 +12,7 @@ module Jekyll
       
       content = File.read(src, self.merged_file_read_opts({})).each_line.to_a
 
-      self.data['layout'] = 'page'
+      self.data['layout'] = 'default'
       self.data['title'] = content[0].match(/^#* ?(.*)\n$/)[1]
       slug = self.data['title'].match(/^([^:]*):.*$/)
       if slug
index f6db232e05d46a3d9ead9416d03d451afae4c34a..e867f3fe7a4f3171923cffeb346d34c68f18625e 100644 (file)
@@ -1,11 +1,10 @@
 ---
 title: Archive
-pretitle: "Ralf's Ramblings"
+vars: blog-page.html
 rss: true
 sort: 1
 hide: true
 ---
-
 <p>Here you can find direct links to all my blog posts.</p>
 
   <ul class="post-list">
index 70032ce218c9eeb4941f03b338316b159c0843a8..99724ea6f74a21e650a9cf94e499bd99dae0b0b6 100644 (file)
@@ -1,7 +1,8 @@
 ---
-title: "Ralf's Ramblings"
+vars: blog-index.html
 slug: Blog
 rss: true
+sort: 10
 ---
 
 {% assign num_posts = 5 %}