Skip to content

Commit

Permalink
deprecate the markdown component in SSR (#3240)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed May 4, 2022
1 parent 78855ce commit 224c181
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/astro/components/Markdown.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ export interface Props {
content?: string;
}
// NOTE(fks): We are most likely moving this component out of Astro core
// in a few weeks. Checking the name like this is a bit of a hack, but we
// intentionally don't want to add an SSR flag for others to read from, just yet.
if (Astro.redirect.name !== '_onlyAvailableInSSR') {
console.error(`\x1B[31mThe <Markdown> component is not available in SSR. See https://github.com/withastro/rfcs/discussions/179 for more info.\x1B[39m`);
}
const dedent = (str: string) => {
const _str = str.split('\n').filter(s => s.trimStart().length > 0);
if (_str.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createCanonicalURL, isCSSRequest } from './util.js';
import { isScriptRequest } from './script.js';

function onlyAvailableInSSR(name: string) {
return function () {
return function _onlyAvailableInSSR() {
// TODO add more guidance when we have docs and adapters.
throw new Error(`Oops, you are trying to use ${name}, which is only available with SSR.`);
};
Expand Down

0 comments on commit 224c181

Please sign in to comment.