summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/modern-adults-dance.md5
-rw-r--r--packages/astro/components/Markdown.astro4
-rw-r--r--packages/astro/src/core/render/result.ts14
3 files changed, 17 insertions, 6 deletions
diff --git a/.changeset/modern-adults-dance.md b/.changeset/modern-adults-dance.md
new file mode 100644
index 000000000..ad98bbb68
--- /dev/null
+++ b/.changeset/modern-adults-dance.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Ensure private, internal APIs are not enumerable
diff --git a/packages/astro/components/Markdown.astro b/packages/astro/components/Markdown.astro
index 0dc214732..b7fbdf3cb 100644
--- a/packages/astro/components/Markdown.astro
+++ b/packages/astro/components/Markdown.astro
@@ -24,8 +24,6 @@ let { content, class: className } = Astro.props as InternalProps;
let html = null;
let htmlContent = '';
-const { privateRenderMarkdownDoNotUse: renderMarkdown } = Astro as any;
-
// If no content prop provided, use the slot.
if (!content) {
content = await Astro.slots.render('default');
@@ -35,7 +33,7 @@ if (!content) {
}
if (content) {
- htmlContent = await renderMarkdown(content, {
+ htmlContent = await (Astro as any).__renderMarkdown(content, {
mode: 'md',
$: {
scopedClassName: className,
diff --git a/packages/astro/src/core/render/result.ts b/packages/astro/src/core/render/result.ts
index 9edef6bad..02b442610 100644
--- a/packages/astro/src/core/render/result.ts
+++ b/packages/astro/src/core/render/result.ts
@@ -88,7 +88,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
createAstro(astroGlobal: AstroGlobalPartial, props: Record<string, any>, slots: Record<string, any> | null) {
const astroSlots = new Slots(result, slots);
- return {
+ const Astro = {
__proto__: astroGlobal,
props,
request,
@@ -138,8 +138,14 @@ ${extra}`
return astroGlobal.resolve(path);
},
slots: astroSlots,
+ } as unknown as AstroGlobal;
+
+ Object.defineProperty(Astro, '__renderMarkdown', {
+ // Ensure this API is not exposed to users
+ enumerable: false,
+ writable: false,
// <Markdown> also needs the same `astroConfig.markdownOptions.render` as `.md` pages
- async privateRenderMarkdownDoNotUse(content: string, opts: any) {
+ value: async function(content: string, opts: any) {
let [mdRender, renderOpts] = markdownRender;
let parser: MarkdownParser | null = null;
//let renderOpts = {};
@@ -164,7 +170,9 @@ ${extra}`
const { code } = await parser(content, { ...renderOpts, ...(opts ?? {}) });
return code;
},
- } as unknown as AstroGlobal;
+ });
+
+ return Astro;
},
resolve,
_metadata: {