-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added additional conditional statements #9
base: master
Are you sure you want to change the base?
Conversation
added additional statements for the category and tags, I found that if the post doesn't have a category or a tag selected, It will give an error saying cannot read property of length. by checking first if a tag or category exist fixed it.
I had this problem too. I think you can simplify this request by just checking the property itself. You don't need to check for != null and then the length. You should be able to just do this.
If the tag or category returns null it will evaluate to false and will not show that section. |
@@ -8,15 +8,15 @@ | |||
:alt="$page.wordPressPost.featuredMedia.title" | |||
/> | |||
<div v-html="$page.wordPressPost.content"/> | |||
<template v-if="$page.wordPressPost.categories.length"> | |||
<template v-if="$page.wordPressPost.categories!=null && $page.wordPressPost.categories.length"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<template v-if="$page.wordPressPost.categories!=null && $page.wordPressPost.categories.length"> | |
<template v-if="$page.wordPressPost.categories"> |
<h4>Posted in</h4> | ||
<ul class="list categories"> | ||
<li v-for="category in $page.wordPressPost.categories" :key="category.id" > | ||
<g-link :to="category.path">{{ category.title }}</g-link> | ||
</li> | ||
</ul> | ||
</template> | ||
<template v-if="$page.wordPressPost.tags.length"> | ||
<template v-if="$page.wordPressPost.tags!=null && $page.wordPressPost.tags.length"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<template v-if="$page.wordPressPost.tags!=null && $page.wordPressPost.tags.length"> | |
<template v-if="$page.wordPressPost.tags"> |
added additional statements for the category and tags, I found that if the post doesn't have a category or a tag selected, It will give an error saying cannot read property of length. by checking first if a tag or category exist fixed it.