Show FAQs in Vue - The Simple Way

In one of the recent projects there was this requirement to create a FAQ page for a small application. The change was not planned and came up during the final stages of the project.

I took it in the same spirit as what I do for a home page. I did not plan to use SSR or a static-site generator, but rather leaned back on the excellent ‘prerender-spa-plugin’.

prerender-spa-plugin will take care of pre-rendering the content, and I don’t need to worry on the performance or the SEO side of things.

(PS: I have not used Nuxt in my real-world project yet. Though I sometimes wonder why. This would have been far simpler.)

The next problem was to create FAQs in a page.

The ideal solution was to have FAQs sitting as static content (e.g. a CSV file) processed during render (or, during generation of the static page). Or, FAQs coming in from a database table that can be changed by an admin using the ‘admin’ application.

With the given time constraint and considering the fact that FAQ will not change for months at end, I decided on a far simpler but not-quite-scalable approach - included the static FAQs within a component and threw in custom CSS to format the FAQs.

    <v-container grid-list-md class="mt-5">
      <v-layout row wrap>
        <v-flex xs12>
          <div class="amber--text display-2">FAQ</div>

        <ol class="ml-3 mt-5">
          <template v-for="(item, index) in faqs">
            <div :key="index" class="body-2 mt-4">
                <br />
                <br />
                <span class="body-1" v-html="item['answer']"></span>

  import { mapState, mapActions } from "vuex";

  export default {
    data() {
      return {
        faqs: [
            question: "What is the answer to life?",
            answer: "42"

Does the solution work? Yes.

Was the client happy? Yes.

Am I proud of what I did? Not quite.

comments powered by Disqus