Par Sébastien Rodriguez
@sebtiz13
Pléthore de CMS
(Wordpress, Drupal, Joomla)
Apache / Nginx ou Serverless
<?php $MyCMS->get_post(12); ?>
<h1>
<?php echo post_title(); ?>
</h1>
<?php echo post_contents(); ?>
[
{
id: 12,
title: "Exemple title",
authorName: "Sebtiz13",
dateCreated: "2019-02-13 20:30:00",
postContent: "<p>Exemple content</p>"
}
]
Vue.js
<template>
<section>
<h1>Les derniers articles</h1>
<l-article
v-for="post in posts"
:key="post.id"
:post="post"
/>
</section>
</template>
<script>
export default {
async asyncData () {
// Récupère les articles
const posts = await this.$axios.get('/posts').then(({ data }) => data.map(post => {
// Fait quelque chose
return post
}))
// Retourne les posts
return { posts }
}
}
</script>
<div data-server-rendered="true" id="__nuxt">
<!---->
<div id="__layout">
<section>
<h1>Les derniers articles</h1>
<article>
<img src="http://cdn.sebtiz13.fr/example.jpg" alt="example">
<main>content</main>
<a href="/articles/example">Lire la suite</a>
</article>
</section>
</div>
</div>
<script>
window.__NUXT__ = (function (a, b, c) {
return {
layout: "default",
data: [{ posts: [{ ... }] }],
error: null,
serverRendered: true
}
}("...", "...", "..."));
</script>
Tendance de recherche :