Skip to content

Commit a5b2678

Browse files
committed
Updates
1 parent 2a9b065 commit a5b2678

File tree

11 files changed

+83
-232
lines changed

11 files changed

+83
-232
lines changed

assets/css/tailwind.css

+27-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,35 @@ body {
3939
@apply min-h-screen flex justify-center items-center text-center mx-auto text-white;
4040
}
4141

42+
/* themes */
43+
4244
.btn {
43-
@apply rounded-full text-sm font-medium capitalize focus:to-gray-700 px-5;
45+
@apply rounded-full text-sm font-light mt-2 px-3 py-1 capitalize text-gray-400 hover:text-gray-700 focus:to-gray-900 hover:border-gray-700;
4446
}
4547

4648
.btn-xs {
47-
@apply rounded-full text-xs font-medium capitalize focus:to-gray-700 px-2;
49+
@apply rounded-full text-xs px-2;
50+
}
51+
52+
.btn-lg {
53+
@apply text-lg px-5 uppercase;
54+
}
55+
56+
.btn-outline {
57+
@apply border border-gray-400;
58+
}
59+
60+
/* forms */
61+
62+
form {
63+
@apply my-4;
64+
}
65+
66+
input,
67+
textarea {
68+
@apply text-gray-400 border border-gray-400 px-2 py-1 focus:text-gray-500 hover:border-gray-700;
69+
}
70+
71+
label {
72+
@apply inline-block my-2;
4873
}

components/cards/Article.vue

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<template>
2-
<div v-if="items && items.length > 0" class="lg:container mx-auto my-12">
3-
<div class="row">
2+
<div class="lg:container mx-auto">
3+
<div
4+
v-if="items && items.length > 0"
5+
class="mx-auto my-12 lg:flex space-x-4"
6+
>
47
<Nuxt-Link
58
v-for="(item, index) in items"
69
:key="item.slug"
710
:to="localePath({ name: 'article-slug', params: { slug: item.slug } })"
8-
class="col-12 mb-4 shadow-lg hover:shadow-xl"
11+
class="mb-4 shadow-lg hover:shadow-xl lg:flex-1"
912
>
1013
<figure class="md:flex bg-gray-100 p-8 md:p-0" :rel="`card-${index}`">
1114
<img
@@ -25,12 +28,15 @@
2528
<div class="pt-6 md:p-8 text-center md:text-left space-y-4">
2629
<blockquote>
2730
<p class="text-lg font-semibold">
28-
{{ item.description }}
31+
{{ item.description.slice(0, 50) }}...
2932
</p>
3033
</blockquote>
3134
<figcaption class="font-medium">
3235
<div class="text-cyan-600">{{ item.author.name }}</div>
33-
<div class="text-gray-500">Posted: {{ item.createdAt }}</div>
36+
<div class="text-gray-500">
37+
Posted:
38+
{{ $dateFns.format(item.createdAt, 'MMMM dd, yyyy') }}
39+
</div>
3440
</figcaption>
3541
</div>
3642
</figure>

components/cards/ArticleHeadline.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
2-
<div v-if="item" class="lg:container mx-auto my-12">
3-
<div class="row">
2+
<div v-if="items && items.length" class="lg:container mx-auto my-12">
3+
<div v-for="item in items" :key="item.slug" class="row">
44
<Nuxt-Link
55
:to="localePath({ name: 'article-slug', params: { slug: item.slug } })"
66
class="col-12 mb-4 shadow-lg hover:shadow-xl"
@@ -31,7 +31,10 @@
3131
<div class="text-cyan-600">
3232
{{ item.author && item.author.name }}
3333
</div>
34-
<div class="text-gray-500">Posted: {{ item.createdAt }}</div>
34+
<div class="text-gray-500">
35+
Posted:
36+
{{ $dateFns.format(item.createdAt, 'MMMM dd, yyyy') }}
37+
</div>
3538
</figcaption>
3639
</div>
3740
</figure>
@@ -43,7 +46,7 @@
4346
<script>
4447
export default {
4548
props: {
46-
item: { type: Object, required: true, default: () => {} }
49+
items: { type: Array, required: true, default: () => [] }
4750
}
4851
}
4952
</script>

components/global/Languages.vue

