Skip to content

Commit a181289

Browse files
committed
UJ: Merged from template.
2 parents d7aad04 + 71d2ace commit a181289

File tree

7 files changed

+118
-11
lines changed

7 files changed

+118
-11
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- Generate a random number of comments based on the number of words in the content -->
2+
{% assign fixed_content = include.content | liquify | markdownify | strip_html | uj_strip_ads %}
3+
{% assign words = fixed_content | number_of_words %}
4+
{% assign comments = words | modulo: 13 %}
5+
6+
{{ comments }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- Calculate readtime from include.content -->
2+
{% assign fixed_content = include.content | liquify | markdownify | strip_html | uj_strip_ads %}
3+
{% assign words = fixed_content | number_of_words %}
4+
{% assign readtime = words | divided_by: 200 | plus: 1 %}
5+
6+
{{ readtime }}

_layouts/master/placeholder/blog/post.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ <h1 class="blog-post-title mb-1">{{ page.post.title }}</h1>
6262
{%- include /master/helpers/blog-image.html class="img-fluid rounded-lg" -%}
6363
</div>
6464

65+
{% for category in page.post.categories %}
66+
<a href="{{ site.url }}/category/{{ category | slugify }}" class="badge bg-secondary text-decoration-none">{{ category }}</a>
67+
{% endfor %}
68+
69+
<!-- Calculate read time in min -->
70+
<span>
71+
{%- include /master/helpers/read-time.html content=content -%} min read
72+
</span>
73+
74+
<!-- Calculate comments -->
75+
<span>
76+
{%- include /master/helpers/fake-comments.html content=content -%} comments
77+
</span>
6578
<p>
6679
{{ page.post.excerpt | liquify }}
6780
</p>
@@ -72,7 +85,6 @@ <h1 class="blog-post-title mb-1">{{ page.post.title }}</h1>
7285

7386
</article>
7487

75-
7688
<div class="mb-3">
7789
{%- include /master/modules/engagement/social-share-kit.html -%}
7890
</div>

_websrc/templates/master/placeholder/blog/post.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33
layout: master/placeholder/blog/post
44
sitemap:
55
include: true
6-
6+
77
### POST ONLY ###
88
post:
99
title: "Example post number {count}"
1010
excerpt: "This is a sample excerpt for post number {count}"
1111
description: "This is a sample excerpt for post number {count}"
1212
author: alex
1313
id: {id}
14-
tags: [tag, tag2, tag3]
15-
categories: [marketing, business]
14+
tags: ["business marketing"]
15+
categories: ["Marketing", "Business"]
1616
affiliate-search-term: Marketing
1717
---
1818

1919
## Title inside post {count}
2020
This is a wonderful paragrah inside a post! This is post #{count} with ID {id}.
21+
22+
Before ads
23+
24+
{% include /master/modules/adunits/adsense-in-article.html index="0" %}
25+
26+
Between ads
27+
28+
{% include /master/modules/adunits/adsense-in-article.html index="1" %}
29+
30+
After ads

special/master/feeds/posts-test.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
layout: null
3+
permalink: /feeds/posts-test.json
4+
---
5+
6+
{
7+
"version": "https://jsonfeed.org/version/1",
8+
"title": "{{ site.brand.name }} Blog",
9+
"home_page_url": "{{ site.url }}/blog",
10+
"feed_url": "{{ site.url }}{{ page.url }}",
11+
"description": "{{ site.brand.description }}",
12+
"generator": "Jekyll {{ jekyll.version }}",
13+
"language": "en",
14+
"favicon": "{{ site.favicon.path }}",
15+
"items": [
16+
{%- assign sortedFeed = site.posts | sort: 'date' | reverse -%}
17+
18+
{% for post in sortedFeed limit:25 %}
19+
{
20+
{%- if post.post.categories -%}
21+
{%- assign tags = post.post.categories | jsonify -%}
22+
{%- else -%}
23+
{%- assign tags = "[]" -%}
24+
{%- endif -%}
25+
26+
"id": "{{ site.url }}{{ post.url }}",
27+
"url": "{{ site.url }}{{ post.url }}",
28+
"title": "{{ post.title | strip_html | strip_newlines | uj_json_escape }}",
29+
"date_published": "{{ post.date | date: "%Y-%m-%dT%H:%M:%S" }}.000Z",
30+
"image": "{{ post.image }}",
31+
"content_text": "{{ post.content | liquify | markdownify | strip_html | uj_json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
32+
"content_html": "{{ post.content | liquify | markdownify | uj_strip_ads | uj_json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
33+
34+
"test_1": "{{ post.content }}",
35+
"test_1_2": "{{ post.content | uj_strip_ads }}",
36+
"test_1_3": "{{ post.content | uj_strip_ads | liquify | markdownify | uj_json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
37+
38+
39+
"test_2": "{{ post.content | liquify }}",
40+
"test_3": "{{ post.content | liquify | markdownify }}",
41+
"test_4": "{{ post.content | liquify | markdownify | uj_strip_ads }}",
42+
"test_5": "{{ post.content | liquify | markdownify | uj_strip_ads | uj_json_escape }}",
43+
44+
"test_6": "{{ post.content | markdownify }}",
45+
"test_7": "{{ post.content | markdownify | uj_strip_ads }}",
46+
"test_8": "{{ post.content | markdownify | uj_strip_ads | uj_json_escape }}",
47+
48+
"authors": [
49+
{
50+
"name": "{{ site.brand.name }}"
51+
}
52+
],
53+
"attachments": [
54+
{
55+
"url": "{{ post.image }}"
56+
}
57+
],
58+
"summary": "{{ post.post.excerpt | strip_html | strip_newlines | uj_json_escape }}",
59+
"tags": {{ tags }}
60+
}{% if forloop.last == false %},{% endif %}
61+
{% endfor %}
62+
]
63+
}

special/master/feeds/posts.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ permalink: /feeds/posts.json
1717

1818
{% for post in sortedFeed limit:25 %}
1919
{
20+
{%- if post.post.categories -%}
21+
{%- assign tags = post.post.categories | jsonify -%}
22+
{%- else -%}
23+
{%- assign tags = "[]" -%}
24+
{%- endif -%}
2025
"id": "{{ site.url }}{{ post.url }}",
2126
"url": "{{ site.url }}{{ post.url }}",
22-
"title": "{{ post.title | strip_html | strip_newlines | json_escape }}",
27+
"title": "{{ post.title | strip_html | strip_newlines | uj_json_escape }}",
2328
"date_published": "{{ post.date | date: "%Y-%m-%dT%H:%M:%S" }}.000Z",
2429
"image": "{{ post.image }}",
25-
"content_text": "{{ post.content | liquify | markdownify | strip_html | json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
26-
"content_html": "{{ post.content | liquify | markdownify | strip_ads | json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
30+
"content_text": "{{ post.content | liquify | markdownify | strip_html | uj_json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
31+
"content_html": "{{ post.content | uj_strip_ads | liquify | markdownify | uj_strip_ads | uj_json_escape | replace: '\n', ' ' | replace: '\r', ' ' | strip_newlines }}",
2732
"authors": [
2833
{
2934
"name": "{{ site.brand.name }}"
@@ -34,8 +39,8 @@ permalink: /feeds/posts.json
3439
"url": "{{ post.image }}"
3540
}
3641
],
37-
"summary": "{{ post.post.excerpt | strip_html | strip_newlines | json_escape }}",
38-
"tags": ["{{ post.post.category }}"]
42+
"summary": "{{ post.post.excerpt | strip_html | strip_newlines | uj_json_escape }}",
43+
"tags": {{ tags }}
3944
}{% if forloop.last == false %},{% endif %}
4045
{% endfor %}
4146
]

special/master/feeds/posts.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ permalink: /feeds/posts.xml
3939
{{ post.post.title }}
4040
{%- endif -%}
4141
{%- endcapture -%}
42+
{%- if post.post.categories -%}
43+
{%- assign category = post.post.categories | first -%}
44+
{%- else -%}
45+
{%- assign category = "" -%}
46+
{%- endif -%}
4247
<item>
4348
<title>
4449
<![CDATA[
@@ -65,7 +70,7 @@ permalink: /feeds/posts.xml
6570
</description>
6671
<content:encoded>
6772
<![CDATA[
68-
{{ post.content | liquify | markdownify | strip_ads }}
73+
{{ post.content | uj_strip_ads | liquify | markdownify | uj_strip_ads }}
6974
]]>
7075
</content:encoded>
7176
<dc:creator>
@@ -75,7 +80,7 @@ permalink: /feeds/posts.xml
7580
</dc:creator>
7681
<category>
7782
<![CDATA[
78-
{{ post.post.category }}
83+
{{ category }}
7984
]]>
8085
</category>
8186
</item>

0 commit comments

Comments
 (0)