Add line breaks to description

This commit is contained in:
2025-09-11 22:51:23 +02:00
parent 86a66aad37
commit 5d4e802796
7 changed files with 53 additions and 19 deletions
+26
View File
@@ -0,0 +1,26 @@
<script setup lang="ts">
withDefaults(
defineProps<{
tag?: string;
text: string;
css?: string;
}>(),
{
tag: 'p',
css: ''
}
);
</script>
<template>
<component
:is="tag"
v-for="(line, i) in text.split('\n')"
:key="i"
:class="css"
>
{{ line }}
</component>
</template>
<style scoped></style>
@@ -1,11 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import ClickableImage from '~/components/ClickableImage.vue'; import ClickableImage from '~/components/ClickableImage.vue';
import MultilineString from '~/components/MultilineString.vue';
import { useI18nKey } from '~/composables/useI18nKey'; import { useI18nKey } from '~/composables/useI18nKey';
import { useTitleStore } from '~/stores/title'; import { useTitleStore } from '~/stores/title';
import { fullDate } from '~~/server/utils/date'; import { fullDate } from '~~/server/utils/date';
definePageMeta({ definePageMeta({
middleware: ['auth'] middleware: ['auth'],
keepalive: false
}); });
const app = useNuxtApp(); const app = useNuxtApp();
@@ -155,7 +157,10 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
/> />
<VaCardContent> <VaCardContent>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<p class="text-lg">{{ tKey(data, 'description') }}</p> <MultilineString
:text="tKey(data, 'description').value"
css="text-lg"
/>
<p v-if="hasKey(data, 'question')" class="text-xl font-bold"> <p v-if="hasKey(data, 'question')" class="text-xl font-bold">
{{ data.textRequired ? '❓' : '❔' }}: {{ data.textRequired ? '❓' : '❔' }}:
{{ tKey(data, 'question') }} {{ tKey(data, 'question') }}
@@ -163,6 +168,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
<p v-if="hasKey(data, 'question')"> <p v-if="hasKey(data, 'question')">
🖋: {{ t(`enums.text_type.${data.textType}`) }} 🖋: {{ t(`enums.text_type.${data.textType}`) }}
</p> </p>
<VaDivider v-if="hasKey(data, 'extraText')" />
<p v-if="hasKey(data, 'extraText')"> <p v-if="hasKey(data, 'extraText')">
<span class="uppercase">{{ <span class="uppercase">{{
t('page.quest.extra_points') t('page.quest.extra_points')
@@ -191,13 +197,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
v-if="data.answer.review.review" v-if="data.answer.review.review"
class="flex max-h-[60dvh] flex-col gap-2 overflow-y-auto pr-4" class="flex max-h-[60dvh] flex-col gap-2 overflow-y-auto pr-4"
> >
<p <MultilineString :text="data.answer.review.review" css="italic" />
v-for="(line, i) in data.answer.review.review.split('\n')"
:key="i"
class="italic"
>
{{ line }}
</p>
</div> </div>
</VaCardContent> </VaCardContent>
</VaCard> </VaCard>
+2 -1
View File
@@ -5,7 +5,8 @@ import { useTitleStore } from '~/stores/title';
import { fullDate } from '~~/server/utils/date'; import { fullDate } from '~~/server/utils/date';
definePageMeta({ definePageMeta({
middleware: ['admin'] middleware: ['admin'],
keepalive: false
}); });
const app = useNuxtApp(); const app = useNuxtApp();
+5 -6
View File
@@ -120,12 +120,7 @@ ${document.location.href}`
/> />
<VaCardContent> <VaCardContent>
<div class="mb-4 flex flex-col gap-2"> <div class="mb-4 flex flex-col gap-2">
<p <MultilineString :text="tKey(data, 'description').value" />
v-for="(line, i) in tKey(data, 'description').value.split('\n')"
:key="i"
>
{{ line }}
</p>
</div> </div>
<p v-if="data.start" class="text-xl"> <p v-if="data.start" class="text-xl">
{{ {{
@@ -246,6 +241,10 @@ ${document.location.href}`
<VaButton <VaButton
v-if="data.isMember" v-if="data.isMember"
color="danger" color="danger"
:preset="(quest.unreviewed || 0) <= 0 ? 'secondary' : undefined"
:border-color="
(quest.unreviewed || 0) <= 0 ? 'danger' : undefined
"
:icon="(quest.unreviewed || 0) > 0 ? 'priority_high' : undefined" :icon="(quest.unreviewed || 0) > 0 ? 'priority_high' : undefined"
:to=" :to="
$localePath( $localePath(
+2 -2
View File
@@ -37,7 +37,7 @@ watch(loggedIn, () => refresh());
/> />
<VaCardContent> <VaCardContent>
<h3 class="text-xl">{{ tKey(hunt, 'name') }}</h3> <h3 class="text-xl">{{ tKey(hunt, 'name') }}</h3>
{{ tKey(hunt, 'description') }} <p class="line-clamp-4">{{ tKey(hunt, 'description') }}</p>
<VaDivider /> <VaDivider />
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<p>{{ t('page.home.n_quests', hunt._count.quests) }}</p> <p>{{ t('page.home.n_quests', hunt._count.quests) }}</p>
@@ -91,7 +91,7 @@ watch(loggedIn, () => refresh());
/> />
<VaCardContent> <VaCardContent>
<h3 class="text-xl">{{ tKey(hunt, 'name') }}</h3> <h3 class="text-xl">{{ tKey(hunt, 'name') }}</h3>
{{ tKey(hunt, 'description') }} <p class="line-clamp-4">{{ tKey(hunt, 'description') }}</p>
<VaDivider /> <VaDivider />
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<p>{{ t('page.home.n_quests', hunt._count.quests) }}</p> <p>{{ t('page.home.n_quests', hunt._count.quests) }}</p>
+3
View File
@@ -3,6 +3,9 @@ export default defineNuxtConfig({
compatibilityDate: '2025-07-15', compatibilityDate: '2025-07-15',
devtools: { enabled: true }, devtools: { enabled: true },
devServer: { port: 3080 }, devServer: { port: 3080 },
app: {
keepalive: true
},
modules: [ modules: [
'@nuxt/devtools', '@nuxt/devtools',
'nuxt-auth-utils', 'nuxt-auth-utils',
+6 -1
View File
@@ -26,7 +26,12 @@ export function sluggy(object: {
}) + '-'; }) + '-';
} }
string += `${id}`; const stringId = `${id}`;
// prevent '-' strings on weird Unicode names
if (string.length === 1) {
return stringId;
}
string += stringId;
return string; return string;
} }