Portage du site sous vuejs #232
2 changed files with 16 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted, onBeforeUpdate } from "vue";
|
||||||
import { marked } from "marked";
|
import { marked } from "marked";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@ const props = defineProps<{
|
||||||
|
|
||||||
const htmlContent = ref("");
|
const htmlContent = ref("");
|
||||||
|
|
||||||
onMounted(() => {
|
function refresh() {
|
||||||
|
const markdownFileUrl = `/${props.path}.md`;
|
||||||
|
console.log(`Chargement de l'URL ${markdownFileUrl}`);
|
||||||
axios
|
axios
|
||||||
.get(`/${props.path}.md`)
|
.get(markdownFileUrl)
|
||||||
.then((response) => (htmlContent.value = marked.parse(response.data)))
|
.then((response) => (htmlContent.value = marked.parse(response.data)))
|
||||||
.catch(
|
.catch(
|
||||||
() =>
|
() =>
|
||||||
|
@ -19,6 +21,14 @@ onMounted(() => {
|
||||||
"# 404 Not Found \n \n La page recherchée n'a pas pu être trouvée"
|
"# 404 Not Found \n \n La page recherchée n'a pas pu être trouvée"
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUpdate(() => {
|
||||||
|
refresh();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MarkdownFile from "../components/MarkdownFile.vue";
|
import MarkdownFile from "../components/MarkdownFile.vue";
|
||||||
import { useRoute } from "vue-router";
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const category = route.params.category;
|
|
||||||
const filepath = route.params.filepath;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
<MarkdownFile :path="`rules/${category}/${filepath}`" />
|
<MarkdownFile
|
||||||
|
:path="`rules/${$route.params.category}/${$route.params.filepath}`"
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in a new issue