-
Notifications
You must be signed in to change notification settings - Fork 32
Home
Welcome to the contenta_vue_nuxt wiki!
Please first make sure to read project objectives; as dev guidelines are built upon that : https://github.com/contentacms/contenta_vue_nuxt#objectives-guidelines--what-are-we-doing-and-why--
- components pages are responsible to fetch all datas ( deserving to be indexed by Search Engines) from contenta public API
- Pages components fetch data via "services" located in "services" directory
- Fetched datas MUST flows down from pages components to components children (one way data flow )
- components children should events up if needed
- a store may be added if it is required by components communication and if events are not a good answer. But "pure" components and internal state is preferred when possible for unit testing (and reusability betweenpages) purposes
- Each component SHOULD have a corresponding unit test in "test" directory
- NO OVER-ENGINEERING : we want to convince people that this is awesome to build Drupal Healdess site With Vue.js !
Page components are special components located in "pages" directory. They are server side rendered automatically by Nuxt, making our application content crawlable by search engines. Pages fetch content from contenta API and should be a composition of existing components, passing them data they need.
This is illustrated by this very simple example displaying a recipe page : recipeAsDetail component is easy to unit test because it only needs a recipe passed as a prop.
<template>
<RecipeAsDetail :recipe="recipe" />
</template>
<script>
import Recipes from '~/services/Recipes'
import RecipeAsDetail from '~/components/RecipeAsDetail'
export default {
components: { RecipeAsDetail },
async asyncData ({ params }) {
const recipe = await Recipes.findOneById(params.id)
return { recipe }
}
}
</script>
See "components" directory
I borrowed "view mode" concept from Drupal : component "recipeAsTeaser" display recipe as a teaser (title, image, description) and takes a recipe as an argument. "recipeAsDetail" display the full recipe detail. "recipesAsTeaser" is the same thing but for listing.
All components beginning with "Bulma" prefix are reusable components using bulma classes, to create a grid for example. Here is how to use bulma css ("Card")[http://bulma.io/documentation/components/card/]
<BulmaCard>
<div slot="image" v-if="node.image" class="thumbnail">
<img v-if="node.image" :src="node.image.thumbnail.filename" />
</div>
<div slot="content">
your custom card content
</div>
</BulmaCard>
very small piece of design that is shared by a lot of places in the site, for example the "view more" button.