Browse Source

add itemurl macro for creating the url for articles and use it...

main
John-Mark Gurney 3 years ago
parent
commit
603f70195f
5 changed files with 12 additions and 6 deletions
  1. +2
    -1
      layout/base.j2
  2. +4
    -3
      layout/blog.j2
  3. +2
    -1
      layout/frontpage.j2
  4. +2
    -0
      layout/macros.j2
  5. +2
    -1
      layout/tagged_posts.j2

+ 2
- 1
layout/base.j2 View File

@@ -1,3 +1,4 @@
{% from "macros.j2" import itemurl %}
<!doctype html>
<!-- https://github.com/paulirish/html5-boilerplate/blob/master/index.html -->
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
@@ -74,7 +75,7 @@
<b><button class="w3-button">{{ monthgrp.list[0].meta.created|date_format('%B') }}{# font awesome <i class="fa fa-caret-down"></i> #}</button></b>
{% for item in monthgrp.list %}
<div class="w3-dropdown-click w3-bar-block" style="margin-left: 0.75em;">
<a href="{{ content_url(item.url) }}" class="no-tufte-underline w3-bar-item w3-button">{{ item.meta.title }}</a>
<a href="{{ itemurl(item) }}" class="no-tufte-underline w3-bar-item w3-button">{{ item.meta.title }}</a>
</div>
{% endfor %}
{% endfor %}


+ 4
- 3
layout/blog.j2 View File

@@ -1,3 +1,4 @@
{% from "macros.j2" import itemurl %}
{% from "macros.j2" import slug %}
{% extends "base.j2" %}

@@ -6,7 +7,7 @@
{% mark post -%}
<article class="post">

<h1><a name="{{ slug(resource) }}-title" class="no-tufte-underline" href="{{ resource.url ~"#"~slug(resource)~"-title" }}">{{ resource.meta.title }}</a></h1>
<h1><a name="{{ slug(resource) }}-title" class="no-tufte-underline" href="{{ itemurl(resource) }}">{{ resource.meta.title }}</a></h1>

<p class="posted">Posted: {{ resource.meta.created.strftime('%B %e, %Y') }} at {{ resource.meta.time }}</p>

@@ -35,7 +36,7 @@
<a class="prev{{' disabled' if not resource.prev_by_time }}"
title="{{ resource.prev_by_time.meta.title }}"
{% if resource.prev_by_time %}
href="{{ content_url(resource.prev_by_time.url) ~ "#" ~ slug(resource.prev_by_time) ~ "-title" }}"{% endif %}>
href="{{ itemurl(resource.prev_by_time) }}"{% endif %}>
Next
</a>
|
@@ -44,7 +45,7 @@
<a class="next{{' disabled' if not resource.next_by_time }}"
title="{{ resource.next_by_time.meta.title }}"
{% if resource.next_by_time %}
href="{{ content_url(resource.next_by_time.url) ~ "#" ~ slug(resource.next_by_time) ~ "-title" }}"{% endif %}>
href="{{ itemurl(resource.next_by_time) }}"{% endif %}>
Previous
</a>
</span>


+ 2
- 1
layout/frontpage.j2 View File

@@ -1,3 +1,4 @@
{% from "macros.j2" import itemurl %}
{% extends "base.j2" %}

{% block main %}
@@ -21,7 +22,7 @@
<a class="prev{{' disabled' if not nextpost }}"
title="{{ nextpost.meta.title }}"
{% if nextpost %}
href="{{ content_url(nextpost.url) }}"{% endif %}>
href="{{ itemurl(nextpost) }}"{% endif %}>
Previous Post
</a>
</span>


+ 2
- 0
layout/macros.j2 View File

@@ -1,5 +1,7 @@
{% macro slug(res) %}
{{ res.meta.id if res.meta.id else res.slug }}{% endmacro %}
{% macro itemurl(res) %}
{{ res.url ~ "#" ~ (res.meta.id if res.meta.id else res.slug) ~ "-title" }}{% endmacro %}

{# endmacro not on new line to prevent white space at end of macro #}



+ 2
- 1
layout/tagged_posts.j2 View File

@@ -1,3 +1,4 @@
{% from "macros.j2" import itemurl %}
{% extends "base.j2" %}

{% block main %}
@@ -9,7 +10,7 @@
<time datetime="{{ resource.meta.created.strftime('%Y-%m-%d') }}">
{{ resource.meta.created.strftime('%a, %d %b %Y') }}
</time>
<a href="{{ content_url(resource.url) }}">{{ resource.meta.title }}</a>
<a href="{{ itemurl(resource) }}">{{ resource.meta.title }}</a>
{% if resource.meta.tags %}
<ul class="tags clear">
{% for tag in resource.meta.tags %}


Loading…
Cancel
Save