Fixed ordering for next/previous
This commit is contained in:
parent
e0bee5292d
commit
9afbb737c0
@ -50,3 +50,6 @@ sites:
|
|||||||
addons:
|
addons:
|
||||||
- rss
|
- rss
|
||||||
|
|
||||||
|
# TODO: add Jimoire Laboratoire
|
||||||
|
# TODO: add newsletter
|
||||||
|
|
||||||
@ -107,12 +107,15 @@ def build_articles(
|
|||||||
'''Generates HTML files for all of a given site's Markdown articles
|
'''Generates HTML files for all of a given site's Markdown articles
|
||||||
by interpolating the contents and metadata into the HTML templates.'''
|
by interpolating the contents and metadata into the HTML templates.'''
|
||||||
|
|
||||||
|
# Sort the articles in order of ascending date.
|
||||||
|
sorted_articles = sorted([*index.values()], key = lambda a: a.metadata.date)
|
||||||
|
|
||||||
# Include the previous and next articles (if available) in the iteration
|
# Include the previous and next articles (if available) in the iteration
|
||||||
# in case the article template wants to link to them.
|
# in case the article template wants to link to them.
|
||||||
for previous_article, article, next_article in zip(
|
for previous_article, article, next_article in zip(
|
||||||
([None] + [*index.values()][:-1]),
|
([None] + sorted_articles[:-1]),
|
||||||
index.values(),
|
sorted_articles,
|
||||||
([*index.values()][1:] + [None])
|
(sorted_articles[1:] + [None])
|
||||||
):
|
):
|
||||||
# Create a dummy to be used for the first article's "previous" and the last
|
# Create a dummy to be used for the first article's "previous" and the last
|
||||||
# article's "next" to avoid errors if trying to access into None.
|
# article's "next" to avoid errors if trying to access into None.
|
||||||
|
|||||||
@ -21,8 +21,8 @@ def pull_git_repo(repo: GitRepo, build_cache: str) -> None:
|
|||||||
|
|
||||||
# Download all LFS files.
|
# Download all LFS files.
|
||||||
if repo.lfs:
|
if repo.lfs:
|
||||||
run('git -C {build_cache} lfs fetch --all')
|
run(f'git -C {build_cache} lfs fetch --all')
|
||||||
run('git -C {build_cache} lfs pull')
|
run(f'git -C {build_cache} lfs pull')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from typing import Union
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def run(cmd: Union[list,str], log_errors = True, debug = True) -> tuple:
|
def run(cmd: Union[list,str]) -> tuple:
|
||||||
|
|
||||||
if isinstance(cmd, str):
|
if isinstance(cmd, str):
|
||||||
cmd = cmd.split(' ')
|
cmd = cmd.split(' ')
|
||||||
@ -21,10 +21,7 @@ def run(cmd: Union[list,str], log_errors = True, debug = True) -> tuple:
|
|||||||
res.stderr = res.stderr.decode().strip()
|
res.stderr = res.stderr.decode().strip()
|
||||||
res.cmd = cmd
|
res.cmd = cmd
|
||||||
|
|
||||||
if debug:
|
if res.stderr:
|
||||||
logger.debug(res)
|
|
||||||
|
|
||||||
if log_errors and res.stderr:
|
|
||||||
logger.exception(res.stderr)
|
logger.exception(res.stderr)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
@ -208,7 +208,7 @@ img.rss-icon{
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
span img.rss-icon{
|
a > img.rss-icon{
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,6 @@
|
|||||||
<h2>Post History</h2>
|
<h2>Post History</h2>
|
||||||
{content}
|
{content}
|
||||||
<br /><hr /><br />
|
<br /><hr /><br />
|
||||||
<p>Last Updated: {globalvars.today}<span>{templates.components.rss_icon}</span></p>
|
<p>Last Updated: {globalvars.today}{templates.components.rss_icon}</p>
|
||||||
</article>
|
</article>
|
||||||
<script src="/assets/js/blog_archive_query.js"></script>
|
<script src="/assets/js/blog_archive_query.js"></script>
|
||||||
@ -13,7 +13,8 @@
|
|||||||
<br /><hr /><br />
|
<br /><hr /><br />
|
||||||
<p>
|
<p>
|
||||||
<a href="{previous_article.path}" title="{previous_article.metadata.title}" data="{previous_article.path}" class="previous-article-link">< Previous</a>
|
<a href="{previous_article.path}" title="{previous_article.metadata.title}" data="{previous_article.path}" class="previous-article-link">< Previous</a>
|
||||||
|
<!-- This non-breaking space prevents the RSS icon from getting weird when previous-article-link is hidden. -->
|
||||||
<a href="{next_article.path}" title="{next_article.metadata.title}" data="{next_article.path}" class="next-article-link">Next ></a>
|
<a href="{next_article.path}" title="{next_article.metadata.title}" data="{next_article.path}" class="next-article-link">Next ></a>
|
||||||
</p>
|
</p>
|
||||||
<p>Tags: {blog_tags}<span>{templates.components.rss_icon}</span></p>
|
<p>Tags: {blog_tags}{templates.components.rss_icon}</p>
|
||||||
</article>
|
</article>
|
||||||
Loading…
x
Reference in New Issue
Block a user