From 1a6e250875206fe685ae082c43fa26b1fb977faf Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 14 Jul 2024 21:17:17 -0700 Subject: [PATCH] feat: split out dividers; proper block sorting --- package-lock.json | 4 ++-- package.json | 2 +- src/_data/pages.js | 5 +++-- src/_data/posts.js | 6 ++++-- src/_includes/partials/blocks/index.liquid | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2fabf898..ec2eb9ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "20.5.0", + "version": "20.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "20.5.0", + "version": "20.6.0", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", diff --git a/package.json b/package.json index 48a8e695..daefd507 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "20.5.0", + "version": "20.6.0", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/pages.js b/src/_data/pages.js index 1115a94f..39b04728 100644 --- a/src/_data/pages.js +++ b/src/_data/pages.js @@ -24,7 +24,7 @@ const fetchBlockData = async (collection, itemId) => { const fetchBlocksForPage = async (pageId) => { const { data, error } = await supabase .from('pages_blocks') - .select('collection, item') + .select('collection, item, sort') .eq('pages_id', pageId) if (error) { @@ -37,11 +37,12 @@ const fetchBlocksForPage = async (pageId) => { return { type: block['collection'], + sort: block['sort'], ...blockData } })) - return blocks + return blocks.sort((a, b) => a.sort - b.sort) } const fetchAllPages = async () => { diff --git a/src/_data/posts.js b/src/_data/posts.js index adaa4c10..c3a5cf06 100644 --- a/src/_data/posts.js +++ b/src/_data/posts.js @@ -38,7 +38,7 @@ const fetchTagsForPost = async (postId) => { const fetchBlocksForPost = async (postId) => { const { data, error } = await supabase .from('posts_blocks') - .select('collection, item') + .select('collection, item, sort') .eq('posts_id', postId) if (error) { @@ -48,8 +48,10 @@ const fetchBlocksForPost = async (postId) => { const blocks = await Promise.all(data.map(async block => { const blockData = await fetchBlockData(block.collection, block.item) + return { - type: block.collection, + type: block['collection'], + sort: block['sort'], ...blockData } })) diff --git a/src/_includes/partials/blocks/index.liquid b/src/_includes/partials/blocks/index.liquid index 89e6bbae..e14e9fc1 100644 --- a/src/_includes/partials/blocks/index.liquid +++ b/src/_includes/partials/blocks/index.liquid @@ -11,7 +11,9 @@ {% render "partials/blocks/hero.liquid", image:block.image.filename_disk, alt:block.alt_text %} {% elsif block.type == 'markdown' %} {{ block.text | markdown }} + {% elsif block.type == 'divider' %} + {{ block.markup | markdown }} {% elsif block.type == 'addon_links' %} -
{% render "partials/widgets/addon-links.liquid", popularPosts:collections.popularPosts, links:links %} + {% render "partials/widgets/addon-links.liquid", popularPosts:collections.popularPosts, links:links %} {% endif %} {% endfor %} \ No newline at end of file