Skip to content

Commit d8d817a

Browse files
committed
refactor: update share.yml and sidebar.html
Update the share.yml file to add a new platform for Reddit sharing. Also, modify the sidebar.html file to change the site title element to a clickable link. Closes cotes2020#1955
2 parents 1d8f54f + b3b7188 commit d8d817a

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

_data/share.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ platforms:
1414
icon: "fab fa-telegram"
1515
link: "https://t.me/share/url?url=URL&text=TITLE"
1616

17+
- type: Reddit
18+
icon: "fa-brands fa-square-reddit"
19+
link: "https://www.reddit.com/submit?url=URL&title=TITLE"
20+
1721
# Uncomment below if you need to.
1822
#
1923
# - type: Linkedin
@@ -41,10 +45,6 @@ platforms:
4145
# icon: "fa-brands fa-bluesky"
4246
# link: "https://bsky.app/intent/compose?text=TITLE%20URL"
4347
#
44-
# - type: Reddit
45-
# icon: "fa-brands fa-square-reddit"
46-
# link: "https://www.reddit.com/submit?url=URL&title=TITLE"
47-
#
4848
# - type: Threads
4949
# icon: "fa-brands fa-square-threads"
5050
# link: "https://www.threads.net/intent/post?text=TITLE%20URL"

_includes/sidebar.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
{%- endif -%}
1212
</a>
1313

14-
<h1 class="site-title">
15-
<a href="{{ '/' | relative_url }}">{{ site.title }}</a>
16-
</h1>
14+
<a class="site-title d-block" href="{{ '/' | relative_url }}">{{ site.title }}</a>
1715
<p class="site-subtitle fst-italic mb-0">{{ site.tagline }}</p>
1816
</header>
1917
<!-- .profile-wrapper -->

_layouts/home.html

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,45 @@
55

66
{% include lang.html %}
77

8-
{% assign pinned = site.posts | where: 'pin', 'true' %}
9-
{% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
8+
{% assign all_pinned = site.posts | where: 'pin', 'true' %}
9+
{% assign all_normal = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
1010

1111
{% assign posts = '' | split: '' %}
1212

13-
<!-- Get pinned posts -->
13+
<!-- Get pinned posts on current page -->
1414

15-
{% assign offset = paginator.page | minus: 1 | times: paginator.per_page %}
16-
{% assign pinned_num = pinned.size | minus: offset %}
15+
{% assign visible_start = paginator.page | minus: 1 | times: paginator.per_page %}
16+
{% assign visible_end = visible_start | plus: paginator.per_page %}
1717

18-
{% if pinned_num > 0 %}
19-
{% for i in (offset..pinned.size) limit: pinned_num %}
20-
{% assign posts = posts | push: pinned[i] %}
18+
{% if all_pinned.size > visible_start %}
19+
{% if all_pinned.size > visible_end %}
20+
{% assign pinned_size = paginator.per_page %}
21+
{% else %}
22+
{% assign pinned_size = all_pinned.size | minus: visible_start %}
23+
{% endif %}
24+
25+
{% for i in (visible_start..all_pinned.size) limit: pinned_size %}
26+
{% assign posts = posts | push: all_pinned[i] %}
2127
{% endfor %}
2228
{% else %}
23-
{% assign pinned_num = 0 %}
29+
{% assign pinned_size = 0 %}
2430
{% endif %}
2531

26-
<!-- Get default posts -->
32+
<!-- Get normal posts on current page -->
2733

28-
{% assign default_beg = offset | minus: pinned.size %}
34+
{% assign normal_size = paginator.posts | size | minus: pinned_size %}
2935

30-
{% if default_beg < 0 %}
31-
{% assign default_beg = 0 %}
32-
{% endif %}
36+
{% if normal_size > 0 %}
37+
{% if pinned_size > 0 %}
38+
{% assign normal_start = 0 %}
39+
{% else %}
40+
{% assign normal_start = visible_start | minus: all_pinned.size %}
41+
{% endif %}
3342

34-
{% assign default_num = paginator.posts | size | minus: pinned_num %}
35-
{% assign default_end = default_beg | plus: default_num | minus: 1 %}
43+
{% assign normal_end = normal_start | plus: normal_size | minus: 1 %}
3644

37-
{% if default_num > 0 %}
38-
{% for i in (default_beg..default_end) %}
39-
{% assign posts = posts | push: default[i] %}
45+
{% for i in (normal_start..normal_end) %}
46+
{% assign posts = posts | push: all_normal[i] %}
4047
{% endfor %}
4148
{% endif %}
4249

_sass/addon/commons.scss

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -738,20 +738,18 @@ $btn-mb: 0.5rem;
738738
}
739739

740740
.site-title {
741+
@extend %clickable-transition;
742+
@extend %sidebar-link-hover;
743+
741744
font-family: inherit;
742745
font-weight: 900;
743746
font-size: 1.75rem;
744747
line-height: 1.2;
745748
letter-spacing: 0.25px;
746749
margin-top: 1.25rem;
747750
margin-bottom: 0.5rem;
748-
749-
a {
750-
@extend %clickable-transition;
751-
@extend %sidebar-link-hover;
752-
753-
color: var(--site-title-color);
754-
}
751+
width: fit-content;
752+
color: var(--site-title-color);
755753
}
756754

757755
.site-subtitle {

0 commit comments

Comments
 (0)