-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added published date to display in user's local timezone. * Added reading time, as well as total words of the post. * Added pagination feature. Each page has 5 posts. * Removed prepend published date in post names, even if you create posts by `$ cobalt new`, so blog post is now `blog/initial-test`. * Implement the local_date_string function into the downloads page as well so that update release times are shown in the correct timezone, this will need testing and maybe fixing after merge. --------- Co-authored-by: Sam Tupy <[email protected]>
- Loading branch information
Showing
9 changed files
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,54 @@ | ||
--- | ||
layout: default.liquid | ||
title: Blog | ||
title: The NVGT blog | ||
description: The NVGT blog is where developers and contributors to the engine can post helpful tips about it's use, news and updates, insites about development, or anything else that doesn't fit very well in the documentation or in other areas of this site. It is a very minamilistic blogging setup using a static site generator and is meant for informational purposes only. | ||
permalink: /blog | ||
pagination: | ||
include: All | ||
per_page: 5 | ||
permalink_suffix: "./{{num}}/" | ||
order: Desc | ||
sort_by: ["published_date"] | ||
--- | ||
# {{ page.title }} | ||
{{ page.description }} | ||
|
||
# {{ collections.posts.title }} | ||
{{ collections.posts.description }} | ||
|
||
[RSS](/{{ collections.posts.rss }}) | ||
[RSS](/blog.xml) | ||
|
||
## posts | ||
{% for post in collections.posts.pages %} | ||
### [{{ post.title }}](/{{ post.permalink }}) | ||
on {{ post.published_date | date: "%A, %B %d %Y at %r" }} | ||
{% for post in paginator.pages %} | ||
{% assign posttitle = post.title %} | ||
{% if post.description and post.description != "" %} | ||
{% assign posttitle = posttitle | append: " (" | append: post.description | append: ")" %} | ||
{% endif %} | ||
### [{{posttitle}}](/{{post.permalink}}) | ||
Published on <script>document.write(local_datetime_string("{{ post.published_date}}"));</script> | ||
|
||
{{post.excerpt | strip_html}} | ||
|
||
{%endfor%} | ||
|
||
{%if paginator.previous_index or paginator.next_index%} | ||
<nav aria-label="Pagination"> | ||
|
||
## Pagination | ||
{{paginator.index}} / {{paginator.total_indexes}} | ||
|
||
{%if paginator.previous_index%} | ||
[Previous page](/{{paginator.previous_index_permalink}}) | ||
{%endif%} | ||
|
||
{%if paginator.next_index%} | ||
[Next page](/{{paginator.next_index_permalink}}) | ||
{%endif%} | ||
|
||
{%if paginator.previous_index%} | ||
[First page](/{{paginator.first_index_permalink}}) | ||
{%endif%} | ||
|
||
{{ post.excerpt | strip_html }} | ||
{%if paginator.next_index%} | ||
[Last page](/{{paginator.last_index_permalink}}) | ||
{%endif%} | ||
|
||
{% endfor %} | ||
</nav> | ||
{%endif%} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function normalize_iso_datetime(dateString) { | ||
// Convert date string into a valid ISO format (inserting colon in the timezone) | ||
const validDateString = dateString.replace(/([+-]\d{2})(\d{2})$/, '$1:$2'); | ||
return validDateString; | ||
} | ||
function local_datetime_string(date_input) { | ||
var r=new Date(date_input); | ||
if (!r) r = new Date(normalize_iso_datetime(date_input)); | ||
const options = { | ||
weekday: "long", | ||
month: "long", | ||
day: "numeric", | ||
year: "numeric" | ||
}; | ||
const toptions = { | ||
hour: "numeric", | ||
minute: "numeric", | ||
second: "numeric", | ||
hour12: true, | ||
timeZoneName: "short" | ||
}; | ||
var final = r.toLocaleDateString("EN-US", options) + " at " + r.toLocaleTimeString("EN-US", toptions); | ||
return final; | ||
} |