diff --git a/_includes/post-summary.html b/_includes/post-summary.html new file mode 100644 index 0000000..c9314fc --- /dev/null +++ b/_includes/post-summary.html @@ -0,0 +1,39 @@ +{%- comment -%} + Get the post's description or body content. + + Arguments: + full_text: If true, return the full content. Default is false. + max_length: The maximum length of the returned content. Default is 200. +{%- endcomment -%} + +{%- if post.description and include.full_text != true -%} + {{- post.description -}} +{%- else -%} + {%- comment -%} Remove the line numbers from the code snippet. {%- endcomment -%} + + {%- assign content = post.content -%} + + {%- if content contains '
' -%}
+    {%- assign content = content
+      | replace: '
',
+        '' -%}
+  {%- endif -%}
+
+  {%- assign content = content
+    | markdownify
+    | strip_html
+    | newline_to_br
+    | replace: '
', ' ' + | strip_newlines + | strip + -%} + + {%- unless include.full_text -%} + {%- assign max_length = include.max_length | default: 200 -%} + {%- assign content = content | truncate: max_length -%} + {%- endunless -%} + + {{- content -}} +{%- endif -%} diff --git a/_includes/sidebar.html b/_includes/sidebar.html new file mode 100644 index 0000000..1b9b63c --- /dev/null +++ b/_includes/sidebar.html @@ -0,0 +1,97 @@ + + + + diff --git a/_layouts/home.html b/_layouts/home.html new file mode 100644 index 0000000..2af3ba3 --- /dev/null +++ b/_layouts/home.html @@ -0,0 +1,150 @@ +--- +layout: default +--- + +{% include lang.html %} + +{% assign all_pinned = site.posts | where: 'pin', 'true' %} +{% assign all_normal = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %} + +{% assign posts = '' | split: '' %} + + +{% assign per_page = paginator.per_page | default: site.paginate | default: 10 %} +{% assign page_num = paginator.page | default: 1 %} + + + +{% assign visible_start = page_num | minus: 1 | times: per_page %} +{% assign visible_end = visible_start | plus: per_page %} + +{% if all_pinned.size > visible_start %} + {% if all_pinned.size > visible_end %} + {% assign pinned_size = paginator.per_page %} + {% else %} + {% assign pinned_size = all_pinned.size | minus: visible_start %} + {% endif %} + + {% for i in (visible_start..all_pinned.size) limit: pinned_size %} + {% assign posts = posts | push: all_pinned[i] %} + {% endfor %} +{% else %} + {% assign pinned_size = 0 %} +{% endif %} + + + +{% assign paginator_posts = paginator.posts | default: site.posts %} +{% assign normal_size = paginator_posts | size | minus: pinned_size %} + +{% if normal_size > 0 %} + {% if pinned_size > 0 %} + {% assign normal_start = 0 %} + {% else %} + {% assign normal_start = visible_start | minus: all_pinned.size %} + {% endif %} + + {% assign normal_end = normal_start | plus: normal_size | minus: 1 %} + + {% assign normal_end = 10 %} + + {% for i in (normal_start..normal_end) %} + {% assign posts = posts | push: all_normal[i] %} + {% endfor %} +{% endif %} + + + +
+ {% for post in posts %} +
+ + {% assign card_body_col = '12' %} + + {% if post.image %} + {% assign src = post.image.path | default: post.image %} + + {% if post.media_subpath %} + {% unless src contains '://' %} + {% assign src = post.media_subpath + | append: '/' + | append: src + | replace: '///', '/' + | replace: '//', '/' + %} + {% endunless %} + {% endif %} + + {% if post.image.lqip %} + {% assign lqip = post.image.lqip %} + + {% if post.media_subpath %} + {% unless lqip contains 'data:' %} + {% assign lqip = post.media_subpath + | append: '/' + | append: lqip + | replace: '///', '/' + | replace: '//', '/' + %} + {% endunless %} + {% endif %} + + {% assign lqip_attr = 'lqip="' | append: lqip | append: '"' %} + {% endif %} + + {% assign alt = post.image.alt | xml_escape | default: 'Preview Image' %} + +
+ {{ alt }} +
+ + {% assign card_body_col = '7' %} + {% endif %} + +
+
+

{{ post.title }}

+ +
+

{% include post-summary.html %}

+
+ + + +
+ +
+
+
+ {% endfor %} +
+ + +{% assign total_pages = paginator.total_pages | default: 2 %} +{% if total_pages > 1 and paginator %} + {% include post-paginator.html %} +{% endif %} diff --git a/_tabs/about.md b/_tabs/about.md index aea4e50..6654ac5 100644 --- a/_tabs/about.md +++ b/_tabs/about.md @@ -1,7 +1,7 @@ --- # the default layout is 'page' icon: fas fa-info-circle -order: 4 +order: 0 --- # Sungchan Yi diff --git a/_tabs/archives.md b/_tabs/archives.md index c3abc59..eb89f59 100644 --- a/_tabs/archives.md +++ b/_tabs/archives.md @@ -1,5 +1,5 @@ --- layout: archives icon: fas fa-archive -order: 3 +order: 4 --- diff --git a/_tabs/blog.md b/_tabs/blog.md new file mode 100644 index 0000000..f0bd718 --- /dev/null +++ b/_tabs/blog.md @@ -0,0 +1,13 @@ +--- +title: Blog +layout: home +icon: fas fa-pencil +order: 1 +# pagination: +# enabled: true +# per_page: 10 +# collection: posts +# permalink: '/page/:num/' +--- + +This page serves as the site "Home" (posts listing). It is now a tab in the sidebar. diff --git a/_tabs/categories.md b/_tabs/categories.md index 2d241be..0a3c10a 100644 --- a/_tabs/categories.md +++ b/_tabs/categories.md @@ -1,5 +1,5 @@ --- layout: categories icon: fas fa-stream -order: 1 +order: 2 --- diff --git a/_tabs/tags.md b/_tabs/tags.md index ded3adc..fe3da5a 100644 --- a/_tabs/tags.md +++ b/_tabs/tags.md @@ -1,5 +1,5 @@ --- layout: tags icon: fas fa-tags -order: 2 +order: 3 ---