Skip to content

Commit

Permalink
Added ts support to blog index
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Andrew Hinchey <[email protected]>
  • Loading branch information
ChrisHinchey committed Jul 11, 2023
1 parent fb8fe5c commit b340a9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
//'prettier/prettier': 'error',
'vue/multi-word-component-names': 'off',
// not needed for vue 3
'vue/no-multiple-template-root': 'off'
Expand Down
19 changes: 10 additions & 9 deletions pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@
</div>
</template>

<script setup>
<script setup lang="ts">
import {ref, onMounted, nextTick} from 'vue';
/// / Data ////
const posts = ref([]);
const posts = ref();
/// / Methods ////
const getBlogPosts = async () => {
posts.value = await useAsyncData('getAllBlogData', () => GqlBlogPosts()).then(
({data}) =>
data.value.blogPosts.data.map((post) => ({
title: post.attributes.title,
description: post.attributes.description,
category: {name: post.attributes.category},
author: post.attributes.users_permissions_user.data.attributes.name,
date: post.attributes.date,
data?.value?.blogPosts?.data.map((post) => ({
title: post?.attributes?.title,
description: post?.attributes?.description,
category: {name: post?.attributes?.category},
author:
post?.attributes?.users_permissions_user?.data?.attributes?.name,
date: post?.attributes?.date,
id: post.id,
content: post.attributes.content
content: post?.attributes?.content
}))
);
};
Expand Down

0 comments on commit b340a9f

Please sign in to comment.