Skip to content

Commit

Permalink
feat: allow rendering narrative preview
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Nov 19, 2024
1 parent 1709098 commit 34b08d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .vitepress/theme/Narrative.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
<script setup>
import { onMounted, ref } from "vue";
import { useData } from "vitepress";
const { page } = useData();
let fetchedContent = ref("");
onMounted(async () => {
if (page.value.relativePath?.includes("preview")) {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has("url")) {
const response = await fetch(urlParams.get("url"));
fetchedContent.value = await response.text();
}
}
});
</script>
<template>
<ClientOnly>
<eox-storytelling .markdown="page.content"></eox-storytelling>
<eox-storytelling
show-nav
.markdown="page.content || fetchedContent"
></eox-storytelling>
</ClientOnly>
</template>
<style>
eox-storytelling {
--header-font-family: Poppins, sans-serif;
--body-font-family: Poppins, sans-serif;
margin: calc(var(--vp-nav-height) * -1) 0 var(--vp-nav-height) 0;
transform: translateY(var(--vp-nav-height));
}
</style>
3 changes: 3 additions & 0 deletions preview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
layout: narrative
---

0 comments on commit 34b08d2

Please sign in to comment.