...
 
Commits (2)
export default $axios => resource => ({
index(options) {
return $axios.$get(`/${resource}${options}`)
},
show(id, options) {
return $axios.$get(`/${resource}/${id}${options}`)
}
})
\ No newline at end of file
......@@ -26,8 +26,7 @@ export default {
]
},
env: {
pageTitle: 'DORBAN',
api: 'https://api.dorban.de/dorban/',
pageTitle: 'DORBAN'
},
/*
** Customize the progress-bar color
......@@ -44,7 +43,7 @@ export default {
** Plugins to load before mounting the App
*/
plugins: [
'@/plugins/axios',
'~/plugins/repository',
{ src: '~/plugins/uikit.js', ssr: false }
],
/*
......@@ -64,6 +63,7 @@ export default {
** See https://axios.nuxtjs.org/options
*/
axios: {
baseURL: 'https://api.dorban.de/dorban'
},
/*
** Build configuration
......
......@@ -1204,15 +1204,15 @@
}
},
"@nuxtjs/axios": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.9.3.tgz",
"integrity": "sha512-+P1BK7MxMRL4q1WeYM9vyfocJrRoskbuD2TztKU8ryunK8JgpkIvqCzQxTI2BLUbOPd7qvjPLwzA0QBdzqYlaA==",
"version": "5.9.5",
"resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.9.5.tgz",
"integrity": "sha512-5sMsl5PbNSbAOou75wN2ztDAfGi6pU12zZQvfkDBz3s9KnKST/Azfc1FLw2Y8TR4UaDv074vt20oxK+z7AnH1A==",
"requires": {
"@nuxtjs/proxy": "^1.3.3",
"axios": "^0.19.1",
"axios": "^0.19.2",
"axios-retry": "^3.1.2",
"consola": "^2.11.3",
"defu": "^0.0.4"
"defu": "^1.0.0"
}
},
"@nuxtjs/proxy": {
......@@ -1839,9 +1839,9 @@
"dev": true
},
"axios": {
"version": "0.19.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.1.tgz",
"integrity": "sha512-Yl+7nfreYKaLRvAvjNPkvfjnQHJM1yLBY3zhqAwcJSwR/6ETkanUgylgtIvkvz0xJ+p/vZuNw8X7Hnb7Whsbpw==",
"version": "0.19.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
"requires": {
"follow-redirects": "1.5.10"
},
......@@ -3365,9 +3365,9 @@
}
},
"defu": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/defu/-/defu-0.0.4.tgz",
"integrity": "sha512-rgzSYjB7bq5P6uPTPOlFYy/hw4SR/Ml+SM/ZlRx1BEcgUmcTA8yqnzByRiA4npIuJPb1uRJo6ROx++Xs5QooqQ=="
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/defu/-/defu-1.0.0.tgz",
"integrity": "sha512-1Y1KRFxiiq+LYsZ3iP7xYSR8bHfmHFOUpDunZCN1ld1fGfDJWJIvkUBtjl3apnBwPuJtL/H7cwwlLYX8xPkraQ=="
},
"delayed-stream": {
"version": "1.0.0",
......@@ -4159,9 +4159,9 @@
}
},
"follow-redirects": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.9.0.tgz",
"integrity": "sha512-CRcPzsSIbXyVDl0QI01muNDu69S8trU4jArW9LpOt2WtC6LyUJetcIrmfHsRBx7/Jb6GHJUiuqyYxPooFfNt6A==",
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.10.0.tgz",
"integrity": "sha512-4eyLK6s6lH32nOvLLwlIOnr9zrL8Sm+OvW4pVTJNoXeGzYIkHVf+pADQi+OJ0E67hiuSLezPVPyBcIZO50TmmQ==",
"requires": {
"debug": "^3.0.0"
}
......@@ -9354,9 +9354,9 @@
}
},
"uikit": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/uikit/-/uikit-3.2.7.tgz",
"integrity": "sha512-/EGCJd7qGGwJsidyOxr+13DZwJtmkknbQhc+fk6LHOpNazG3nm0pPw++3/Bx3exL8gbwmFyS9alwLdKmoiourQ=="
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/uikit/-/uikit-3.3.1.tgz",
"integrity": "sha512-ddE01TPVP2rA8A/a9wkaixkhympjIOfpL//Gp0lHrjTNskBZYIazmBjW9OifJNrvp5di/1kbWVBl8fWKswAQnQ=="
},
"unfetch": {
"version": "4.1.0",
......
......@@ -11,10 +11,10 @@
"generate": "nuxt generate"
},
"dependencies": {
"@nuxtjs/axios": "^5.3.6",
"@nuxtjs/axios": "^5.9.5",
"moment": "^2.24.0",
"nuxt": "^2.0.0",
"uikit": "^3.2.7"
"uikit": "^3.3.1"
},
"devDependencies": {
"node-sass": "^4.13.1",
......
<template>
<div class="base">
<main class="content">
<h1>{{ page.title }}</h1>
<div v-html="page.text"></div>
</main>
</div>
</template>
<script>
import axios from '~/plugins/axios'
export default {
async asyncData ({ params, error }) {
return await axios.get(`items/pages?filter[slug][eq]=${params.slug}&fields=title,text,seo_index&single=1`)
async asyncData ({ app, params, error }) {
return await app.$postRepository.index(`?filter[slug][eq]=${params.slug}&filter[is_page][nempty]&fields=title,text,seo_index&single=1`)
.then((res) => {
return { page: res.data.data }
return { page: res.data }
})
.catch((e) => {
error({ statusCode: 404, message: 'Page not found' })
})
},
head () {
var seoIndex = 'noindex';
var seoIndex = 'index';
if (this.page.seo_index == 1) {
seoIndex = 'index'
if (this.page.seo_index) {
seoIndex = 'noindex'
}
return {
......
......@@ -5,13 +5,11 @@
</template>
<script>
import axios from '~/plugins/axios'
export default {
async asyncData ({ params, error }) {
return await axios.get(`items/pages?filter[slug][eq]=home&fields=title,text&single=1`)
async asyncData ({ app, params, error }) {
return await app.$postRepository.index('?filter[slug][eq]=home&fields=title,text&single=1')
.then((res) => {
return { home: res.data.data }
return { home: res.data }
})
.catch((e) => {
error({ statusCode: 404, message: 'Home not found' })
......
......@@ -11,23 +11,30 @@
<div class="uk-text-lead" v-html="post.intro"></div>
<div v-html="post.text"></div>
<div v-if="post.images" class="[email protected]" data-uk-grid
data-uk-scrollspy="cls: uk-animation-scale-down; target: .templates-post_gallery__item; delay: 300; repeat: true">
<a v-for="image in post.images" v-bind:key="image.id" :href="image.directus_files_id.data.thumbnails[5].url"
:title="image.directus_files_id.title" :data-caption="image.directus_files_id.title"
class="templates-post_gallery__item">
<img :src="image.directus_files_id.data.thumbnails[3].url" :alt="'Bild zum Beitrag ' + post.title" />
</a>
</div>
</article>
<router-link to="/posts" class="back"><span uk-icon="chevron-double-left"></span> Zurück</router-link>
<router-link to="/posts"><span uk-icon="chevron-double-left"></span> Zurück</router-link>
</main>
</div>
</template>
<script>
import axios from '~/plugins/axios'
var moment = require('moment')
export default {
async asyncData ({ params, error }) {
return await axios.get(`items/posts?filter[slug][eq]=${params.slug}&fields=intro,title,text,published_on&single=1`)
async asyncData ({ app, params, error }) {
return await app.$postRepository.index(`?filter[slug][eq]=${params.slug}&fields=intro,title,text,published_on,images.*.*&single=1`)
.then((res) => {
return { post: res.data.data }
return { post: res.data }
})
.catch((e) => {
error({ statusCode: 404, message: 'Post not found' })
......@@ -35,7 +42,7 @@ export default {
},
filters: {
moment: function (date) {
return moment(date).format('D.MM.YYYY')
return moment(date).format('DD.MM.YYYY')
}
},
head () {
......
......@@ -4,15 +4,19 @@
<h1>{{ title }}</h1>
<div v-for="post in posts" v-bind:key="post.slug">
<article class="post-list-article">
<article class="post-list-article" data-uk-scrollspy="cls: uk-animation-slide-left-small; target: .templates-posts_article; delay: 300; repeat: true">
<div class="date">
<time :datetime="post.published_on">{{ post.published_on | moment }}</time>
</div>
<div class="post-list-intro">
<nuxt-link :to="{ path: 'posts/' + post.slug}">
<nuxt-link :to="{ path: 'posts/' + post.slug }">
<h3 class="post-list-title">{{ post.title }}</h3>
</nuxt-link>
<nuxt-link v-if="post.image" :to="{ path: 'posts/' + post.slug }" :aria-label="'Beitragsbild ' + post.title">
<img :src="post.image.data.thumbnails[3].url" :alt="'Bild zum Beitrag ' + post.title" />
</nuxt-link>
<div v-if="post.intro" v-html="post.intro">
</div>
......@@ -27,15 +31,13 @@
</template>
<script>
import axios from '~/plugins/axios'
var moment = require('moment')
export default {
async asyncData ({ params, error }) {
return await axios.get(`items/posts?fields=title,slug,published_on,intro&sort=-published_on`)
async asyncData ({ app, params, error }) {
return await app.$postRepository.index(`?filter[is_page][empty]&fields=title,slug,published_on,image.*,intro,is_page&sort=-published_on`)
.then((res) => {
return { posts: res.data.data }
return { posts: res.data }
})
.catch((e) => {
error({ statusCode: 404, message: 'Posts not found' })
......@@ -43,12 +45,12 @@ export default {
},
filters: {
moment: function (date) {
return moment(date).format('D.MM.YYYY')
return moment(date).format('DD.MM.YYYY')
}
},
data () {
return {
title: 'Beiträge'
title: 'Beiträge',
}
},
head () {
......
import axios from 'axios'
export default axios.create({
baseURL: process.env.api
})
\ No newline at end of file
import createRepository from '~/api/repository.js'
export default (ctx, inject) => {
const repositoryWithAxios = createRepository(ctx.$axios)
inject('postRepository', repositoryWithAxios('items/posts'))
}
\ No newline at end of file