This repository has been archived by the owner on Jun 5, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
110 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div class="grid gap-4 grid-cols-1 md:grid-cols-3"> | ||
<div v-for="content in contents" :key='content.id' class="flex flex-warp"> | ||
<div class="overflow-hidden rounded shadow-lg h-50 bg-gray-100 cursor-pointer" v-on:click="toggleModal(content.id)"> | ||
<img class="object-contain" :src="content.default_image.url" /> | ||
<div class="p-4"> | ||
<h3>{{content.title}}</h3> | ||
<p class="text-xs text-gray-400">{{content.date.slice(0,10)}}</p> | ||
<p class="my-2 text-base mx-1">{{content.abstract}}</p> | ||
<p v-show="content.categories != null" class="tag" v-for="category in content.categories" :key="category.index">{{category.name}}</p> | ||
</div> | ||
</div> | ||
<Modal v-if="showModal==content.id" v-bind:content="content" v-on:close="toggleModal(content.id)"></Modal> | ||
</div> | ||
</div> | ||
|
||
</template> | ||
|
||
<script> | ||
import Modal from "./Modal.vue"; | ||
export default { | ||
props: ['contents'], | ||
name: "Contents", | ||
components: { | ||
Modal, | ||
}, | ||
data() { | ||
return { | ||
showModal: false, | ||
} | ||
}, | ||
methods: { | ||
toggleModal(id){ | ||
if(!this.showModal){ | ||
this.showModal = id; | ||
} else { | ||
this.showModal =false; | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<div class="w-full text-left p-3 mt-5"> | ||
<h1>Products</h1> | ||
<section class="my-4"> | ||
<Card :contents ="products.contents"></Card> | ||
</section> | ||
|
||
</div> | ||
</template> | ||
|
||
<script> | ||
import Card from "../Card.vue"; | ||
import axios from "axios"; | ||
export default { | ||
name: "product", | ||
data() { | ||
return { | ||
showModal: false, | ||
products: [], | ||
} | ||
}, | ||
components: { | ||
Card, | ||
}, | ||
async mounted() { | ||
// productsを取得 | ||
//秘密にする必要がないため公開してます。 | ||
const response = await axios.get( | ||
"https://yukyu-myportfolio.microcms.io/api/v1/products", | ||
{ | ||
headers: { "X-API-KEY": process.env.VUE_APP_X_API_KEY} | ||
} | ||
); | ||
this.products = response.data; | ||
} | ||
}; | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters