Skip to content

Commit

Permalink
Remove markdown component (#7931)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Aug 4, 2023
1 parent 85f2268 commit 2eb6252
Show file tree
Hide file tree
Showing 89 changed files with 11 additions and 1,653 deletions.
9 changes: 9 additions & 0 deletions .changeset/gentle-meals-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'astro': major
---

Remove support for `Astro.__renderMarkdown` which is used by `@astrojs/markdown-component`.

The `<Markdown />` component was deprecated in Astro v1 and is completely removed in v3. This integration must now be removed from your project.

As an alternative, you can use community packages that provide a similar component like https://github.com/natemoo-re/astro-remote instead.
1 change: 0 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@astrojs/vercel": "3.7.4",
"@astrojs/vue": "2.2.1",
"@astrojs/internal-helpers": "0.1.1",
"@astrojs/markdown-component": "1.0.5",
"@astrojs/markdown-remark": "2.2.1",
"@astrojs/telemetry": "2.1.1",
"@astrojs/underscore-redirects": "0.2.0"
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class App {
return createEnvironment({
adapterName: this.#manifest.adapterName,
logging: this.#logging,
markdown: this.#manifest.markdown,
mode: 'production',
compressHTML: this.#manifest.compressHTML,
renderers: this.#manifest.renderers,
Expand Down
2 changes: 0 additions & 2 deletions packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
import type {
RouteData,
SerializedRouteData,
Expand Down Expand Up @@ -40,7 +39,6 @@ export type SSRManifest = {
base: string;
compressHTML: boolean;
assetsPrefix?: string;
markdown: MarkdownRenderingOptions;
renderers: SSRLoadedRenderer[];
/**
* Map of directive name (e.g. `load`) to the directive script code
Expand Down
2 changes: 0 additions & 2 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ async function generatePath(
const env = createEnvironment({
adapterName: manifest.adapterName,
logging,
markdown: manifest.markdown,
mode: opts.mode,
renderers: manifest.renderers,
clientDirectives: manifest.clientDirectives,
Expand Down Expand Up @@ -619,7 +618,6 @@ export function createBuildManifest(
entryModules: Object.fromEntries(internals.entrySpecifierToBundleMap.entries()),
routes: [],
adapterName: '',
markdown: settings.config.markdown,
clientDirectives: settings.clientDirectives,
compressHTML: settings.config.compressHTML,
renderers,
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ function buildManifest(
base: settings.config.base,
compressHTML: settings.config.compressHTML,
assetsPrefix: settings.config.build.assetsPrefix,
markdown: settings.config.markdown,
componentMetadata: Array.from(internals.componentMetadata),
renderers: [],
clientDirectives: Array.from(settings.clientDirectives),
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/render/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async function renderPage({ mod, renderContext, env, cookies }: RenderPage) {
links: renderContext.links,
styles: renderContext.styles,
logging: env.logging,
markdown: env.markdown,
params: renderContext.params,
pathname: renderContext.pathname,
componentMetadata: renderContext.componentMetadata,
Expand Down
5 changes: 0 additions & 5 deletions packages/astro/src/core/render/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
import type { AstroSettings, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
import type { LogOptions } from '../logger/core.js';
import type { ModuleLoader } from '../module-loader';
Expand All @@ -16,10 +15,6 @@ export interface Environment {
adapterName?: string;
/** logging options */
logging: LogOptions;
/**
* Used to support `Astro.__renderMarkdown` for legacy `<Markdown />` component
*/
markdown: MarkdownRenderingOptions;
/** "development" or "production" */
mode: RuntimeMode;
compressHTML: boolean;
Expand Down
34 changes: 1 addition & 33 deletions packages/astro/src/core/render/result.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
import type {
AstroGlobal,
AstroGlobalPartial,
Expand Down Expand Up @@ -27,10 +26,6 @@ export interface CreateResultArgs {
*/
ssr: boolean;
logging: LogOptions;
/**
* Used to support `Astro.__renderMarkdown` for legacy `<Markdown />` component
*/
markdown: MarkdownRenderingOptions;
params: Params;
pathname: string;
renderers: SSRLoadedRenderer[];
Expand Down Expand Up @@ -128,10 +123,8 @@ class Slots {
}
}

let renderMarkdown: any = null;

export function createResult(args: CreateResultArgs): SSRResult {
const { markdown, params, request, resolve, locals } = args;
const { params, request, resolve, locals } = args;

const url = new URL(request.url);
const headers = new Headers();
Expand Down Expand Up @@ -222,31 +215,6 @@ export function createResult(args: CreateResultArgs): SSRResult {
slots: astroSlots as unknown as AstroGlobal['slots'],
};

Object.defineProperty(Astro, '__renderMarkdown', {
// Ensure this API is not exposed to users
enumerable: false,
writable: false,
// TODO: Remove this hole "Deno" logic once our plugin gets Deno support
value: async function (content: string, opts: MarkdownRenderingOptions) {
// @ts-expect-error
if (typeof Deno !== 'undefined') {
throw new Error('Markdown is not supported in Deno SSR');
}

if (!renderMarkdown) {
// The package is saved in this variable because Vite is too smart
// and will try to inline it in buildtime
let astroRemark = '@astrojs/';
astroRemark += 'markdown-remark';

renderMarkdown = (await import(astroRemark)).renderMarkdown;
}

const { code } = await renderMarkdown(content, { ...markdown, ...(opts ?? {}) });
return code;
},
});

return Astro;
},
resolve,
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/vite-plugin-astro-server/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function createDevelopmentEnvironment(
let env = createEnvironment({
adapterName: manifest.adapterName,
logging,
markdown: manifest.markdown,
mode,
// This will be overridden in the dev server
renderers: [],
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest
entryModules: {},
routes: [],
adapterName: '',
markdown: settings.config.markdown,
clientDirectives: settings.clientDirectives,
renderers: [],
base: settings.config.base,
Expand Down
78 changes: 0 additions & 78 deletions packages/markdown/component/CHANGELOG.md

This file was deleted.

49 changes: 0 additions & 49 deletions packages/markdown/component/Markdown.astro

This file was deleted.

43 changes: 0 additions & 43 deletions packages/markdown/component/package.json

This file was deleted.

16 changes: 0 additions & 16 deletions packages/markdown/component/readme.md

This file was deleted.

37 changes: 0 additions & 37 deletions packages/markdown/component/test/astro-markdown-plugins.test.js

This file was deleted.

Loading

0 comments on commit 2eb6252

Please sign in to comment.