mirror of
https://github.com/godotengine/godot-website.git
synced 2025-12-31 09:48:43 +03:00
Blog: add note for articles that might be outdated (#537)
Provides a custom `site.outdated_article_threshold` variable through a Jekyll plugin.
This commit is contained in:
19
_includes/outdated_article_notice.html
Normal file
19
_includes/outdated_article_notice.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% unless page.no_outdated_notice %}
|
||||
{% unless page.categories contains "release" or page.categories contains "pre-release" or page.categories contains "showcase" %}
|
||||
{% comment %}
|
||||
`site.outdated_article_threshold` is generated by `_plugins/outdated_article_threshold.rb`.
|
||||
{% endcomment %}
|
||||
{% if page.date < site.outdated_article_threshold %}
|
||||
<div class="card card-warning base-padding">
|
||||
<p>
|
||||
{% if page.outdated_notice_text %}
|
||||
{{ page.outdated_notice_text }}
|
||||
{% else %}
|
||||
This article is from <strong>{{ page.date | date: "%B %Y" }}</strong>, some of its contents might be outdated and no longer accurate.<br><br>
|
||||
You can find up-to-date information about the engine in the <a href="https://docs.godotengine.org/en/stable/">official documentation</a>.
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endunless %}
|
||||
{% endunless %}
|
||||
@@ -136,6 +136,8 @@ layout: default
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include outdated_article_notice.html %}
|
||||
|
||||
{{ content }}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
10
_plugins/outdated_article_threshold.rb
Normal file
10
_plugins/outdated_article_threshold.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
AVERAGE_SECONDS_PER_MONTH = 2628000
|
||||
|
||||
# Add a custom `site.outdated_article_threshold` variable.
|
||||
# We use `site.time` that holds the build time as a base, but since you can't do math in
|
||||
# the template language we can't use it there directly.
|
||||
Jekyll::Hooks.register(:site, :after_init) do |site|
|
||||
# Articles that have a date older than this at build time are considered outdated.
|
||||
# see `_includes/outdated_article_notice.html`
|
||||
site.config["outdated_article_threshold"] = site.time - AVERAGE_SECONDS_PER_MONTH * 18
|
||||
end
|
||||
@@ -62,6 +62,9 @@
|
||||
--teams-subteams-color: rgba(255, 255, 255, 0.4);
|
||||
|
||||
--table-divider-color: rgba(0, 0, 0, 0.1);
|
||||
|
||||
--warning-background-color: #ffedcc;
|
||||
--warning-color: #404040;
|
||||
}
|
||||
|
||||
.nav-logo.dark-logo {
|
||||
@@ -132,6 +135,9 @@
|
||||
--teams-subteams-color: rgba(0, 0, 0, 0.2);
|
||||
|
||||
--table-divider-color: rgba(255, 255, 255, 0.1);
|
||||
|
||||
--warning-background-color: #444033;
|
||||
--warning-color: #ffeeaf;
|
||||
}
|
||||
|
||||
/* Use logo with white text for dark navbar. */
|
||||
@@ -792,6 +798,11 @@ p.small {
|
||||
background-color: var(--card-footer-color);
|
||||
}
|
||||
|
||||
.card-warning {
|
||||
background: var(--warning-background-color);
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
a.card {
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user