-25
This file was deleted.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@nuxt/content": "^1.14.0",
3030
"@nuxtjs/color-mode": "^2.0.5",
3131
"@nuxtjs/date-fns": "^1.5.0",
32+
"@nuxtjs/device": "^2.1.0",
3233
"@nuxtjs/eslint-config": "^5.0.0",
3334
"@nuxtjs/eslint-module": "^3.0.2",
3435
"@nuxtjs/stylelint-module": "4.0.0",

pages/index.vue

+15-28
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
11
<template>
22
<div>
33
<Header />
4-
<CardsArticleHeadline :item="storeArticle" />
5-
<CardsArticle :items="storeArticles" />
4+
<CardsArticleHeadline :items="articleHeadlines" />
5+
<CardsArticle :items="articles" />
66
</div>
77
</template>
88

99
<script>
10-
import { mapState } from 'vuex'
11-
1210
export default {
13-
async fetch({ app, params, store, store: { dispatch, getters } }) {
14-
const lang =
15-
app.i18n.locale === app.i18n.defaultLocale ? '' : app.i18n.locale
16-
17-
await dispatch('article/list/getList', { status: 'publish' })
18-
await dispatch('article/listQuery/getListQuery', {
19-
where: { headline: true },
20-
limit: 1
21-
})
22-
23-
await dispatch('article/detail/getDetail', {
24-
where: { headline: true },
25-
lang
26-
})
27-
},
28-
computed: {
29-
...mapState({
30-
storeArticles: (state) => state.article.list.data,
31-
storeArticle: (state) => state.article.detail.data,
32-
storeArticleLatest: (state) => state.article.listQuery.data
33-
})
34-
},
35-
mounted() {
36-
// console.log(this.storeArticle)
11+
async asyncData({ $content }) {
12+
const articles = await $content('articles')
13+
.where({ headline: { $ne: true } })
14+
.limit(10)
15+
.fetch()
16+
const articleHeadlines = await $content('articles')
17+
.where({ headline: true })
18+
.limit(4)
19+
.fetch()
20+
return {
21+
articles,
22+
articleHeadlines
23+
}
3724
}
3825
}
3926
</script>

store/article/detail.js

-55
This file was deleted.

store/article/list.js

-45
This file was deleted.

store/article/listQuery.js

-57
This file was deleted.

store/index.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ const mutations = {
3535
// top level actions
3636
const actions = {
3737
async nuxtServerInit({ commit, context }, { req }) {
38-
commit('GET_MENU', 'loading')
39-
const storeItems = await this.$content('pages')
40-
.only(['title', 'slug'])
41-
.where({ slug: { $ne: 'home' }, showInMenu: true, status: 'publish' })
42-
.sortBy('indexOrder', 'asc')
43-
.limit(5)
44-
.fetch()
45-
.catch((err) => {
46-
commit('SET_MENU_ERROR', err)
47-
})
48-
commit('SET_MENU', storeItems)
38+
try {
39+
commit('GET_MENU', 'loading')
40+
const storeItems = await this.$content('pages')
41+
.only(['title', 'slug'])
42+
.where({ slug: { $ne: 'home' }, showInMenu: true, status: 'publish' })
43+
.sortBy('indexOrder', 'asc')
44+
.limit(5)
45+
.fetch()
46+
.catch((err) => {
47+
commit('SET_MENU_ERROR', err)
48+
})
49+
commit('SET_MENU', storeItems)
50+
} catch (error) {
51+
commit('SET_MENU_ERROR', error)
52+
}
4953
}
5054
}
5155

yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,13 @@
16721672
dependencies:
16731673
date-fns "^2.19.0"
16741674

1675+
"@nuxtjs/device@^2.1.0":
1676+
version "2.1.0"
1677+
resolved "https://registry.yarnpkg.com/@nuxtjs/device/-/device-2.1.0.tgz#552c668b2d82dc982d18429845777c19d48d87d6"
1678+
integrity sha512-TYBdt1w2bmCCWp+MhgcBATZtqyUBi3nSdNpcLGILw5USLwCsC/yZtIkq9YisuEzuRnod9w/RZpoE80MxLftEuA==
1679+
dependencies:
1680+
defu "^3.2.2"
1681+
16751682
"@nuxtjs/eslint-config@^5.0.0":
16761683
version "5.0.0"
16771684
resolved "https://registry.yarnpkg.com/@nuxtjs/eslint-config/-/eslint-config-5.0.0.tgz#d66143ee4ada9d944de0bfbe2d7e4693a2e20d60"

0 commit comments

Comments
 (0)