Commit d7dd046b authored by Ben Hong's avatar Ben Hong

bug: Fix errors in console with missing length property

parent f71afb6d
...@@ -21,27 +21,19 @@ export default { ...@@ -21,27 +21,19 @@ export default {
const props = this.$options.propsData const props = this.$options.propsData
if (props) { if (props) {
if (this.selectedTag) { if (props.list && props.list.length > 0) {
return props.list.filter(item => { return props.list.filter(item => {
const isBlogPost = item.path.indexOf("/blog/") > -1 const isBlogPost = item.path.indexOf("/blog/") > -1
const isReadyToPublish = new Date(item.frontmatter.date) <= new Date() const isReadyToPublish = new Date(item.frontmatter.date) <= new Date()
const hasTags = item.frontmatter.tags && item.frontmatter.tags.includes(this.selectedTag) const hasTags = item.frontmatter.tags && item.frontmatter.tags.includes(this.selectedTag)
const shouldPublish = this.selectedTag ? isBlogPost && isReadyToPublish && hasTags : isBlogPost && isReadyToPublish
if (isBlogPost && isReadyToPublish && hasTags) { if (shouldPublish) {
return item
}
}).sort((a, b) => new Date(b.frontmatter.date) - new Date(a.frontmatter.date))
} else {
return props.list.filter(item => {
const isBlogPost = item.path.indexOf("/blog/") > -1
const isReadyToPublish = new Date(item.frontmatter.date) <= new Date()
if (isBlogPost && isReadyToPublish) {
return item return item
} }
}).sort((a, b) => new Date(b.frontmatter.date) - new Date(a.frontmatter.date)) }).sort((a, b) => new Date(b.frontmatter.date) - new Date(a.frontmatter.date))
} }
} }
}, },
}, },
...@@ -93,7 +85,7 @@ export default { ...@@ -93,7 +85,7 @@ export default {
</li> </li>
</ul> </ul>
<div class="pagination"> <div v-if="filteredList" class="pagination">
<button v-show="displayRange.start !== 0" <button v-show="displayRange.start !== 0"
@click="previousPage" @click="previousPage"
class="button--pagination" class="button--pagination"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment