Added related posts section (#1168)

This commit is contained in:
George 2023-02-19 23:26:48 -03:00 committed by GitHub
parent 4005ff4893
commit 8ccc284008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 49 additions and 7 deletions

View File

@ -1,16 +1,17 @@
source 'https://rubygems.org' source 'https://rubygems.org'
group :jekyll_plugins do group :jekyll_plugins do
gem 'classifier-reborn'
gem 'jekyll' gem 'jekyll'
gem 'jekyll-archives' gem 'jekyll-archives'
gem 'jekyll-diagrams' gem 'jekyll-diagrams'
gem 'jekyll-email-protect' gem 'jekyll-email-protect'
gem 'jekyll-feed' gem 'jekyll-feed'
gem 'jekyll-imagemagick' gem 'jekyll-imagemagick'
gem 'jekyll-link-attributes'
gem 'jekyll-minifier' gem 'jekyll-minifier'
gem 'jekyll-paginate-v2' gem 'jekyll-paginate-v2'
gem 'jekyll-scholar' gem 'jekyll-scholar'
gem 'jekyll-sitemap' gem 'jekyll-sitemap'
gem 'jekyll-link-attributes'
gem 'jekyll-twitter-plugin' gem 'jekyll-twitter-plugin'
gem 'jemoji' gem 'jemoji'
gem 'mini_racer' gem 'mini_racer'
@ -18,6 +19,6 @@ group :jekyll_plugins do
gem 'webrick' gem 'webrick'
end end
group :other_plugins do group :other_plugins do
gem 'httparty'
gem 'feedjira' gem 'feedjira'
gem 'httparty'
end end

View File

@ -159,6 +159,7 @@ Images2Symbols (CogSci: <a href="https://images2symbols.github.io/" target="_bla
- [Theming](#theming) - [Theming](#theming)
- [Social media previews](#social-media-previews) - [Social media previews](#social-media-previews)
- [Atom (RSS-like) Feed](#atom-rss-like-feed) - [Atom (RSS-like) Feed](#atom-rss-like-feed)
- [Related posts](#related-posts)
* [Contributing](#contributing) * [Contributing](#contributing)
+ [Core Contributors](#core-contributors) + [Core Contributors](#core-contributors)
* [License](#license) * [License](#license)
@ -221,7 +222,7 @@ Assuming you have [Ruby](https://www.ruby-lang.org/en/downloads/) and [Bundler](
$ git clone git@github.com:<your-username>/<your-repo-name>.git $ git clone git@github.com:<your-username>/<your-repo-name>.git
$ cd <your-repo-name> $ cd <your-repo-name>
$ bundle install $ bundle install
$ bundle exec jekyll serve $ bundle exec jekyll serve --lsi
``` ```
Now, feel free to customize the theme however you like (don't forget to change the name!). Now, feel free to customize the theme however you like (don't forget to change the name!).
@ -269,7 +270,7 @@ uses the `master` branch for the source code and deploys the webpage to `gh-page
If you decide to not use GitHub Pages and host your page elsewhere, simply run: If you decide to not use GitHub Pages and host your page elsewhere, simply run:
```bash ```bash
$ bundle exec jekyll build $ bundle exec jekyll build --lsi
``` ```
which will (re-)generate the static webpage in the `_site/` folder. which will (re-)generate the static webpage in the `_site/` folder.
Then simply copy the contents of the `_site/` foder to your hosting server. Then simply copy the contents of the `_site/` foder to your hosting server.
@ -289,7 +290,7 @@ Firstly, from the deployment repo dir, checkout the git branch hosting your publ
Then from the website sources dir (commonly your al-folio fork's clone): Then from the website sources dir (commonly your al-folio fork's clone):
```bash ```bash
$ bundle exec jekyll build --destination $HOME/repo/publishing-source $ bundle exec jekyll build --lsi --destination $HOME/repo/publishing-source
``` ```
This will instruct jekyll to deploy the website under `$HOME/repo/publishing-source`. This will instruct jekyll to deploy the website under `$HOME/repo/publishing-source`.
@ -535,6 +536,12 @@ It generates an Atom (RSS-like) feed of your posts, useful for Atom and RSS read
The feed is reachable simply by typing after your homepage `/feed.xml`. The feed is reachable simply by typing after your homepage `/feed.xml`.
E.g. assuming your website mountpoint is the main folder, you can type `yourusername.github.io/feed.xml` E.g. assuming your website mountpoint is the main folder, you can type `yourusername.github.io/feed.xml`
#### Related posts
By default, there will be a related posts section on the bottom of the blog posts.
These are generated by selecting the `max_related` most recent posts that share at least `min_common_tags` tags with the current post.
If you do not want to display related posts on a specific post, simply add `related_posts: false` to the front matter of the post.
If you want to disable it for all posts, simply set `enabled` to false in the `related_blog_posts` section in `_config.yml`.
## Contributing ## Contributing
Contributions to al-folio are very welcome! Contributions to al-folio are very welcome!

View File

@ -124,6 +124,10 @@ permalink: /blog/:year/:title/
pagination: pagination:
enabled: true enabled: true
related_blog_posts:
enabled: true
max_related: 5
# Giscus comments (RECOMMENDED) # Giscus comments (RECOMMENDED)
# Follow instructions on https://giscus.app/ to setup for your repo to fill out # Follow instructions on https://giscus.app/ to setup for your repo to fill out
# the information below. # the information below.

View File

@ -0,0 +1,19 @@
{% assign have_related_posts = false %}
{% for post in site.related_posts | limit: site.related_blog_posts.max_related %}
{% unless have_related_posts %}
{% assign have_related_posts = true %}
<br>
<hr>
<br>
<ul class="list-disc pl-8"></ul>
<!-- Adds related posts to the end of an article -->
<h2 class="text-3xl font-semibold mb-4 mt-12">Enjoy Reading This Article?</h2>
<p class="mb-2">Here are some more articles you might like to read next:</p>
{% endunless %}
<li class="my-2">
<a class="text-pink-700 underline font-semibold hover:text-pink-800" href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}

View File

@ -43,6 +43,12 @@ layout: default
{{ content }} {{ content }}
</article> </article>
{%- if site.related_blog_posts.enabled -%}
{%- if page.related_posts == null or page.related_posts -%}
{% include related_posts.html %}
{%- endif %}
{%- endif %}
{%- if site.disqus_shortname and page.disqus_comments -%} {%- if site.disqus_shortname and page.disqus_comments -%}
{% include disqus.html %} {% include disqus.html %}
{%- endif %} {%- endif %}

View File

@ -5,5 +5,6 @@ date: 2015-10-20 11:59:00-0400
description: an example of a blog post with disqus comments description: an example of a blog post with disqus comments
categories: sample-posts external-services categories: sample-posts external-services
disqus_comments: true disqus_comments: true
related_posts: false
--- ---
This post shows how to add DISQUS comments. This post shows how to add DISQUS comments.

View File

@ -5,6 +5,7 @@ date: 2015-10-20 11:12:00-0400
description: an example of a blog post with some math description: an example of a blog post with some math
tags: formatting math tags: formatting math
categories: sample-posts categories: sample-posts
related_posts: false
--- ---
This theme supports rendering beautiful math in inline and display modes using [MathJax 3](https://www.mathjax.org/) engine. You just need to surround your math expression with `$$`, like `$$ E = mc^2 $$`. If you leave it inside a paragraph, it will produce an inline expression, just like $$ E = mc^2 $$. This theme supports rendering beautiful math in inline and display modes using [MathJax 3](https://www.mathjax.org/) engine. You just need to surround your math expression with `$$`, like `$$ E = mc^2 $$`. If you leave it inside a paragraph, it will produce an inline expression, just like $$ E = mc^2 $$.

View File

@ -5,3 +5,5 @@ date: 2022-02-01 17:39:00
description: you can also redirect to assets like pdf description: you can also redirect to assets like pdf
redirect: /assets/pdf/example_pdf.pdf redirect: /assets/pdf/example_pdf.pdf
--- ---
Redirecting to another page.

View File

@ -5,5 +5,6 @@ date: 2022-12-10 11:59:00-0400
description: an example of a blog post with giscus comments description: an example of a blog post with giscus comments
categories: sample-posts external-services categories: sample-posts external-services
giscus_comments: true giscus_comments: true
related_posts: false
--- ---
This post shows how to add GISCUS comments. This post shows how to add GISCUS comments.

View File

@ -1 +1 @@
bundle exec jekyll build bundle exec jekyll build --lsi

View File

@ -93,7 +93,7 @@ git checkout -b $DEPLOY_BRANCH
export JEKYLL_ENV=production export JEKYLL_ENV=production
# Build site # Build site
bundle exec jekyll build bundle exec jekyll build --lsi
# Delete and move files # Delete and move files
find . -maxdepth 1 ! -name '_site' ! -name '.git' ! -name 'CNAME' ! -name '.gitignore' -exec rm -rf {} \; find . -maxdepth 1 ! -name '_site' ! -name '.git' ! -name 'CNAME' ! -name '.gitignore' -exec rm -rf {} \;