Skip to content

Commit

Permalink
Add Atom feed
Browse files Browse the repository at this point in the history
  • Loading branch information
imustafin committed Sep 12, 2024
1 parent a4358fc commit 666108f
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ group :jekyll_plugins do
gem 'jekyll-plantuml', '~> 1.4', '>= 1.4.2'
gem 'jekyll-node-module', '~> 0.1.3'
gem 'jekyll_picture_tag', '~> 2.1'
gem 'jekyll-inline-svg', '~> 1.1', '>= 1.1.5'
end

# Tests
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ GEM
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-inline-svg (1.1.5)
jekyll (>= 3.3, < 5.0)
svg_optimizer (~> 0.3.0)
jekyll-node-module (0.1.3)
jekyll (>= 2.0, < 5.0)
jekyll-plantuml (1.4.2)
Expand Down Expand Up @@ -121,6 +124,8 @@ GEM
safe_yaml (1.0.5)
sass-embedded (1.78.0-x86_64-linux-gnu)
google-protobuf (~> 4.27)
svg_optimizer (0.3.0)
nokogiri
temple (0.10.3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand All @@ -134,6 +139,7 @@ PLATFORMS

DEPENDENCIES
jekyll (~> 4.3, >= 4.3.3)
jekyll-inline-svg (~> 1.1, >= 1.1.5)
jekyll-node-module (~> 0.1.3)
jekyll-plantuml (~> 1.4, >= 1.4.2)
jekyll-postcss (~> 0.5.0)
Expand Down
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ plugins:
- jekyll-plantuml
- jekyll-postcss
- jekyll-node-module
- jekyll-inline-svg

svg:
optimize: true

node_modules:
copy:
Expand Down
4 changes: 4 additions & 0 deletions _data/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ home:
en: New projects
ru: Новые проекты
tt: Яңа проектлар
subscribe-posts:
en: Subscribe to the posts feed!
ru: Подпишись на ленту постов!
tt: Язма каналына языл!

about:
links-and-contacts:
Expand Down
2 changes: 1 addition & 1 deletion _includes/post_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a
href="{{ include.post.url | relative_url }}"
title="{{ include.post.title }}"
class="vlink no-underline"
class="vlink no-underline hover:underline"
>
{{ include.post.title | escape }}
</a>
Expand Down
5 changes: 5 additions & 0 deletions _layouts/bare.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<link rel="alternate" hreflang="{{ lang }}" href="{{ page.url | absolute_url }}" />
{% endfor %}

{% assign feed_posts_multilang = site.pages | where: "ref", "feed-posts-multilang" | first %}
{% assign feed_posts = site.pages | where: "ref", "feed-posts" | where: "lang", page.lang | first %}
<link rel="alternate" type="application/atom+xml" href="{{ feed_posts.url | absolute_url }}" title="{{ feed_posts.title }}"/>
<link rel="alternate" type="application/atom+xml" href="{{ feed_posts_multilang.url | absolute_url }}" title="{{ feed_posts_multilang.title }}"/>

{% seo %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#157878">
Expand Down
7 changes: 6 additions & 1 deletion _layouts/blog_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

<div class="prose">
<h1>{{ site.data.i18n.blog.posts[page.lang] }}</h1>
<span></span>
</div>

{% assign feed_posts = site.pages | where: "ref", "feed-posts" | where: "lang", page.lang | first %}
<a href="{{ feed_posts.url | absolute_url }}" class="inline-block vlink no-underline my-4">
{% svg feed-icon.svg class="inline h-4 w-4"%}
<span class="underline">{{ site.data.i18n.home.subscribe-posts | t }}</span>
</a>

{% include posts.html limit=nil hlevel=2 %}
40 changes: 40 additions & 0 deletions _layouts/feed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
layout: none
---
<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom" {% if page.lang %}xml:lang="{{ page.lang }}"{% endif %}>
<generator uri="https://jekyllrb.com/" version="{{ jekyll.version }}">Jekyll</generator>
<title>{{ page.title | xml_escape }} | {{ site.title }}</title>
<link href="{{ page.url | absolute_url }}" rel="self" type="application/atom+xml" />
<link href="{{ site.url }}" />
<id>{{ page.url | absolute_url | xml_escape }}</id>
<updated>{{ site.time | date_to_xmlschema}}</updated>

{% assign posts = site.posts | sort: "date" | reverse %}
{% if page.lang %}
{% assign posts = posts | where: "lang", page.lang %}
{% endif %}
{% for post in posts limit: 10 %}
<entry xml:lang="{{ post.lang }}">
{% assign post_title = post.title | strip_html | normalize_whitespace | xml_escape %}
<title>{{ post_title }}</title>
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post_title }}"/>
<published>{{ post.date | date_to_xmlschema }}</published>
{% assign post_updated = post.last_modified_at | default: post.date %}
<updated>{{ post_updated | date_to_xmlschema }}</updated>
<id>{{ post.id | absolute_url | xml_escape }}</id>

<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">
<![CDATA[{{ post.content | strip }}]]>
</content>
<summary type="html">
<![CDATA[{{ post.excerpt | strip_html | normalize_whitespace }}]]>
</summary>
<author>
<name>{{ post.author.name }}</name>
<uri>{{ post.author.url | xml_escape }}</uri>
</author>
</entry>
{% endfor %}
</feed>
6 changes: 6 additions & 0 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ <h2 class="text-ghaze-600 text-center font-serif text-3xl font-semibold">
{{ site.data.i18n.home.all-posts[page.lang] }}
</a>
</div>

{% assign feed_posts = site.pages | where: "ref", "feed-posts" | where: "lang", page.lang | first %}
<a href="{{ feed_posts.url | absolute_url }}" class="inline-block vlink no-underline mt-4">
{% svg feed-icon.svg class="inline h-4 w-4"%}
<span class="underline">{{ site.data.i18n.home.subscribe-posts | t }}</span>
</a>
</section>

<section class="flex-1 min-w-[30ch]">
Expand Down
1 change: 0 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ object.plantuml {
.vlink {
@apply visited:text-[revert];
@apply underline;
@apply hover:underline;
@apply text-clink;
}
}
18 changes: 18 additions & 0 deletions feed-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions feed-multilang.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: feed
include_in_sitemap: false
title: Posts in all languages
lang: false
ref: feed-posts-multilang
---
6 changes: 6 additions & 0 deletions feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
layout: feed
include_in_sitemap: false
title: Posts in English
ref: feed-posts
---
6 changes: 6 additions & 0 deletions ru/feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
layout: feed
include_in_sitemap: false
title: Посты на русском
ref: feed-posts
---
6 changes: 6 additions & 0 deletions tt/feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
layout: feed
include_in_sitemap: false
title: Татарча язмалар
ref: feed-posts
---

0 comments on commit 666108f

Please sign in to comment.