Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ralpdexterbongato
Copy link

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.

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.
@spenwall
Copy link
Member

spenwall commented May 7, 2019

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.

v-if="$page.wordPressPost.tags"
v-if="$page.wordPressPost.categories"

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">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<template v-if="$page.wordPressPost.tags!=null && $page.wordPressPost.tags.length">
<template v-if="$page.wordPressPost.tags">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants