Skip to content

Commit 266caed

Browse files
committed
Truncato gem を使って「前の作品」「次の作品」のタイトルを一部表示
1 parent c9512af commit 266caed

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ source "https://rubygems.org"
33
gem "jekyll"
44
gem 'rake' # Enable Rakefile to run tasks
55
gem 'rinku' # Enable to add links in texts
6+
gem 'truncato' # Enable to truncate long text
67
gem 'mini_racer' # Enable to run 'docker-compose up'
78

89
group :jekyll_plugins do

Gemfile.lock

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ GEM
4141
yell (~> 2.0)
4242
zeitwerk (~> 2.5)
4343
htmlcompressor (0.4.0)
44+
htmlentities (4.3.4)
4445
http_parser.rb (0.8.0)
4546
i18n (1.14.1)
4647
concurrent-ruby (~> 1.0)
@@ -97,11 +98,11 @@ GEM
9798
mercenary (0.4.0)
9899
mini_racer (0.8.0)
99100
libv8-node (~> 18.16.0.0)
100-
nokogiri (1.15.3-aarch64-linux)
101+
nokogiri (1.15.4-aarch64-linux)
101102
racc (~> 1.4)
102-
nokogiri (1.15.3-arm64-darwin)
103+
nokogiri (1.15.4-arm64-darwin)
103104
racc (~> 1.4)
104-
nokogiri (1.15.3-x86_64-linux)
105+
nokogiri (1.15.4-x86_64-linux)
105106
racc (~> 1.4)
106107
pathutil (0.16.2)
107108
forwardable-extended (~> 2.6)
@@ -133,6 +134,9 @@ GEM
133134
terminal-table (3.0.2)
134135
unicode-display_width (>= 1.1.1, < 3)
135136
timers (4.3.5)
137+
truncato (0.7.12)
138+
htmlentities (~> 4.3.1)
139+
nokogiri (>= 1.7.0, <= 2.0)
136140
ttfunk (1.7.0)
137141
typhoeus (1.4.0)
138142
ethon (>= 0.9.0)
@@ -160,6 +164,7 @@ DEPENDENCIES
160164
mini_racer
161165
rake
162166
rinku
167+
truncato
163168

164169
BUNDLED WITH
165170
2.4.3

tasks/upsert_project_pages_by_data.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env ruby
22

33
# require 'pry' unless ENV['JEKYLL_ENV'] == 'production'
4-
require 'yaml' # https://docs.ruby-lang.org/ja/latest/library/yaml.html
5-
require 'rinku' # https://github.com/vmg/rinku
4+
require 'yaml' # https://docs.ruby-lang.org/ja/latest/library/yaml.html
5+
require 'rinku' # https://github.com/vmg/rinku
6+
require 'truncato' # https://github.com/jorgemanrubia/truncato
7+
t = Truncato
68

79
# Remove existing files and re-generate them
810
# NOTE: もしファイルパスを変更して過去ファイルを消したい場面があれば使う
@@ -66,9 +68,16 @@
6668
</div>
6769
6870
<div class="article-navigation" style="margin-bottom: 100px;">
69-
<a href="/expo/#{project_prev[:id]}" class="previous-article">&lt; 前の作品へ</a>
70-
&nbsp;・&nbsp;
71-
<a href="/expo/#{project_next[:id]}" class="next-article">次の作品へ &gt;</a>
71+
<a href="/expo/#{project_prev[:id]}" title="#{project_prev[:title]}" style="margin-right: 20px;">
72+
<i class="fas fa-arrow-left"></i>
73+
前の作品へ<br>
74+
<span style="font-size: 8px;">#{t.truncate project_prev[:title], max_length: 11}</span>
75+
</a>
76+
<a href="/expo/#{project_next[:id]}" title="#{project_next[:title]}" style="margin-left: 20px;">
77+
次の作品へ
78+
<i class="fas fa-arrow-right"></i><br>
79+
<span style="font-size: 8px;">#{t.truncate project_next[:title], max_length: 11}</span>
80+
</a>
7281
</div>
7382
7483
<style type="text/css">

0 commit comments

Comments
 (0)