Static GitHub Issues

[1351] Server Side Rendering for components called from layouts

prev: Javascript doesn't work when put behind nginx with subdirectory
next: nuxt build and start cannot load vue components properly

Hello ! on my site (https://yineo.fr/), my right sidebar is a component called from layouts/default.vue

Because i don't want to call it in every page component.

I know asyncData() is only for pages and not layouts but maybe they are some workarounds ?

So my sidebar with last articles is not server side rendered and google bot can not see it ( see picture below, the left one is what google bot see and probably index )

How can i have server side rendering for my "Sidebar" Component called from layouts/default.vue ( code below the picture ) ? thanks !

<img width="1101" alt="capture d ecran 2017-08-12 a 04 24 47" src="https://user-images.githubusercontent.com/335495/29237021-c3c1c262-7f15-11e7-9267-b2170831a9cb.png">
<!-- main layout -->
<template>
  <div>
    <AppNavigation />
    <AppHeader/>
  
    <div class="container">
      <div class="columns">
  
        <div class="column is-two-thirds">
          <nuxt/>
        </div>
  
        <div class="column">
          <section class="section">
            <TwitterFollowMe/>
            <hr/>
            <h2 class="title is-2">Derniers billets</h2>
            <PostsSidebar :posts="posts" />
          </section>
        </div>
  
      </div>
    </div>
    <AppFooter />
  </div>
</template>

<script>
import AppHeader from '~/components/AppHeader'
import AppNavigation from '~/components/AppNavigation'
import AppFooter from '~/components/AppFooter'
import TwitterFollowMe from '~/components/TwitterFollowMe'
import PostsSidebar from '~/components/PostsSidebar'
import { getPosts } from '~/services/wpContentApi'

export default {
  components: { AppHeader, AppNavigation, AppFooter, TwitterFollowMe, PostsSidebar },
  data () {
    return {
      posts: []
    }
  },
  async created () {
    this.posts = await getPosts(20)
  }
}
</script>
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1197">#c1197</a>)</em></sub></div>