refactor(about, i18n): improved i18n dx with markdown (#753)

This commit is contained in:
Corentin THOMASSET 2023-11-15 00:15:41 +01:00 committed by GitHub
parent de1ee69ef9
commit bd3edcb528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 113 additions and 79 deletions

View file

@ -1,63 +1,9 @@
<script setup lang="ts">
import { useHead } from '@vueuse/head';
import { useTracker } from '@/modules/tracker/tracker.services';
useHead({ title: 'About - IT Tools' });
const { tracker } = useTracker();
</script>
<template>
<div mx-auto mt-50px max-w-600px>
<h1>{{ $t('about.h1') }}</h1>
<p text-justify>
{{ $t('about.h1p1') }}
<c-link href="https://github.com/CorentinTh" target="_blank" rel="noopener">
Corentin Thomasset
</c-link>{{ $t('about.h1p2') }}
</p>
<p text-justify>
{{ $t('about.h1p3') }}
<c-link
href="https://www.buymeacoffee.com/cthmsst"
rel="noopener"
target="_blank"
@click="() => tracker.trackEvent({ eventName: 'Support button clicked' })"
>
{{ $t('about.h1p4') }}
</c-link>.
</p>
<h2>{{ $t('about.h2') }}</h2>
<p text-justify>
{{ $t('about.h2p1') }}
<c-link href="https://github.com/CorentinTh/it-tools/blob/main/package.json" rel="noopener" target="_blank">
package.json
</c-link>
{{ $t('about.h2p2') }}
</p>
<h2>{{ $t('about.h3') }}</h2>
<p text-justify>
{{ $t('about.h3p1') }}
<c-link
href="https://github.com/CorentinTh/it-tools/issues/new/choose"
rel="noopener"
target="_blank"
>
{{ $t('about.h3p2') }}
</c-link>
{{ $t('about.h3p3') }}
</p>
<p text-justify>
{{ $t('about.h3p4') }}
<c-link
href="https://github.com/CorentinTh/it-tools/issues/new/choose"
rel="noopener"
target="_blank"
>
{{ $t('about.h3p5') }}
</c-link>
{{ $t('about.h3p6') }}
</p>
</div>
<c-markdown :markdown="$t('about.content')" mx-auto mt-50px max-w-600px />
</template>

View file

@ -0,0 +1,18 @@
<script setup lang="ts">
const md = `
# IT Tools
## About
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nisl quis
mollis blandit, nunc nisl aliquam nunc, vitae aliquam nisl nunc vitae nisl.
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- Sed euismod, nisl quis mollis blandit, nunc nisl aliquam nunc, vitae aliquam nisl nunc vitae nisl.
[it-tools](https://it-tools.tech)
`;
</script>
<template>
<c-markdown :markdown="md" />
</template>

View file

@ -0,0 +1,21 @@
<script setup lang="ts">
import { marked } from 'marked';
import DomPurify from 'dompurify';
const props = withDefaults(defineProps<{ markdown?: string }>(), { markdown: '' });
const { markdown } = toRefs(props);
marked.use({
renderer: {
link(href, title, text) {
return `<a class="text-primary transition decoration-none hover:underline" href="${href}" target="_blank" rel="noopener">${text}</a>`;
},
},
});
const html = computed(() => DomPurify.sanitize(marked(markdown.value), { ADD_ATTR: ['target'] }));
</script>
<template>
<div v-html="html" />
</template>