cleaned up and fixed pagination, pages not published are not show on archive page

This commit is contained in:
Ro 2020-06-25 15:15:19 -07:00
parent 4387591661
commit 56fc6cbe7b
5 changed files with 117 additions and 29 deletions

View file

@ -80,6 +80,7 @@ export default class Utils {
moment(page.metadata.created).format('YYYY') === item.year &&
moment(page.metadata.created).format('MM') === month &&
page.metadata.deleted === false &&
page.metadata.published === true &&
page.metadata.layout !== 'index'
);
})

View file

@ -25,12 +25,30 @@ router.get('/list/:filter?/:page?', function (req, res) {
for (let index = 0; index < pages.length; index++) {
let item = pages[index].metadata;
if (typeof item.deleted === 'undefined' || item.deleted === false) {
all.push(pages[index].metadata);
if (item.published == true) published.push(pages[index].metadata);
if (item.menu == true) menu.push(pages[index].metadata);
if (item.featured == true) featured.push(pages[index].metadata);
all.push({
page: pages[index].metadata,
date: moment(pages[index].metadata.created).fromNow()
});
if (item.published == true)
published.push({
page: pages[index].metadata,
date: moment(pages[index].metadata.created).fromNow()
});
if (item.menu == true)
menu.push({
page: pages[index].metadata,
date: moment(pages[index].metadata.created).fromNow()
});
if (item.featured == true)
featured.push({
page: pages[index].metadata,
date: moment(pages[index].metadata.created).fromNow()
});
} else {
deleted.push(pages[index].metadata);
deleted.push({
page: pages[index].metadata,
date: moment(pages[index].metadata.created).fromNow()
});
}
}
var filtered;
@ -45,14 +63,17 @@ router.get('/list/:filter?/:page?', function (req, res) {
filtered = all;
break;
}
var count = Math.round(filtered.length / 6);
var count = Math.ceil(filtered.length / 6);
var pageItems = [];
var itemLimit = 6;
var rangeStart = pageNum * itemLimit - itemLimit;
for (var i = 0; i < itemLimit; i++) {
try {
if (filtered[i + rangeStart].id != null) {
pageItems.push(filtered[i + rangeStart]);
if (filtered[i + rangeStart].page.id != null) {
pageItems.push({
page: filtered[i + rangeStart].page,
date: moment(filtered[i + rangeStart].page.created).fromNow()
});
}
} catch (e) {
//console.log("NO POST", e)

View file

@ -23,24 +23,33 @@ block main-content
#posts-list
- var index = 0;
- for ( index; index < items.length; index++)
a.post-link(href="/@/dashboard/page/edit/"+items[index].uuid id=items[index].uuid)
a.page-link(href="/@/dashboard/page/edit/"+items[index].page.uuid id=items[index].uuid)
div.page-bg(style="background: #fc6399 url("+items[index].page.feature+") no-repeat center center / cover")
#meta
- var menu = String(items[index].page.menu)
- var published = String(items[index].page.published)
- var featured = String(items[index].page.featured)
span= items[index].date
label= items[index].page.title
br
#options
span.meta-options(data-active=menu) MENU ITEM
span.meta-options(data-active=published) PUBLISHED
span.meta-options(data-active=featured) FEATURED
div.post-bg(style="background: #fc6399 url("+items[index].feature+") no-repeat center center / cover")
label= items[index].title
span= items[index].created
//p= items[index].plaintext.substr(0, 200)+"..."
- var next = parseInt(page_index, 10) + 1
- var prev = parseInt(page_index, 10) - 1
- if(next > page_count) next = 1
- if(prev <= 0) prev = page_count
- if(page_count > 1)
br
.paginate
a.page-btns(href="/@/dashboard/page/list/"+postFilter+"/"+prev)
svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/assets/images/global/sprite.svg#entypo-chevron-left')
span.paginate= "PAGE "+page_index+" OF "+page_count
span.count= "PAGE "+page_index+" OF "+page_count
a.page-btns(href="/@/dashboard/page/list/"+postFilter+"/"+next)
svg(viewBox="0 0 20 20" class="icons")

View file

@ -152,10 +152,7 @@
bottom 0
border-radius 0 0 3px 3px
//background-opacity($black, .35)
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#000000+0,000000+100&0+0,0.65+100 */
background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0.65) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%);
#options
display block

View file

@ -30,7 +30,7 @@
#posts-list
margin 20px 0 0 0
a.post-link
a.page-link
background $white
display inline-block
vertical-align top
@ -57,15 +57,75 @@
width 50%
padding 0 0 0 10px
div.post-bg
div.page-bg
width 100%
height 350px
background-color $highlight
position relative
#meta
width 100%
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%);
border-radius 3px
margin auto
bottom 0
position absolute
padding 0 0 20px 0
span
color $white
text-align center
margin 0 auto
display block
label
font-size 1.4em
font-weight 700
color $white
padding 5px
vertical-align top
display inline-block
word-wrap break-word
width 100%
text-align center
text-drop-shadow($black, 1, 2px, 2px, 0)
#options
margin 0 auto
width: 275px
.meta-options
border-radius 3px
margin 5px
display inline-block
text-align: center
padding 2px
.meta-options[data-active='false']
width 70px
background $primary - 60%
color $white
.meta-options[data-active='true']
width 75px
background $tertiary + 50%
color $primary - 60%
p
padding 5px 10px 5px 10px
font-size 1.2em
font-weight 400
.paginate
width 260px
display block
margin 0 auto
a
display inline-block
vertical-align: top
span.count
text-align center
padding 5px
margin-top -2px
display inline-block
width 200px
font-size: 1.5em
color $tertiary
#post-edit-index
width 100%