Skip to content

Instantly share code, notes, and snippets.

View lovemycodesnippets's full-sized avatar

The New Stack lovemycodesnippets

View GitHub Profile
@lovemycodesnippets
lovemycodesnippets / index.vue
Created February 7, 2025 17:50
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const reset = () => {
totalCorrect.value = 0;
questionsAnswered.value = 0;
};
</script>
<template>
<template>
<div class="questions-ctr">
<div class="progress">
<div
class="bar"
:style="{
width: `${(questionsAnswered / questions.length) * 100}%`,
}"></div>
@lovemycodesnippets
lovemycodesnippets / index.vue
Created February 7, 2025 17:48
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const questionAnswered = (is_correct) => {
if (is_correct) {
totalCorrect.value++;
}
questionsAnswered.value++;
};
</script>
@lovemycodesnippets
lovemycodesnippets / Questions4.vue
Created February 7, 2025 17:30
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const selectAnswer = (is_correct) => {
emit("question-answered", is_correct);
};
</script>
<template>
<div class="questions-ctr">
@lovemycodesnippets
lovemycodesnippets / Questions3.vue
Created February 7, 2025 17:29
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const props = defineProps({
questions: Array,
answers: Array,
questionsAnswered: Number,
});
</script>
@lovemycodesnippets
lovemycodesnippets / index3.vue
Created February 7, 2025 17:27
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
</script>
<template>
<main>
<div class="ctr">
<Questions
v-if="questionsAnswered < questions.length"
:questions="questions"
@lovemycodesnippets
lovemycodesnippets / Questions2.vue
Last active February 7, 2025 17:27
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
const props = defineProps({
questions: Array,
answers: Array,
});
const getAnswersForQuestion = (questionId) => {
return props.answers.filter((answer) => answer.question.id === questionId);
};
</script>
@lovemycodesnippets
lovemycodesnippets / index-1.vue
Last active February 7, 2025 17:26
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
useSeoMeta({
title: "Quiz - QA app",
ogTitle: "Quiz - QA app",
description:
"Let's test your knowledge with our engaging and challenging quiz app.",
ogDescription:
"Let's test your knowledge with our engaging and challenging quiz app.",
ogImage:
"https://res.cloudinary.com/terieyenike/image/upload/v1720489148/quiz_vyvk4d.png",
@lovemycodesnippets
lovemycodesnippets / index-2.vue
Last active February 7, 2025 17:26
From the article "Building a Quiz App with Nuxt and Xata"
<script setup>
useSeoMeta({
});
const questionsAnswered = useState("questionsAnswered", () => 0);
const totalCorrect = useState("totalCorrect", () => 0);
const { data: questions } = await useFetch(`/api/questions`);
const { data: answers } = await useFetch(`/api/answers`);
@lovemycodesnippets
lovemycodesnippets / Result1.vue
Last active February 7, 2025 17:25
From the article "Building a Quiz App with Nuxt and Xata"
<template>
<div class="result">
<div class="title">You got sample result 1!</div>
<div class="desc">Enter a short description here about the result.</div>
<div class="score">You answered 1 out of 5 correctly.</div>
</div>
</template>