fix(frontend): fix prism.js not being triggered at the right moment

This commit is contained in:
MiniDigger | Martin 2023-01-03 21:10:15 +01:00
parent 5f3c45f736
commit 4234d10bb4
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { computed, nextTick, ref, watch } from "vue";
import { computed, ref, watch, watchPostEffect } from "vue";
import { useI18n } from "vue-i18n";
import { debounce } from "lodash-es";
import { useInternalApi } from "~/composables/useApi";
@ -30,15 +30,17 @@ async function fetch() {
content: props.raw,
}).catch<any>((e) => handleRequestError(e));
loading.value = false;
}
await fetch();
watchPostEffect(async () => {
if (!import.meta.env.SSR) {
await nextTick();
setupAdmonition();
if (typeof renderedMarkdown.value?.includes === "function" && renderedMarkdown.value?.includes("<code")) {
await usePrismStore().handlePrism();
}
}
}
await fetch();
});
function setupAdmonition() {
/** @licence

View File

@ -78,7 +78,7 @@ function createPinnedVersionUrl(version: PinnedVersion): string {
:deletable="false"
:saveable="true"
:cancellable="true"
:maxlength="useBackendData.validations.project.sponsorsContent.max"
:maxlength="useBackendData.validations.project.sponsorsContent?.max"
:title="i18n.t('project.sponsors')"
class="pt-0 mr-4"
@save="saveSponsors"