Portage du site sous vuejs #232

Merged
kazhnuz merged 29 commits from vue-remake into master 2023-02-08 12:45:46 +01:00
2 changed files with 16 additions and 9 deletions
Showing only changes of commit d8ba1895fd - Show all commits

View file

@ -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>

View file

@ -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>