23 lines
1.1 KiB
Vue
23 lines
1.1 KiB
Vue
<script setup>
|
|
import { computed, ref } from 'vue';
|
|
import { linkify } from '../lib/format';
|
|
|
|
/** Text mit Links; lange Texte werden gekürzt („Mehr anzeigen“) */
|
|
const props = defineProps({
|
|
text: { type: String, default: '' },
|
|
limit: { type: Number, default: 600 },
|
|
});
|
|
const expanded = ref(false);
|
|
const long = computed(() => props.text.length > props.limit);
|
|
const shown = computed(() => (long.value && !expanded.value ? `${props.text.slice(0, props.limit).trimEnd()} …` : props.text));
|
|
</script>
|
|
|
|
<template>
|
|
<p class="ih:break-words ih:whitespace-pre-wrap">
|
|
<template v-for="(part, i) in linkify(shown)" :key="i">
|
|
<a v-if="part.href" :href="part.href" target="_blank" rel="noopener noreferrer" class="ih:text-brand-text ih:underline ih:underline-offset-2">{{ part.text }}</a>
|
|
<template v-else>{{ part.text }}</template>
|
|
</template>
|
|
<button v-if="long" type="button" class="ih:ml-1 ih:font-medium ih:text-brand-text ih:hover:underline" @click="expanded = !expanded">{{ expanded ? 'Weniger' : 'Mehr anzeigen' }}</button>
|
|
</p>
|
|
</template>
|