mirror of
https://github.com/ArthurDanjou/website-old.git
synced 2026-01-26 01:40:32 +01:00
Importing blog
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -60,7 +60,7 @@ typings/
|
|||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env
|
src/.env
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default {
|
export default {
|
||||||
baseUrl: 'http://localhost:3333',
|
credentials: true,
|
||||||
credentials: true
|
baseURL: 'http://localhost:5555/'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/typescript-runtime": "^2.0.0",
|
"@nuxt/typescript-runtime": "^2.0.0",
|
||||||
"@nuxtjs/axios": "^5.12.2",
|
"@nuxtjs/axios": "5.12.1",
|
||||||
"core-js": "^3.7.0",
|
"core-js": "^3.7.0",
|
||||||
"nuxt": "^2.14.6",
|
"nuxt": "^2.14.6",
|
||||||
"sass": "^1.29.0",
|
"sass": "^1.29.0",
|
||||||
|
|||||||
@@ -4,4 +4,3 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<article class="hover:bg-gray-200 dark:hover:bg-dark-800 border-2 border-solid border-black dark:border-white w-full h-auto h-blog p-2 flex flex-col justify-between my-5 duration-300">
|
<article
|
||||||
|
class="w-full h-blog p-2 flex flex-col justify-between my-5"
|
||||||
|
:style="{ backgroundImage: 'url(http://localhost:5555/files/' + cover.file_name + ')' }"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-3xl font-bold text-justify leading-7 mb-3">{{title}}</p>
|
<p class="text-3xl text-white font-bold text-justify leading-7 mb-3">{{title}}</p>
|
||||||
<p class="dark:text-dark-900 text-gray-900 text-lg italic text-justify leading-5">{{description}}</p>
|
<p class="text-dark-900 text-lg italic text-justify leading-5">{{description}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mt-8">
|
<div class="flex justify-between mt-8 text-dark-900">
|
||||||
<div>
|
<div>
|
||||||
<div>{{date}}</div>
|
<div>{{formatDate}}</div>
|
||||||
<div>{{reading_time}} min read</div>
|
<div>{{reading_time}} min read</div>
|
||||||
|
<div>{{likes}} ❤</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="self-end flex flex-wrap">
|
<div class="self-end flex flex-wrap flex-col md:flex-row">
|
||||||
<div v-for="tag in tagsSplit" class="ml-2 py-1 px-2 dark:bg-white dark:text-black rounded bg-black text-white font-semibold">
|
<div v-for="(tag) in tags" class="my-1 md:my-0 ml-2 py-1 px-2 bg-white text-black rounded font-semibold">
|
||||||
#{{tag}}
|
#{{tag}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,16 +35,20 @@ export default {
|
|||||||
default: "New Post's description"
|
default: "New Post's description"
|
||||||
},
|
},
|
||||||
reading_time: {
|
reading_time: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: "0"
|
default: 0
|
||||||
},
|
},
|
||||||
date: {
|
date: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "Today"
|
default: "Today"
|
||||||
},
|
},
|
||||||
|
likes: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: String,
|
type: Array,
|
||||||
default: "Tag1 Tag2 Tag3",
|
default: () => ["Tag1", "Tag2", "Tag3"],
|
||||||
},
|
},
|
||||||
cover: {
|
cover: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -49,8 +57,15 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
tagsSplit() {
|
tagsSplit() {
|
||||||
return this.tags.split(" ")
|
return this.tags.keys
|
||||||
}
|
},
|
||||||
|
formatDate() {
|
||||||
|
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"
|
||||||
|
];
|
||||||
|
const date = new Date(this.date)
|
||||||
|
return date.getDate() + " " + monthNames[date.getMonth()] + " " + date.getFullYear()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -58,5 +73,7 @@ export default {
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.h-blog {
|
.h-blog {
|
||||||
min-height: 20rem;
|
min-height: 20rem;
|
||||||
|
background-position: center;
|
||||||
|
background-size: cover;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ module.exports = {
|
|||||||
'48': '12rem',
|
'48': '12rem',
|
||||||
'56': '14rem',
|
'56': '14rem',
|
||||||
'64': '16rem',
|
'64': '16rem',
|
||||||
|
'blog': '25rem',
|
||||||
'1/2': '50%',
|
'1/2': '50%',
|
||||||
'1/3': '33.333333%',
|
'1/3': '33.333333%',
|
||||||
'2/3': '66.666667%',
|
'2/3': '66.666667%',
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<main class="blog flex flex-col items-center px-5 xl:px-64">
|
<main class="blog flex flex-col items-center px-5 xl:px-64 mb-16 md:mb-32">
|
||||||
<h1 class="mt-16 md:mt-32 title font-bold text-4xl mr-2 inline mb-4">
|
<!-- TODO Titre en blanc et desc en gris lien autre couleur + Définir un autre padding sur les cotés-->
|
||||||
Blog
|
<div class="mt-8 md:mt-32 flex flex-col justify-around py-8 w-full">
|
||||||
<svg class="inline-block blog-img" height="40" width="40" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<h1 class="text-3xl md:text-5xl font-bold">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
{{ title }}
|
||||||
</svg>
|
|
||||||
</h1>
|
|
||||||
<div class="flex flex-col justify-around items-center py-8 w-full bg-red-100">
|
|
||||||
<!-- TODO Insert blog's posts -->
|
|
||||||
<h1>
|
|
||||||
TITLE
|
|
||||||
</h1>
|
</h1>
|
||||||
<div class="w-1/2">
|
<h3 class="text-xl text-gray-800 dark:text-dark-900 my-4 md:mt-8">
|
||||||
<div class="flex flex-row justify-between">
|
{{ description }}
|
||||||
<div>
|
</h3>
|
||||||
4 min. read
|
<div class="flex flex-row justify-between w-full md:w-2/3 mb-12">
|
||||||
</div>
|
<div>
|
||||||
<div>
|
<p class="uppercase text-sm font-bold text-gray-800 dark:text-dark-900">Date</p>
|
||||||
14 aout 2020
|
<p>{{ formatDate }}</p>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-center">
|
<div>
|
||||||
COVER
|
<p class="uppercase text-sm font-bold text-gray-800 dark:text-dark-900">Time</p>
|
||||||
|
<p>{{ reading_time }} min</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="uppercase text-sm font-bold text-gray-800 dark:text-dark-900">Tags</p>
|
||||||
|
<p>{{formatTags}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3>
|
<div class="w-full">
|
||||||
DESCRIPTION
|
<div class="flex justify-center w-full h-auto">
|
||||||
</h3>
|
<img class="w-full h-auto" :src="'http://localhost:5555/files/'+cover.file_name" alt="Cover Img" />
|
||||||
<p>
|
</div>
|
||||||
CONTENT
|
</div>
|
||||||
|
<p class="my-6 md:my-12 text-gray-800 dark:text-dark-900">
|
||||||
|
{{ content }}
|
||||||
</p>
|
</p>
|
||||||
<div class="my-10 border-t border-black border-solid w-full" />
|
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
Merci d'avoir lu jusqu'au bout ! 😊<br class="md:hidden"/>
|
Merci d'avoir lu jusqu'au bout ! 😊<br class="md:hidden"/>
|
||||||
Hésite surtout pas à partager l'article sur Twitter
|
Hésite surtout pas à partager l'article sur Twitter
|
||||||
|
Todo : replace par des buttons : - Likes, - Twitter (proposition de tweet), - partage (lien)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -44,25 +44,48 @@ export default {
|
|||||||
name: "blog",
|
name: "blog",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
id: this.$route.params.id
|
id: this.$route.params.id,
|
||||||
|
title: '',
|
||||||
|
description: '',
|
||||||
|
content: '',
|
||||||
|
tags: [],
|
||||||
|
likes: 0,
|
||||||
|
date: '',
|
||||||
|
cover: '',
|
||||||
|
reading_time: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async asyncData({ params, $axios }) {
|
||||||
|
const {data: post} = await $axios.get('/posts/' + params.id)
|
||||||
|
return {
|
||||||
|
title: post.title.code,
|
||||||
|
description: post.description.code,
|
||||||
|
content: post.content.code,
|
||||||
|
tags: post.tags,
|
||||||
|
likes: post.likes,
|
||||||
|
date: post.created_at,
|
||||||
|
reading_time: post.reading_time,
|
||||||
|
cover: post.cover
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
formatDate() {
|
||||||
|
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
|
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec"
|
||||||
|
];
|
||||||
|
const date = new Date(this.date)
|
||||||
|
return date.getDate() + " " + monthNames[date.getMonth()] + " " + date.getFullYear()
|
||||||
|
},
|
||||||
|
formatTags() {
|
||||||
|
let tags = ""
|
||||||
|
this.tags.map(tag => {
|
||||||
|
tags += tag.label.code + ", "
|
||||||
|
})
|
||||||
|
return tags.substring(0, tags.length - 2)
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.blog {
|
|
||||||
.blog-img {
|
|
||||||
transform: translate(3px, -10px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.title:after {
|
|
||||||
margin-top: 0.1rem;
|
|
||||||
content: '';
|
|
||||||
height: 2px;
|
|
||||||
width: 100%;
|
|
||||||
display: block;
|
|
||||||
@apply bg-green-400;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -7,23 +7,55 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="flex flex-col justify-around items-center py-8 w-full md:w-1/2">
|
<div class="flex flex-col justify-around items-center py-8 w-full md:w-1/2">
|
||||||
<!-- TODO Insert blog's posts -->
|
<!-- TODO
|
||||||
<nuxt-link to="/blog/1">
|
Insert research by tags
|
||||||
<Post
|
Insert see more
|
||||||
title="Il était une nouvelle fois la vie"
|
-->
|
||||||
reading_time="4"
|
<div v-if="posts.size !== 0" class="w-full" v-for="post in posts">
|
||||||
description="Un tout nouvel article à propos de je ne sais pas quoi. Un tout nouvel article à propos de je ne sais pas quoi. Un tout nouvel article à propos de je ne sais pas quoi."
|
<nuxt-link :to="'/blog/' + post.id">
|
||||||
tags="Dev Tech Vie"/>
|
<Post
|
||||||
</nuxt-link>
|
:title="post.title.code"
|
||||||
<Post reading_time="12"/>
|
:reading_time="post.reading_time"
|
||||||
<Post />
|
:description="post.description.code"
|
||||||
|
:tags="displayTags(post.tags)"
|
||||||
|
:cover="post.cover"
|
||||||
|
:date="post.created_at"
|
||||||
|
:likes="post.likes"
|
||||||
|
/>
|
||||||
|
</nuxt-link>
|
||||||
|
</div>
|
||||||
|
<div v-else class="w-full">
|
||||||
|
Pas de blogs !
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Post from "~/components/Post";
|
||||||
export default {
|
export default {
|
||||||
name: "blog"
|
name: "blog",
|
||||||
|
components: {Post},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
posts: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
displayTags(tags) {
|
||||||
|
const tags_label = []
|
||||||
|
tags.map(tag => {
|
||||||
|
tags_label.push(tag.label.code)
|
||||||
|
})
|
||||||
|
return tags_label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async asyncData ({ $axios }) {
|
||||||
|
const {data: posts} = await $axios.get('/posts')
|
||||||
|
return {
|
||||||
|
posts
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,13 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
posts: [],
|
||||||
|
works: [],
|
||||||
|
services: []
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user