From 18321ad1c5c09534e39817d9b75070b5481950bd Mon Sep 17 00:00:00 2001
From: Volpeon <git@volpeon.ink>
Date: Wed, 17 Nov 2021 17:43:40 +0100
Subject: Improved list, made header sticky, removed git link

---
 assets/css/components/_card-list.scss   |   6 +-
 assets/css/components/_header.scss      |   2 +
 content/9thPK7O3xn/index.md             |   2 +-
 content/9thPK7O3xn/pages/index.md       |   6 --
 content/9thPK7O3xn/posts/index.md       |   6 ++
 content/docs/index.md                   |   4 --
 content/index.md                        |   3 +-
 content/posts/index.md                  |   4 ++
 content/profiles/git.md                 |   6 --
 scripts/metadata_filter.lua             | 101 ++++++++++++++++++++------------
 templates/layouts/categorized_list.html |  11 ++--
 11 files changed, 90 insertions(+), 61 deletions(-)
 delete mode 100644 content/9thPK7O3xn/pages/index.md
 create mode 100644 content/9thPK7O3xn/posts/index.md
 delete mode 100644 content/docs/index.md
 create mode 100644 content/posts/index.md
 delete mode 100644 content/profiles/git.md

diff --git a/assets/css/components/_card-list.scss b/assets/css/components/_card-list.scss
index 0f44b00..7455193 100644
--- a/assets/css/components/_card-list.scss
+++ b/assets/css/components/_card-list.scss
@@ -23,6 +23,10 @@
         }
 
         @include element('category-title') {
+            display:      inline-block;
+            margin-top:   0;
+            margin-right: 1em;
+
             :link,
             :visited {
                 text-decoration: none;
@@ -33,7 +37,7 @@
             }
         }
 
