From c44291fc5b9f1b552d879f777998481477a73d4b Mon Sep 17 00:00:00 2001 From: vasfvitor Date: Mon, 24 Jun 2024 13:56:02 -0300 Subject: [PATCH] Update Permissions.astro --- src/components/Permissions.astro | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/components/Permissions.astro b/src/components/Permissions.astro index a68e7c22b07..540219787ce 100644 --- a/src/components/Permissions.astro +++ b/src/components/Permissions.astro @@ -4,7 +4,10 @@ * */ -import type { MarkdownInstance } from 'astro'; +import { createMarkdownProcessor } from '@astrojs/markdown-remark'; +import fs from 'fs/promises'; +import path from 'path'; +import { fileURLToPath } from 'url'; interface Props { plugin: string; @@ -13,14 +16,34 @@ interface Props { const { plugin } = Astro.props; async function importMDX(p: string): Promise { - /* @vite-ignore */ - // Apparently, this is working, but Vite is complaining https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations - const dir = `../../packages/plugins-workspace/plugins/${p}/permissions/autogenerated/reference.md`; - return import(dir).then((a: MarkdownInstance) => { - return a.compiledContent(); - }); + console.log(import.meta.url) + const base = fileURLToPath(import.meta.url); + const dirname = path.dirname(base); + + const dir = path.join( + dirname, + '../../packages/plugins-workspace/plugins', + p, + 'permissions/autogenerated', + 'reference.md' + ); + + try { + const content = await fs.readFile(dir, 'utf-8'); + return content; + } catch (err) { + console.error(`Error reading file ${dir}: ${err}`); + throw err; + } } +const md = await createMarkdownProcessor(); + const pageContent: string = await importMDX(plugin); +const content = await md.render(pageContent); + +const code = `${plugin}: `; +const prefix = `Prefix: ${code}`; --- - +

+