feat: split out dividers; proper block sorting
This commit is contained in:
parent
4b908fc3df
commit
1a6e250875
5 changed files with 13 additions and 8 deletions
|
@ -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 () => {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}))
|
||||
|
|
|
@ -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' %}
|
||||
<hr />{% render "partials/widgets/addon-links.liquid", popularPosts:collections.popularPosts, links:links %}
|
||||
{% render "partials/widgets/addon-links.liquid", popularPosts:collections.popularPosts, links:links %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
Reference in a new issue