-        @include element('category-subtitle') {
+        @include element('category-description') {
             display: block;
 
             p {
diff --git a/assets/css/components/_header.scss b/assets/css/components/_header.scss
index 9afa2e6..1470bea 100644
--- a/assets/css/components/_header.scss
+++ b/assets/css/components/_header.scss
@@ -72,6 +72,8 @@
         }
 
         @include media('>=lg') {
+            position:      sticky;
+            top:           2px;
             margin-bottom: calc(-.75 * #{prop(--dims --height)});
         }
     }
diff --git a/content/9thPK7O3xn/index.md b/content/9thPK7O3xn/index.md
index 58272fb..1dd3b1e 100644
--- a/content/9thPK7O3xn/index.md
+++ b/content/9thPK7O3xn/index.md
@@ -5,4 +5,4 @@ feed:     true
 ---
 
 Welcome to the personal section of my website!
-Here you will find content that doesn't belong in the public sections of my website such as test pages or essays about more personal topics.
+Here you will find content that doesn't belong in the public sections of my website such as test pages or posts about more personal topics.
diff --git a/content/9thPK7O3xn/pages/index.md b/content/9thPK7O3xn/pages/index.md
deleted file mode 100644
index 4c42948..0000000
--- a/content/9thPK7O3xn/pages/index.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title:                Pages
-position:             0
-list_read_indicators: true
-feed:                 true
----
diff --git a/content/9thPK7O3xn/posts/index.md b/content/9thPK7O3xn/posts/index.md
new file mode 100644
index 0000000..8801530
--- /dev/null
+++ b/content/9thPK7O3xn/posts/index.md
@@ -0,0 +1,6 @@
+---
+title:                Posts
+position:             0
+list_read_indicators: true
+feed:                 true
+---
diff --git a/content/docs/index.md b/content/docs/index.md
deleted file mode 100644
index d02c2a8..0000000
--- a/content/docs/index.md
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title:    Documents
-position: 3
----
diff --git a/content/index.md b/content/index.md
index 75efead..f6e7893 100644
--- a/content/index.md
+++ b/content/index.md
@@ -1,5 +1,6 @@
 ---
-title: Volpeon's Den
+title:      Volpeon's Den
+list_limit: 4
 ---
 
 Hi, I'm Volpeon! I'm a software developer who creates vector art.
diff --git a/content/posts/index.md b/content/posts/index.md
new file mode 100644
index 0000000..4396e20
--- /dev/null
+++ b/content/posts/index.md
@@ -0,0 +1,4 @@
+---
+title:    Posts
+position: 3
+---
diff --git a/content/profiles/git.md b/content/profiles/git.md
deleted file mode 100644
index 63b1bfc..0000000
--- a/content/profiles/git.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title:    Git
-subtitle: git.vulpes.one
-icon:     git-branch
-url:      https://git.vulpes.one/
----
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua
index 5a547ee..5fa7dfc 100644
--- a/scripts/metadata_filter.lua
+++ b/scripts/metadata_filter.lua
@@ -9,6 +9,16 @@ function pandoc.List:flatMap(fn)
     return result
 end
 
+function pandoc.List:take(n)
+    if n >= #self then return self end
+
+    local result = pandoc.List()
+
+    for i = 1, n do result:insert(self[i]) end
+
+    return result
+end
+
 function format_date(date)
     if not date then return date end
 
@@ -186,6 +196,8 @@ end
 function generate_list(meta)
     if not meta.pages then return nil end
 
+    local limit = (meta.list_limit and tonumber(pandoc.utils.stringify(meta.list_limit))) or 9999
+
     if meta.depth == "1" then
         return meta.pages.all:map(function(p)
             return {
@@ -200,57 +212,69 @@ function generate_list(meta)
         end)
     elseif meta.depth == "2" then
         return meta.pages.all:map(function(cat)
+            local allItems = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p)
+                return {
+                    title = p.title,
+                    subtitle = p.subtitle,
+                    date = p.date,
+                    url = p.url,
+                    icon = p.icon or cat.icon,
+                    post_icon = cat.list_post_icon or meta.list_post_icon,
+                    indicator = cat.list_read_indicators,
+                }
+            end)
+            local items = allItems:take(limit)
+            local omitted = #allItems - #items
+
             return {
                 title = cat.title,
                 content = cat.content,
                 url = cat.url,
                 grid = cat.list_grid,
-                items = ((cat.pages and cat.pages.all) or pandoc.List()):map(function(p)
-                    return {
-                        title = p.title,
-                        subtitle = p.subtitle,
-                        date = p.date,
-                        url = p.url,
-                        icon = p.icon or cat.icon,
-                        post_icon = cat.list_post_icon or meta.list_post_icon,
-                        indicator = cat.list_read_indicators,
-                    }
-                end),
+                items = items,
+                total = tostring(#allItems),
+                omitted = omitted ~= 0 and tostring(omitted),
             }
         end):filter(function(cat) return #cat.items ~= 0 end)
     elseif meta.depth == "3" then
         return meta.pages.all:map(function(cat)
+            local allItems = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c)
+                if c.pages then
+                    return c.pages.all:map(function(p)
+                        return {
+                            title = p.title,
+                            subtitle = p.subtitle,
+                            category = c.title,
+                            url = p.url,
+                            icon = p.icon or c.icon,
+                            post_icon = c.list_post_icon or cat.list_post_icon,
+                            indicator = c.list_read_indicators,
+                        }
+                    end)
+                else
+                    local l = pandoc.List()
+                    l:insert({
+                        title = c.title,
+                        subtitle = c.subtitle,
+                        url = c.url,
+                        icon = c.icon or cat.icon,
+                        post_icon = cat.list_post_icon,
+                        indicator = cat.list_read_indicators,
+                    })
+                    return l
+                end
+            end)
+            local items = allItems:take(limit)
+            local omitted = #allItems - #items
+
             return {
                 title = cat.title,
                 content = cat.content,
                 url = cat.url,
                 grid = cat.list_grid,
-                items = (cat.pages and cat.pages.all or pandoc.List()):flatMap(function(c)
-                    if c.pages then
-                        return c.pages.all:map(function(p)
-                            return {
-                                title = p.title,
-                                subtitle = p.subtitle,
-                                category = c.title,
-                                url = p.url,
-                                icon = p.icon or c.icon,
-                                post_icon = c.list_post_icon or cat.list_post_icon,
-                                indicator = c.list_read_indicators,
-                            }
-                        end)
-                    else
-                        local l = pandoc.List()
-                        l:insert({
-                            title = c.title,
-                            subtitle = c.subtitle,
-                            url = c.url,
-                            icon = c.icon or cat.icon,
-                            post_icon = cat.list_post_icon,
-                            indicator = cat.list_read_indicators,
-                        })
-                        return l
-                    end
-                end),
+                items = items,
+                total = tostring(#allItems),
+                omitted = omitted ~= 0 and tostring(omitted),
             }
         end):filter(function(cat) return #cat.items ~= 0 end)
     end
@@ -293,7 +317,8 @@ function process(global, parent, meta)
     meta.pages =
         process_pages(global, { parent = parent, meta = meta }, meta.list_order, meta.pages)
     meta.depth = (meta.pages and find_depth(meta.pages.all)) or "0"
-    meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or resolve_layout(meta.depth))
+    meta.layout = prep_layout(meta.layout or (meta.redirect and "redirect") or
+                                  resolve_layout(meta.depth))
 
     if meta.date then
         meta.date = format_date(meta.date)
diff --git a/templates/layouts/categorized_list.html b/templates/layouts/categorized_list.html
index adeb762..c5a76b2 100644
--- a/templates/layouts/categorized_list.html
+++ b/templates/layouts/categorized_list.html
@@ -8,11 +8,14 @@ $body$
     $for(list)$
         <section>
             <header class="c-card-list__category-header">
-                <h2 class="c-card-list__category-title">
-                    <a href="$it.url.rel$">$it.title$</a>
-                </h2>
+                <div>
+                    <h2 class="c-card-list__category-title">
+                        <a href="$it.url.rel$">$it.title$ →</a>
+                    </h2>
+                    $if(it.omitted)$<small>$it.omitted$ more</small>$endif$
+                </div>
                 $if(it.content)$
-                    <small class="c-card-list__category-subtitle">$it.content$</small>
+                    <small class="c-card-list__category-description">$it.content$</small>
                 $endif$
             </header>
             $if(it.grid)$
-- 
cgit v1.2.3-70-g09d2