diff --git a/src/pages/candidates/[candidate].astro b/src/pages/candidates/[candidate].astro index b535988..d8de3fb 100644 --- a/src/pages/candidates/[candidate].astro +++ b/src/pages/candidates/[candidate].astro @@ -91,6 +91,10 @@ export async function getStaticPaths() { }; }); + const hasAnswers = questions.some((question) => + question.answers.some((answer) => Boolean(answer.answer)) + ); + return { params: { candidate: lodash.kebabCase(candidateFullName), @@ -100,6 +104,7 @@ export async function getStaticPaths() { candidateAreaName, candidateAreaLocalAuthorityName, questions, + hasAnswers, }, }; }); @@ -110,6 +115,7 @@ const { candidateAreaName, candidateAreaLocalAuthorityName, questions, + hasAnswers, } = Astro.props; --- @@ -127,14 +133,22 @@ const {
{ - questions.map((question) => ( - <> - {question.text} - {question.answers.map((answer) => ( -

{answer.answer}

- ))} - - )) + hasAnswers ? ( + questions.map((question) => ( + <> + {question.text} + {question.answers.map((answer) => ( +

{answer.answer}

+ ))} + + )) + ) : ( +

+ If you're a voter in this candidate's area and you'd like them to + answer these questions, please email them and tell them this: + <placeholder-email@example.com>. +

+ ) }