Skip to content

Commit

Permalink
Adds styling
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeSteam committed Nov 12, 2024
1 parent d709263 commit 4492e4c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 35 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ replace_read_time_with_word_count: true
show_excerpts_html: true
open_external_links_in_new_tab: true
outdated_content_warning:
warning_text: "This article was last updated <DATE> and may be outdated."
warning_text: "This article was last updated <b><DATE></b> and may be outdated."
placeholder_text: "<DATE>"
warning_threshold_days: 1095 # 3 years
warning_threshold_days: 365
ignore_date_updated: false

# Third party feature customisation (delete to turn off)
Expand Down
23 changes: 23 additions & 0 deletions _includes/custom/outdated_content.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% if site.outdated_content_warning and page.hide_content_warning != true %}
{% assign content_date = page.last_modified_at | date: "%s" %}
{% if site.outdated_content_warning.ignore_date_updated or page.last_modified_at == nil %}
{% assign content_date = page.date | date: "%s" %}
{% endif %}

{% assign current_date = "now" | date: "%s" %}
{% assign days_since_last_modified = current_date | minus: content_date | divided_by: 86400 %}

{% if days_since_last_modified > site.outdated_content_warning.warning_threshold_days %}
{% assign years = days_since_last_modified | divided_by: 365 %}
{% if years > 1 %}
{% assign time_since = "over " | append: years | append: " years ago" %}
{% elsif years == 1 %}
{% assign time_since = "over " | append: years | append: " year ago" %}
{% else %}
{% assign time_since = days_since_last_modified | append: " days ago" %}
{% endif %}
<div class="outdated-warning">
⚠️ {{ site.outdated_content_warning.warning_text | replace: site.outdated_content_warning.placeholder_text, time_since }}
</div>
{% endif %}
{% endif %}
24 changes: 1 addition & 23 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,7 @@ <h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}
{%- endif -%}
{% include custom/tags.html %}</p>

{% if site.outdated_content_warning and page.hide_content_warning != true %}

{% assign content_date = page.last_modified_at | date: "%s" %}
{% if site.outdated_content_warning.ignore_date_updated or page.last_modified_at == nil %}
{% assign content_date = page.date | date: "%s" %}
{% endif %}

{% assign current_date = "now" | date: "%s" %}
{% assign days_since_last_modified = current_date | minus: content_date | divided_by: 86400 %}

{% if days_since_last_modified > site.outdated_content_warning.warning_threshold_days %}
{% assign years = days_since_last_modified | divided_by: 365 %}
{% if years > 0 %}
{% assign time_since = "over <b>" | append: years | append: " years ago</b>" %}
{% else %}
{% assign time_since = "<b>" | append: days_since_last_modified | append: " days ago</b>" %}
{% endif %}
<div class="outdated-warning">
⚠️ {{ site.outdated_content_warning.warning_text | replace: site.outdated_content_warning.placeholder_text, time_since }}
</div>
{% endif %}
{% endif %}
{% include custom/outdated_content.html %}
</header>

{% if site.table_of_contents_header != blank? %}
Expand Down
10 changes: 0 additions & 10 deletions _posts/2020-01-01-sample-old-post.md

This file was deleted.

7 changes: 7 additions & 0 deletions assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ h1:hover .octicon, h2:hover .octicon, h3:hover .octicon, h4:hover .octicon, h5:h
white-space: nowrap;
}

/* Outdated content warning */
.outdated-warning {
padding: 0.75rem 1rem;
border: 1px solid {{ site.accent_colour }};
border-radius: 0.25rem;
}

/* Calendar */
.calendar-container {
display: grid;
Expand Down

0 comments on commit 4492e4c

Please sign in to comment.