Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各ページのフッターから「次の投稿」「前の投稿」にワンクリックで遷移できるようにした #340

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_data/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ share:
ja: 'シェア'

back:
en: 'Back'
ja: '戻る'
en: 'Back to index'
ja: '目次に戻る'

jekyll:
en: '<a href="https://jekyllrb.com/">Jekyll</a>'
Expand Down
58 changes: 48 additions & 10 deletions docs/_layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ <h1 class="post-title" data-aos="fade-up" data-aos-delay="200" data-aos-offset="
<p><small>
{{ site.data.translations.link[page.lang] }}: <a href="{{ page.link }}">{{ page.link }}</a><br>

{% assign urls = site.posts | map: 'url' | sort %}
{% assign posts = site.posts | sort: 'date' | reverse %}
{% assign urls = posts | map: 'url' %}
{% assign url_en = page.url | replace_first: page.lang, 'en' %}
{% assign url_ja = page.url | replace_first: page.lang, 'ja' %}
{% if page.lang == 'en' and urls contains url_ja %}
Expand All @@ -38,15 +39,52 @@ <h1 class="post-title" data-aos="fade-up" data-aos-delay="200" data-aos-offset="
{% endif %}

{% assign url = page.url | split: '/' | last %}
{{ site.data.translations.share[page.lang] }}: <a href='https://twitter.com/intent/tweet?text={{ page.title }}&hashtags=RemoteWorkJP&lang={{ page.lang }}&url={{ site.url }}/{{ page.lang }}/{{ url | cgi_escape | url_encode }}'><i class="fa-brands fa-x-twitter"></i></a>
{{ site.data.translations.share[page.lang] }}: <a href='https://twitter.com/intent/tweet?text={{ page.title }}&hashtags=RemoteWorkJP&lang={{ page.lang }}&url={{ site.url }}/{{ page.lang }}/{{ url | cgi_escape | url_encode }}'><i class="fa-brands fa-x-twitter"></i></a><br>
<br>
{% assign this_lang_posts = posts | where: 'lang', page.lang %}
{% assign current_index = nil %}
{% for tlp in this_lang_posts %}
{% if tlp.url == page.url %}
{% assign current_index = forloop.index0 %}
{% endif %}
{% endfor %}

{% assign prev_index = current_index | minus: 1 %}
{% assign next_index = current_index | plus: 1 %}
{% if prev_index == -1 %}{% assign prev_index = this_lang_posts.size | minus: 1 %}{% endif %}
{% if next_index == this_lang_posts.size %}{% assign next_index = 0 %}{% endif %}
<style>
.nav-wrapper {
display: flex;
justify-content: space-between; /* 左右端に配置 */
align-items: center; /* 垂直方向で中央揃え */
width: 100%;
padding: 10px;
}
.prev { text-align: left; }
.toc { text-align: center; }
.next { text-align: right; }
.clearfix { clear: both; } /* 直前の float を解除 */
</style>
<div class='clearfix'></div>
<div class="nav-wrapper">
<div class="prev">
&laquo;
<a href="{{ this_lang_posts[prev_index].url }}">
{{ this_lang_posts[prev_index].title | remove_first: '株式会社' }}
</a>
</div>
<div class="next">
<a href="{{ this_lang_posts[next_index].url }}">
{{ this_lang_posts[next_index].title | remove_first: '株式会社' }}
</a>
&raquo;
</div>
</div>
<div class="toc">
<small><a href="/{{ page.lang }}">{{ site.data.translations.back[page.lang] }}</a></small>
</div>

</small></p>

<p>
<small><a href="/{{ page.lang }}">« {{ site.data.translations.back[page.lang] }}</a></small>
</p>
</article>

{% comment %}
<small>{{ site.data.translations.postCreatedBy[page.lang] }} <b>{{ page.by }}</b></small>
{% endcomment %}
</div>
Loading