Pete 2 years ago
parent
commit
b90c1c8de9

+ 8
- 0
_layouts/post.html View File

@@ -8,6 +8,14 @@ layout: base
8 8
   <div class="row">
9 9
     <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
10 10
       <article role="main" class="blog-post">
11
+        {% if page.tags.size > 0 %}
12
+        <div class="blog-tags">
13
+          Tags: 
14
+          {% for tag in page.tags %}
15
+          <a class="tag_list_link" href="/tag/{{ tag }}">{{ tag }}</a>
16
+          {% endfor %}
17
+        </div>
18
+        {% endif %}  	  
11 19
 	      {{ content }}
12 20
 	    </article>
13 21
 	  	  

+ 42
- 0
_layouts/tag_index.html View File

@@ -0,0 +1,42 @@
1
+---
2
+layout: default
3
+show-avatar: false
4
+---
5
+
6
+<h2 class="post_title">{{page.title}}:</h2>
7
+
8
+<div class="posts-list">
9
+  {% for post in site.posts %}
10
+  {% for tag in post.tags %}
11
+  {% if tag == page.tag %}
12
+  <article class="post-preview">
13
+    <a href="{{ post.url | prepend: site.baseurl }}">
14
+      <h3 class="post-title">{{ post.title }}</h3>
15
+
16
+      {% if post.subtitle %}
17
+      <h4 class="post-subtitle">
18
+        {{ post.subtitle }}
19
+      </h4>
20
+      {% endif %}
21
+    </a>
22
+
23
+    <p class="post-meta">
24
+    Posted on {{ post.date | date: "%B %-d, %Y" }}
25
+    </p>
26
+
27
+    <div class="post-entry">
28
+      {{ post.content | strip_html | xml_escape | truncatewords: 50 }}
29
+      <a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
30
+    </div>
31
+
32
+    <div class="blog-tags">
33
+      Tags: 
34
+      {% for tag in post.tags %}
35
+      <a href="/tag/{{ tag }}">{{ tag }}</a>
36
+      {% endfor %}
37
+    </div>
38
+  </article>
39
+  {% endif %}
40
+  {% endfor %}
41
+  {% endfor %}
42
+</div>

+ 33
- 0
_plugins/_tag_gen.rb View File

@@ -0,0 +1,33 @@
1
+module Jekyll
2
+  class TagIndex < Page
3
+    def initialize(site, base, dir, tag)
4
+      @site = site
5
+      @base = base
6
+      @dir = dir
7
+      @name = 'index.html'
8
+      self.process(@name)
9
+      self.read_yaml(File.join(base, '_layouts'), 'tag_index.html')
10
+      self.data['tag'] = tag
11
+      tag_title_prefix = site.config['tag_title_prefix'] || 'Posts Tagged &ldquo;'
12
+      tag_title_suffix = site.config['tag_title_suffix'] || '&rdquo;'
13
+      self.data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}"
14
+    end
15
+  end
16
+  class TagGenerator < Generator
17
+    safe true
18
+    def generate(site)
19
+      if site.layouts.key? 'tag_index'
20
+        dir = site.config['tag_dir'] || 'tag'
21
+        site.tags.keys.each do |tag|
22
+          write_tag_index(site, File.join(dir, tag), tag)
23
+        end
24
+      end
25
+    end
26
+    def write_tag_index(site, dir, tag)
27
+      index = TagIndex.new(site, site.source, dir, tag)
28
+      index.render(site.layouts, site.site_payload)
29
+      index.write(site.dest)
30
+      site.pages << index
31
+    end
32
+  end
33
+end

+ 2
- 1
_posts/2015-01-04-first-post.md View File

@@ -1,6 +1,7 @@
1 1
 ---
2 2
 layout: post
3 3
 title: First post!
4
+tags: [random, exciting-stuff]
4 5
 ---
5 6
 
6
-This is my first post, how exciting!
7
+This is my first post, how exciting!

+ 2
- 1
_posts/2015-01-15-pirates.md View File

@@ -1,6 +1,7 @@
1 1
 ---
2 2
 layout: post
3 3
 title: Pirates arrrr
4
+tags: [pirates, random]
4 5
 ---
5 6
 
6
-Piracy is typically an act of robbery or criminal violence at sea. The term can include acts committed on land, in the air, or in other major bodies of water or on a shore. It does not normally include crimes committed against persons traveling on the same vessel as the perpetrator (e.g. one passenger stealing from others on the same vessel). The term has been used throughout history to refer to raids across land borders by non-state agents.
7
+Piracy is typically an act of robbery or criminal violence at sea. The term can include acts committed on land, in the air, or in other major bodies of water or on a shore. It does not normally include crimes committed against persons traveling on the same vessel as the perpetrator (e.g. one passenger stealing from others on the same vessel). The term has been used throughout history to refer to raids across land borders by non-state agents.

+ 2
- 1
_posts/2015-01-27-dear-diary.md View File

@@ -1,6 +1,7 @@
1 1
 ---
2 2
 layout: post
3 3
 title: Dear diary
4
+tags: [random, diary, school]
4 5
 ---
5 6
 
6
-What is it with that Mary girl?  Dragging me to school every day. As if I had a choice.  What you don't hear in those nursery rhymes is that she starves me if I don't go to school with her; it's the only way I can stay alive!  I'm thinking about being adopted by Little Bo Peep, sure I may get lost, but anything is better than being with Mary and those little brats at school (shudder, shudder).
7
+What is it with that Mary girl?  Dragging me to school every day. As if I had a choice.  What you don't hear in those nursery rhymes is that she starves me if I don't go to school with her; it's the only way I can stay alive!  I'm thinking about being adopted by Little Bo Peep, sure I may get lost, but anything is better than being with Mary and those little brats at school (shudder, shudder).

+ 28
- 0
css/main.css View File

@@ -331,6 +331,34 @@ footer .theme-by {
331 331
   }
332 332
 }
333 333
 
334
+/* --- Tags --- */
335
+
336
+.blog-tags {
337
+  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
338
+  color: #999;
339
+  font-size: 15px;
340
+  padding-top: 5px;
341
+  /* margin-bottom: 5px; */
342
+}
343
+
344
+.blog-tags a {
345
+  /* color: #999; */
346
+  color: #008AFF;
347
+  text-decoration: none;
348
+  padding: 0px 5px;
349
+}
350
+
351
+.blog-tags a:hover {
352
+  -moz-border-radius-topleft: 2px;
353
+  -moz-border-radius-topright: 2px;
354
+  -moz-border-radius-bottomright: 2px;
355
+  -moz-border-radius-bottomleft: 2px;
356
+  -webkit-border-radius: 2px 2px 2px 2px;
357
+  border-radius: 2px 2px 2px 2px;
358
+  color: #008AFF;
359
+  background-color: #CCC;
360
+}
361
+
334 362
 /* --- Post and page headers --- */
335 363
 
336 364
 .intro-header {

+ 8
- 0
index.html View File

@@ -26,6 +26,14 @@ subtitle: This is where I will tell my friends way too much about me
26 26
 	  <a href="{{ post.url | prepend: site.baseurl }}" class="post-read-more">[Read&nbsp;More]</a>
27 27
     </div>
28 28
 
29
+    {% if post.tags.size > 0 %}
30
+    <div class="blog-tags">
31
+      Tags: 
32
+      {% for tag in post.tags %}
33
+      <a href="/tag/{{ tag }}">{{ tag }}</a>
34
+      {% endfor %}
35
+    </div>
36
+    {% endif %}
29 37
    </article>
30 38
   {% endfor %}
31 39
 </div>

Loading…
Cancel
Save