Skip to content

Commit

Permalink
fix: improve rendering of narratives
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Nov 14, 2024
1 parent 51b5bb0 commit d624a01
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
24 changes: 15 additions & 9 deletions .vitepress/components/NarrativeGallery.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<script setup>
import { data as narratives } from "../narratives.data.js";
const narrativesExcerpts = narratives.map((n) => {
const el = document.createElement("html");
el.innerHTML = n.html;
return (
el.querySelector("h1")?.textContent ||
n.url.replace("/narratives/", "").replace(".html", "")
);
});
</script>
<template>
<div class="gallery">
<a v-for="narrative in narratives" class="narrative" :href="narrative.url">
<p
v-html="
narrative.src.substring(
narrative.src.indexOf('#') + 2,
Math.max(narrative.src.indexOf('\n'), 150),
)
"
></p>
<a
v-for="(narrative, index) in narratives"
class="narrative"
:href="narrative.url"
>
<p>{{ narrativesExcerpts[index] }}</p>
</a>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions .vitepress/narratives.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createContentLoader } from "vitepress";

export default createContentLoader("narratives/*.md", {
includeSrc: true,
render: true,
transform(rawData) {
return rawData.filter(
(d) => d.url !== "/narratives/" && d.url !== "/narratives/README.html",
Expand Down
7 changes: 7 additions & 0 deletions .vitepress/theme/Narrative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ const { page } = useData();
<eox-storytelling .markdown="page.content"></eox-storytelling>
</ClientOnly>
</template>

<style>
eox-storytelling {
--header-font-family: Poppins, sans-serif;
--body-font-family: Poppins, sans-serif;
}
</style>
15 changes: 10 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
},
"dependencies": {
"@eox/map": "^1.17.0",
"@eox/storytelling": "^1.3.0"
"@eox/storytelling": "^1.4.1"
}
}

0 comments on commit d624a01

Please sign in to comment.