Skip to content

Navigation Menu

Sign in
Sign up

Commit 6ab68f5

Browse files
Apply linting changes
1 parent 33664b7 commit 6ab68f5

7 files changed

Lines changed: 103 additions & 116 deletions

File tree

‎packages/sdks/snippets/nuxt/components/ProductHeader.vue‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
<h1>Acme Corp</h1>
55
</div>
66
</template>
7-
8-
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
<!-- /components/ProductInfo.vue -->
22
<template>
3-
<div v-if="product" class="product-info">
4-
<div class="product-image">
5-
<img :src="product.image" :alt="product.title" />
6-
</div>
7-
<div>
8-
<h2>{{ product.title }}</h2>
9-
<p>{{ product.description }}</p>
10-
<p>Price: {{ product.price }} $</p>
11-
<p>Rating: {{ product.rating.rate }} / 5</p>
12-
<button>Buy now</button>
13-
</div>
3+
<div v-if="product" class="product-info">
4+
<div class="product-image">
5+
<img :src="product.image" :alt="product.title" />
146
</div>
15-
</template>
16-
17-
<script setup lang="ts">
18-
defineProps<{
19-
product: {
20-
id: number;
21-
title: string;
22-
price: number;
23-
description: string;
24-
category: string;
25-
image: string;
26-
rating: { rate: number; count: number };
27-
} | null;
28-
}>();
29-
</script>
7+
<div>
8+
<h2>{{ product.title }}</h2>
9+
<p>{{ product.description }}</p>
10+
<p>Price: {{ product.price }} $</p>
11+
<p>Rating: {{ product.rating.rate }} / 5</p>
12+
<button>Buy now</button>
13+
</div>
14+
</div>
15+
</template>
3016

17+
<script setup lang="ts">
18+
defineProps<{
19+
product: {
20+
id: number;
21+
title: string;
22+
price: number;
23+
description: string;
24+
category: string;
25+
image: string;
26+
rating: { rate: number; count: number };
27+
} | null;
28+
}>();
29+
</script>

‎packages/sdks/snippets/nuxt/pages/products/[handle].vue‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,25 @@
99
</template>
1010

1111
<script setup>
12-
import { useRoute, useAsyncData } from '#app'
13-
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue'
14-
import ProductHeader from '@/components/ProductHeader.vue'
15-
import ProductFooter from '@/components/ProductFooter.vue'
16-
import ProductInfo from '@/components/ProductInfo.vue'
12+
import { useRoute, useAsyncData } from '#app';
13+
import { Content, fetchOneEntry, isPreviewing } from '@builder.io/sdk-vue';
14+
import ProductHeader from '@/components/ProductHeader.vue';
15+
import ProductFooter from '@/components/ProductFooter.vue';
16+
import ProductInfo from '@/components/ProductInfo.vue';
1717
18-
const apiKey = 'ee9f13b4981e489a9a1209887695ef2b'
19-
const model = 'product-editorial'
20-
const route = useRoute()
18+
const apiKey = 'ee9f13b4981e489a9a1209887695ef2b';
19+
const model = 'product-editorial';
20+
const route = useRoute();
2121
22-
23-
const {
24-
data: product,
25-
} = useAsyncData('product', () =>
22+
const { data: product } = useAsyncData('product', () =>
2623
$fetch(`https://fakestoreapi.com/products/${route.params.handle}`)
27-
)
24+
);
2825
29-
const {
30-
data: editorial,
31-
} = useAsyncData('editorial', () =>
26+
const { data: editorial } = useAsyncData('editorial', () =>
3227
fetchOneEntry({
3328
model,
3429
apiKey,
3530
userAttributes: { urlPath: route.fullPath },
3631
})
37-
)
32+
);
3833
</script>
39-

‎packages/sdks/snippets/vue/src/components/product-editorial/ProductFooter.vue‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
<p>© 2024 Acme Corp. All rights reserved.</p>
55
</div>
66
</template>
7-
8-

