Cleanup old dependencies and fix RemarkOfm import

This commit is contained in:
Peaceultime 2024-08-05 17:58:39 +02:00
parent 310a4accc4
commit e28d72fd1b
8 changed files with 37 additions and 60 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -2,11 +2,17 @@
const props = defineProps<{
content: string
}>();
const { data: ast, status } = await useAsyncData(`markdown`, () => parseMarkdown(props.content, {}));
const parser = useMarkdown();
const { data: ast, status, error } = await useAsyncData(`markdown`, () => parser(props.content));
</script>
<template>
<Suspense>
<div v-if="status === 'pending'" class="loading-circle"></div>
<MDCRenderer v-else-if="status === 'success'" :body="ast?.body" :data="ast?.data" />
<div v-else>Impossible de traiter le contenu.</div>
<template v-else>
<div>Impossible de traiter le contenu.</div>
<pre> {{ error }} </pre>
</template>
</Suspense>
</template>

View File

@ -0,0 +1,25 @@
import { createMarkdownParser } from "@nuxtjs/mdc/runtime/parser/index";
import RemarkBreaks from "remark-breaks";
import RemarkOfm from "remark-ofm";
export default function useMarkdown(): Awaited<ReturnType<typeof createMarkdownParser>>
{
let parser: Awaited<ReturnType<typeof createMarkdownParser>>
const parse = async (markdown: string) => {
if (!parser)
{
parser = await createMarkdownParser({
remark: {
plugins: {
'remark-breaks': { instance: RemarkBreaks },
'remark-ofm': { instance: RemarkOfm }
}
},
});
}
return parser(markdown);
}
return parse;
}

View File

@ -13,14 +13,5 @@ export default defineNuxtConfig({
pathPrefix: false,
},
],
mdc: {
remarkPlugins: {
'remark-breaks': {},
'remark-ofm': {}
},
components: {
prose: true,
}
},
compatibilityDate: '2024-07-25'
})

View File

@ -4,15 +4,14 @@
"@nuxtjs/mdc": "^0.8.3",
"@types/bun": "^1.1.6",
"nuxt": "^3.12.4",
"vue": "^3.4.34",
"vue-router": "^4.4.0",
"vue": "^3.4.35",
"vue-router": "^4.4.2",
"hast-util-to-html": "^9.0.1",
"remark-breaks": "^4.0.0",
"remark-ofm": "link:remark-ofm",
"zod": "^3.23.8"
},
"patchedDependencies": {
"unstorage@1.10.2": "patches/unstorage@1.10.2.patch",
"@nuxt/content@2.13.2": "patches/@nuxt%2Fcontent@2.13.2.patch"
"dependencies": {
"lodash.capitalize": "^4.2.1"
}
}

View File

@ -2,7 +2,6 @@
const route = useRoute();
const path = unifySlug(route.params.slug);
//const dummy = await useFetch(`/api/project`);
const { data: content } = await useFetch(`/api/project/${route.params.projectId}/file`, {
query: {
path: path

View File

@ -1,17 +0,0 @@
diff --git a/dist/runtime/server/storage.js b/dist/runtime/server/storage.js
index b9bb602074f15488fe7ee700bbed281b42b463d9..96382bc576ab0145c854d06d67649b31138e76f4 100644
--- a/dist/runtime/server/storage.js
+++ b/dist/runtime/server/storage.js
@@ -40,10 +40,10 @@ const contentIgnorePredicate = (key) => {
if (key.startsWith("preview:") || isIgnored(key)) {
return false;
}
- if (invalidKeyCharacters.some((ik) => key.includes(ik))) {
+ /*if (invalidKeyCharacters.some((ik) => key.includes(ik))) {
console.warn(`Ignoring [${key}]. File name should not contain any of the following characters: ${invalidKeyCharacters.join(", ")}`);
return false;
- }
+ }*/
return true;
};
export const getContentsIds = async (event, prefix) => {

View File

@ -1,26 +0,0 @@
diff --git a/drivers/github.cjs b/drivers/github.cjs
index 606d742980420c0a60f991803bc1cc4604112f54..322c61f73c85aa7ccaf684d2cf64af5b20a9c579 100644
--- a/drivers/github.cjs
+++ b/drivers/github.cjs
@@ -21,7 +21,7 @@ module.exports = (0, _utils.defineDriver)(_opts => {
...defaultOptions,
..._opts
};
- const rawUrl = (0, _ufo.joinURL)(opts.cdnURL, opts.repo, opts.branch, opts.dir);
+ const rawUrl = (0, _ufo.joinURL)(opts.cdnURL, opts.repo, 'raw', 'branch', opts.branch, opts.dir);
let files = {};
let lastCheck = 0;
let syncPromise;
diff --git a/drivers/github.mjs b/drivers/github.mjs
index ae9833dfe933d3d68050ed55d7ca202c4a995d0d..2c6dfd006e5495ed2a4c2a057c7a1a8b50b5659b 100644
--- a/drivers/github.mjs
+++ b/drivers/github.mjs
@@ -12,7 +12,7 @@ const defaultOptions = {
const DRIVER_NAME = "github";
export default defineDriver((_opts) => {
const opts = { ...defaultOptions, ..._opts };
- const rawUrl = joinURL(opts.cdnURL, opts.repo, opts.branch, opts.dir);
+ const rawUrl = joinURL(opts.cdnURL, opts.repo, 'raw', 'branch', opts.branch, opts.dir);
let files = {};
let lastCheck = 0;
let syncPromise;