2023-02-03 21:27:30 +01:00
|
|
|
<script setup lang="ts">
|
2023-02-04 09:17:31 +01:00
|
|
|
import { ref, onMounted, onBeforeUpdate } from "vue";
|
2023-02-03 21:27:30 +01:00
|
|
|
import { marked } from "marked";
|
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
path: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const htmlContent = ref("");
|
|
|
|
|
2023-02-04 09:17:31 +01:00
|
|
|
function refresh() {
|
|
|
|
const markdownFileUrl = `/${props.path}.md`;
|
|
|
|
console.log(`Chargement de l'URL ${markdownFileUrl}`);
|
2023-02-03 21:27:30 +01:00
|
|
|
axios
|
2023-02-04 09:17:31 +01:00
|
|
|
.get(markdownFileUrl)
|
2023-02-03 21:27:30 +01:00
|
|
|
.then((response) => (htmlContent.value = marked.parse(response.data)))
|
|
|
|
.catch(
|
|
|
|
() =>
|
|
|
|
(htmlContent.value = marked.parse(
|
|
|
|
"# 404 Not Found \n \n La page recherchée n'a pas pu être trouvée"
|
|
|
|
))
|
|
|
|
);
|
2023-02-04 09:17:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
refresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUpdate(() => {
|
|
|
|
refresh();
|
2023-02-03 21:27:30 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-02-03 22:21:16 +01:00
|
|
|
<main id="content" class="pt-1">
|
|
|
|
<div v-html="htmlContent"></div>
|
|
|
|
<slot></slot>
|
|
|
|
</main>
|
2023-02-03 21:27:30 +01:00
|
|
|
</template>
|