‎packages/sdks/snippets/vue/src/components/product-editorial/ProductHeader.vue‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
<h1>Acme Corp</h1>
55
</div>
66
</template>
7-
8-
Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
<!-- src/components/ProductInfo.vue -->
22
<template>
3-
<div v-if="product" class="product-info">
4-
<div class="product-image">
5-
<img :src="product.image" :alt="product.title" />
6-
</div>
7-
<div>
8-
<h2>{{ product.title }}</h2>
9-
<p>{{ product.description }}</p>
10-
<p>Price: {{ product.price }} $</p>
11-
<p>Rating: {{ product.rating.rate }} / 5</p>
12-
<button>Buy now</button>
13-
</div>
3+
<div v-if="product" class="product-info">
4+
<div class="product-image">
5+
<img :src="product.image" :alt="product.title" />
146
</div>
15-
</template>
16-
17-
<script setup lang="ts">
18-
defineProps<{
19-
product: {
20-
id: number;
21-
title: string;
22-
price: number;
23-
description: string;
24-
category: string;
25-
image: string;
26-
rating: { rate: number; count: number };
27-
} | null;
28-
}>();
29-
</script>
30-
7+
<div>
8+
<h2>{{ product.title }}</h2>
9+
<p>{{ product.description }}</p>
10+
<p>Price: {{ product.price }} $</p>
11+
<p>Rating: {{ product.rating.rate }} / 5</p>
12+
<button>Buy now</button>
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script setup lang="ts">
18+
defineProps<{
19+
product: {
20+
id: number;
21+
title: string;
22+
price: number;
23+
description: string;
24+
category: string;
25+
image: string;
26+
rating: { rate: number; count: number };
27+
} | null;
28+
}>();
29+
</script>
Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
<!-- src/views/ProductEditorial.vue -->
22
<template>
3-
<div v-if="!product && !editorial && !isPreviewing()">404</div>
4-
<div v-else>
5-
<ProductHeader />
6-
<ProductInfo :product="product" />
7-
<Content :model="modelName" :content="editorial" :apiKey="apiKey" />
8-
<ProductFooter />
9-
</div>
10-
</template>
11-
12-
<script setup lang="ts">
3+
<div v-if="!product && !editorial && !isPreviewing()">404</div>
4+
<div v-else>
5+
<ProductHeader />
6+
<ProductInfo :product="product" />
7+
<Content :model="modelName" :content="editorial" :apiKey="apiKey" />
8+
<ProductFooter />
9+
</div>
10+
</template>
1311

14-
import { ref, onMounted } from 'vue';
15-
import { Content, fetchOneEntry, isPreviewing, type BuilderContent } from '@builder.io/sdk-vue';
16-
import ProductHeader from '@/components/product-editorial/ProductHeader.vue';
17-
import ProductFooter from '@/components/product-editorial/ProductFooter.vue';
18-
import ProductInfo from '@/components/product-editorial/ProductInfo.vue';
19-
import { useRoute } from 'vue-router';
12+
<script setup lang="ts">
13+
import { ref, onMounted } from 'vue';
14+
import {
15+
Content,
16+
fetchOneEntry,
17+
isPreviewing,
18+
type BuilderContent,
19+
} from '@builder.io/sdk-vue';
20+
import ProductHeader from '@/components/product-editorial/ProductHeader.vue';
21+
import ProductFooter from '@/components/product-editorial/ProductFooter.vue';
22+
import ProductInfo from '@/components/product-editorial/ProductInfo.vue';
23+
import { useRoute } from 'vue-router';
2024
21-
const apiKey = 'ee9f13b4981e489a9a1209887695ef2b';
22-
const modelName = 'product-editorial';
23-
24-
const product = ref(null);
25-
const editorial = ref<BuilderContent | null>(null);
26-
const {params} = useRoute();
25+
const apiKey = 'ee9f13b4981e489a9a1209887695ef2b';
26+
const modelName = 'product-editorial';
2727
28-
onMounted(() => {
29-
fetch(`https://fakestoreapi.com/products/${params.id}`)
30-
.then((res) => res.json())
31-
.then((data) => {
32-
product.value = data;
33-
})
28+
const product = ref(null);
29+
const editorial = ref<BuilderContent | null>(null);
30+
const { params } = useRoute();
3431
35-
fetchOneEntry({
36-
model: modelName,
37-
apiKey: apiKey,
38-
userAttributes: { urlPath: window.location.pathname },
39-
})
40-
.then((data) => {
41-
editorial.value = data;
42-
})
43-
});
32+
onMounted(() => {
33+
fetch(`https://fakestoreapi.com/products/${params.id}`)
34+
.then((res) => res.json())
35+
.then((data) => {
36+
product.value = data;
37+
});
4438
45-
</script>
46-
39+
fetchOneEntry({
40+
model: modelName,
41+
apiKey: apiKey,
42+
userAttributes: { urlPath: window.location.pathname },
43+
}).then((data) => {
44+
editorial.value = data;
45+
});
46+
});
47+
</script>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /