diff --git a/.changeset/grumpy-days-yell.md b/.changeset/grumpy-days-yell.md new file mode 100644 index 000000000000..5cc00ff54b7e --- /dev/null +++ b/.changeset/grumpy-days-yell.md @@ -0,0 +1,9 @@ +--- +'astro': major +--- + +Removes support for astroFlavoredMarkdown + +In 1.0 Astro moved the old Astro Flavored Markdown (also sometimes called Components in Markdown) to a legacy feature. This change removes the `legacy.astroFlavoredMarkdown` option completely. + +In 2.0 this feature will not be available in Astro at all. We recommend migration to MDX for those were still using this feature in 1.x. diff --git a/packages/astro/e2e/fixtures/preact-compat-component/astro.config.mjs b/packages/astro/e2e/fixtures/preact-compat-component/astro.config.mjs index 2cd377763753..7d2c8a855d1d 100644 --- a/packages/astro/e2e/fixtures/preact-compat-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/preact-compat-component/astro.config.mjs @@ -3,8 +3,5 @@ import preact from '@astrojs/preact'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [preact({ compat: true })], }); diff --git a/packages/astro/e2e/fixtures/preact-compat-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/preact-compat-component/src/pages/markdown.md deleted file mode 100644 index 7c521de772fb..000000000000 --- a/packages/astro/e2e/fixtures/preact-compat-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.jsx'; - import PreactComponent from '../components/JSXComponent.jsx'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/fixtures/preact-component/astro.config.mjs b/packages/astro/e2e/fixtures/preact-component/astro.config.mjs index bcaa451eb910..7a8aef52144b 100644 --- a/packages/astro/e2e/fixtures/preact-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/preact-component/astro.config.mjs @@ -4,8 +4,5 @@ import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [preact(), mdx()], }); diff --git a/packages/astro/e2e/fixtures/preact-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/preact-component/src/pages/markdown.md deleted file mode 100644 index 7c521de772fb..000000000000 --- a/packages/astro/e2e/fixtures/preact-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.jsx'; - import PreactComponent from '../components/JSXComponent.jsx'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/fixtures/react-component/astro.config.mjs b/packages/astro/e2e/fixtures/react-component/astro.config.mjs index badddf1d3922..5c044b69d552 100644 --- a/packages/astro/e2e/fixtures/react-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/react-component/astro.config.mjs @@ -4,8 +4,5 @@ import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [react(), mdx()], }); diff --git a/packages/astro/e2e/fixtures/react-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/react-component/src/pages/markdown.md deleted file mode 100644 index fbc685a5befd..000000000000 --- a/packages/astro/e2e/fixtures/react-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.jsx'; - import ReactComponent from '../components/JSXComponent.jsx'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/fixtures/solid-component/astro.config.mjs b/packages/astro/e2e/fixtures/solid-component/astro.config.mjs index 35d38c8f1566..f527c69b4ab3 100644 --- a/packages/astro/e2e/fixtures/solid-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/solid-component/astro.config.mjs @@ -4,8 +4,5 @@ import solid from '@astrojs/solid-js'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [solid(), mdx()], }); diff --git a/packages/astro/e2e/fixtures/solid-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/solid-component/src/pages/markdown.md deleted file mode 100644 index 21a779c9d817..000000000000 --- a/packages/astro/e2e/fixtures/solid-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.jsx'; - import SolidComponent from '../components/SolidComponent.jsx'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/fixtures/svelte-component/astro.config.mjs b/packages/astro/e2e/fixtures/svelte-component/astro.config.mjs index 99f557d4373b..bc5c6c9bb9a7 100644 --- a/packages/astro/e2e/fixtures/svelte-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/svelte-component/astro.config.mjs @@ -4,8 +4,5 @@ import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [svelte(), mdx()], }); diff --git a/packages/astro/e2e/fixtures/svelte-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/svelte-component/src/pages/markdown.md deleted file mode 100644 index ebc4d87955ec..000000000000 --- a/packages/astro/e2e/fixtures/svelte-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.svelte'; - import SvelteComponent from '../components/SvelteComponent.svelte'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/fixtures/vue-component/astro.config.mjs b/packages/astro/e2e/fixtures/vue-component/astro.config.mjs index 84c024e68fe9..9a3f1272790c 100644 --- a/packages/astro/e2e/fixtures/vue-component/astro.config.mjs +++ b/packages/astro/e2e/fixtures/vue-component/astro.config.mjs @@ -4,9 +4,6 @@ import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [ mdx(), vue({ diff --git a/packages/astro/e2e/fixtures/vue-component/src/pages/markdown.md b/packages/astro/e2e/fixtures/vue-component/src/pages/markdown.md deleted file mode 100644 index 3ae0470aff4c..000000000000 --- a/packages/astro/e2e/fixtures/vue-component/src/pages/markdown.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -layout: ../components/Layout.astro -setup: | - import Counter from '../components/Counter.vue'; - import VueComponent from '../components/VueComponent.vue'; - - const someProps = { - count: 0, - }; ---- - - - # Hello, server! - - - - # Hello, client:idle! - - - - # Hello, client:load! - - - - # Hello, client:visible! - - - - # Hello, client:media! - - - diff --git a/packages/astro/e2e/preact-compat-component.test.js b/packages/astro/e2e/preact-compat-component.test.js index 0798a30edfd2..e1b603e7fb39 100644 --- a/packages/astro/e2e/preact-compat-component.test.js +++ b/packages/astro/e2e/preact-compat-component.test.js @@ -14,11 +14,3 @@ test.describe('preact/compat components in Astro files', () => { pageSourceFilePath: './src/pages/index.astro', }); }); - -test.describe('preact/compat components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); diff --git a/packages/astro/e2e/preact-component.test.js b/packages/astro/e2e/preact-component.test.js index dfd4993da78c..d808b489003c 100644 --- a/packages/astro/e2e/preact-component.test.js +++ b/packages/astro/e2e/preact-component.test.js @@ -15,14 +15,6 @@ test.describe('Preact components in Astro files', () => { }); }); -test.describe('Preact components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); - test.describe('Preact components in MDX files', () => { createTests({ ...config, diff --git a/packages/astro/e2e/react-component.test.js b/packages/astro/e2e/react-component.test.js index 8eb10a7edb92..00d747079a71 100644 --- a/packages/astro/e2e/react-component.test.js +++ b/packages/astro/e2e/react-component.test.js @@ -16,14 +16,6 @@ test.describe('React components in Astro files', () => { }); }); -test.describe('React components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); - test.describe('React components in MDX files', () => { createTests({ ...config, diff --git a/packages/astro/e2e/solid-component.test.js b/packages/astro/e2e/solid-component.test.js index aa8d356cd440..7a195c9b1267 100644 --- a/packages/astro/e2e/solid-component.test.js +++ b/packages/astro/e2e/solid-component.test.js @@ -15,14 +15,6 @@ test.describe('Solid components in Astro files', () => { }); }); -test.describe('Solid components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); - test.describe('Solid components in MDX files', () => { createTests({ ...config, diff --git a/packages/astro/e2e/svelte-component.test.js b/packages/astro/e2e/svelte-component.test.js index 260c8e83dfad..d267aeafea13 100644 --- a/packages/astro/e2e/svelte-component.test.js +++ b/packages/astro/e2e/svelte-component.test.js @@ -16,14 +16,6 @@ test.describe('Svelte components in Astro files', () => { }); }); -test.describe('Svelte components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); - test.describe('Svelte components in MDX files', () => { createTests({ ...config, diff --git a/packages/astro/e2e/vue-component.test.js b/packages/astro/e2e/vue-component.test.js index 55221878049a..0cc41c74eb2b 100644 --- a/packages/astro/e2e/vue-component.test.js +++ b/packages/astro/e2e/vue-component.test.js @@ -16,14 +16,6 @@ test.describe('Vue components in Astro files', () => { }); }); -test.describe('Vue components in Markdown files', () => { - createTests({ - ...config, - pageUrl: '/markdown/', - pageSourceFilePath: './src/pages/markdown.md', - }); -}); - test.describe('Vue components in MDX files', () => { createTests({ ...config, diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 8a8c87c4f471..7b8968f93c3b 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -870,30 +870,7 @@ export interface AstroUserConfig { * These flags allow you to opt in to some deprecated or otherwise outdated behavior of Astro * in the latest version, so that you can continue to upgrade and take advantage of new Astro releases. */ - legacy?: { - /** - * @docs - * @name legacy.astroFlavoredMarkdown - * @type {boolean} - * @default `false` - * @version 1.0.0-rc.1 - * @description - * Enable Astro's pre-v1.0 support for components and JSX expressions in `.md` (and alternative extensions for markdown files like ".markdown") Markdown files. - * In Astro `1.0.0-rc`, this original behavior was removed as the default, in favor of our new [MDX integration](https://docs.astro.build/en/guides/integrations-guide/mdx/). - * - * To enable this behavior, set `legacy.astroFlavoredMarkdown` to `true` in your [`astro.config.mjs` configuration file](https://docs.astro.build/en/guides/configuring-astro/#the-astro-config-file). - * - * ```js - * { - * legacy: { - * // Example: Add support for legacy Markdown features - * astroFlavoredMarkdown: true, - * }, - * } - * ``` - */ - astroFlavoredMarkdown?: boolean; - }; + legacy?: object; /** * @docs diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 0dd1a1bbac99..047831860a05 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -349,7 +349,6 @@ async function generatePath( logging, markdown: { ...settings.config.markdown, - isAstroFlavoredMd: settings.config.legacy.astroFlavoredMarkdown, isExperimentalContentCollections: settings.config.experimental.contentCollections, contentDir: getContentPaths(settings.config).contentDir, }, diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts index be8280f385f6..d9df28af227e 100644 --- a/packages/astro/src/core/build/vite-plugin-ssr.ts +++ b/packages/astro/src/core/build/vite-plugin-ssr.ts @@ -210,7 +210,6 @@ function buildManifest( base: settings.config.base, markdown: { ...settings.config.markdown, - isAstroFlavoredMd: settings.config.legacy.astroFlavoredMarkdown, isExperimentalContentCollections: settings.config.experimental.contentCollections, contentDir: getContentPaths(settings.config).contentDir, }, diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 4d139d322047..85c0b60a7f7b 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -36,9 +36,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { ...markdownConfigDefaults, }, vite: {}, - legacy: { - astroFlavoredMarkdown: false, - }, + legacy: {}, experimental: { contentCollections: false, }, @@ -180,12 +178,7 @@ export const AstroConfigSchema = z.object({ .optional() .default({}), legacy: z - .object({ - astroFlavoredMarkdown: z - .boolean() - .optional() - .default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown), - }) + .object({}) .optional() .default({}), }); diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 2889734fee3d..351ea631815f 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -20,7 +20,6 @@ import htmlVitePlugin from '../vite-plugin-html/index.js'; import astroIntegrationsContainerPlugin from '../vite-plugin-integrations-container/index.js'; import jsxVitePlugin from '../vite-plugin-jsx/index.js'; import astroLoadFallbackPlugin from '../vite-plugin-load-fallback/index.js'; -import legacyMarkdownVitePlugin from '../vite-plugin-markdown-legacy/index.js'; import markdownVitePlugin from '../vite-plugin-markdown/index.js'; import astroScannerPlugin from '../vite-plugin-scanner/index.js'; import astroScriptsPlugin from '../vite-plugin-scripts/index.js'; @@ -110,9 +109,7 @@ export async function createVite( // the build to run very slow as the filewatcher is triggered often. mode !== 'build' && vitePluginAstroServer({ settings, logging, fs }), envVitePlugin({ settings }), - settings.config.legacy.astroFlavoredMarkdown - ? legacyMarkdownVitePlugin({ settings, logging }) - : markdownVitePlugin({ settings, logging }), + markdownVitePlugin({ settings, logging }), htmlVitePlugin(), jsxVitePlugin({ settings, logging }), astroPostprocessVitePlugin({ settings }), diff --git a/packages/astro/src/core/render/dev/environment.ts b/packages/astro/src/core/render/dev/environment.ts index 58a126b02360..c12495bf5c0a 100644 --- a/packages/astro/src/core/render/dev/environment.ts +++ b/packages/astro/src/core/render/dev/environment.ts @@ -24,7 +24,6 @@ export function createDevelopmentEnvironment( logging, markdown: { ...settings.config.markdown, - isAstroFlavoredMd: settings.config.legacy.astroFlavoredMarkdown, isExperimentalContentCollections: settings.config.experimental.contentCollections, contentDir: getContentPaths(settings.config).contentDir, }, diff --git a/packages/astro/src/vite-plugin-markdown-legacy/README.md b/packages/astro/src/vite-plugin-markdown-legacy/README.md deleted file mode 100644 index ee7fd0e54793..000000000000 --- a/packages/astro/src/vite-plugin-markdown-legacy/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# vite-plugin-markdown-legacy - -Adds Markdown support to Vite, both at the top level as well as within `.astro` files. diff --git a/packages/astro/src/vite-plugin-markdown-legacy/index.ts b/packages/astro/src/vite-plugin-markdown-legacy/index.ts deleted file mode 100644 index 4691957f5fcb..000000000000 --- a/packages/astro/src/vite-plugin-markdown-legacy/index.ts +++ /dev/null @@ -1,265 +0,0 @@ -import { renderMarkdown } from '@astrojs/markdown-remark'; -import fs from 'fs'; -import matter from 'gray-matter'; -import { fileURLToPath } from 'url'; -import { Plugin, ResolvedConfig, transformWithEsbuild } from 'vite'; -import type { AstroSettings } from '../@types/astro'; -import { getContentPaths } from '../content/index.js'; -import { pagesVirtualModuleId } from '../core/app/index.js'; -import { cachedCompilation, CompileProps } from '../core/compile/index.js'; -import { AstroErrorData, MarkdownError } from '../core/errors/index.js'; -import type { LogOptions } from '../core/logger/core.js'; -import { isMarkdownFile } from '../core/util.js'; -import type { PluginMetadata as AstroPluginMetadata } from '../vite-plugin-astro/types'; -import { getFileInfo, normalizeFilename } from '../vite-plugin-utils/index.js'; - -interface AstroPluginOptions { - settings: AstroSettings; - logging: LogOptions; -} - -const MARKDOWN_IMPORT_FLAG = '?mdImport'; -const MARKDOWN_CONTENT_FLAG = '?content'; - -function safeMatter(source: string, id: string) { - try { - return matter(source); - } catch (err: any) { - const markdownError = new MarkdownError({ - code: AstroErrorData.UnknownMarkdownError.code, - message: err.message, - stack: err.stack, - location: { - file: id, - }, - }); - - if (err.name === 'YAMLException') { - markdownError.setErrorCode(AstroErrorData.MarkdownFrontmatterParseError.code); - markdownError.setLocation({ - file: id, - line: err.mark.line, - column: err.mark.column, - }); - - markdownError.setMessage(err.reason); - } - - throw markdownError; - } -} - -// Both end up connecting a `load()` hook to the Astro compiler, and share some copy-paste -// logic in how that is done. -export default function markdown({ settings }: AstroPluginOptions): Plugin { - const { config } = settings; - - // Weird Vite behavior: Vite seems to use a fake "index.html" importer when you - // have `enforce: pre`. This can probably be removed once the vite issue is fixed. - // see: https://github.com/vitejs/vite/issues/5981 - const fakeRootImporter = fileURLToPath(new URL('index.html', config.root)); - function isRootImport(importer: string | undefined) { - if (!importer) { - return true; - } - if (importer === fakeRootImporter) { - return true; - } - if (importer === '\0' + pagesVirtualModuleId) { - return true; - } - return false; - } - - let resolvedConfig: ResolvedConfig; - - return { - name: 'astro:markdown', - enforce: 'pre', - async resolveId(id, importer, options) { - // Resolve any .md (or alternative extensions of markdown files like .markdown) files with the `?content` cache buster. This should only come from - // an already-resolved JS module wrapper. Needed to prevent infinite loops in Vite. - // Unclear if this is expected or if cache busting is just working around a Vite bug. - if (isMarkdownFile(id, { suffix: MARKDOWN_CONTENT_FLAG })) { - const resolvedId = await this.resolve(id, importer, { skipSelf: true, ...options }); - return resolvedId?.id.replace(MARKDOWN_CONTENT_FLAG, ''); - } - // If the markdown file is imported from another file via ESM, resolve a JS representation - // that defers the markdown -> HTML rendering until it is needed. This is especially useful - // when fetching and then filtering many markdown files, like with import.meta.glob() or Astro.glob(). - // Otherwise, resolve directly to the actual component. - if (isMarkdownFile(id) && !isRootImport(importer)) { - const resolvedId = await this.resolve(id, importer, { skipSelf: true, ...options }); - if (resolvedId) { - return resolvedId.id + MARKDOWN_IMPORT_FLAG; - } - } - // In all other cases, we do nothing and rely on normal Vite resolution. - return undefined; - }, - async load(id, opts) { - // A markdown file has been imported via ESM! - // Return the file's JS representation, including all Markdown - // frontmatter and a deferred `import() of the compiled markdown content. - if (isMarkdownFile(id, { suffix: MARKDOWN_IMPORT_FLAG })) { - const { fileId, fileUrl } = getFileInfo(id, config); - - const source = await fs.promises.readFile(fileId, 'utf8'); - const { data: frontmatter, content: rawContent } = safeMatter(source, fileId); - return { - code: ` - // Static - export const frontmatter = ${escapeViteEnvReferences(JSON.stringify(frontmatter))}; - export const file = ${JSON.stringify(fileId)}; - export const url = ${JSON.stringify(fileUrl)}; - export function rawContent() { - return ${escapeViteEnvReferences(JSON.stringify(rawContent))}; - } - export async function compiledContent() { - return load().then((m) => m.compiledContent()); - } - - // Deferred - export default async function load() { - return (await import(${JSON.stringify(fileId + MARKDOWN_CONTENT_FLAG)})); - } - export function Content(...args) { - return load().then((m) => m.default(...args)); - } - Content.isAstroComponentFactory = true; - export function getHeadings() { - return load().then((m) => m.metadata.headings); - } - export function getHeaders() { - console.warn('getHeaders() have been deprecated. Use getHeadings() function instead.'); - return load().then((m) => m.metadata.headings); - };`, - map: null, - }; - } - - // A markdown file is being rendered! This markdown file was either imported - // directly as a page in Vite, or it was a deferred render from a JS module. - // This returns the compiled markdown -> astro component that renders to HTML. - if (isMarkdownFile(id)) { - const filename = normalizeFilename(id, config); - const source = await fs.promises.readFile(filename, 'utf8'); - const renderOpts = config.markdown; - - const fileUrl = new URL(`file://${filename}`); - - // Extract special frontmatter keys - let { data: frontmatter, content: markdownContent } = safeMatter(source, filename); - - // Turn HTML comments into JS comments while preventing nested `*/` sequences - // from ending the JS comment by injecting a zero-width space - // Inside code blocks, this is removed during renderMarkdown by the remark-escape plugin. - markdownContent = markdownContent.replace( - /<\s*!--([^-->]*)(.*?)-->/gs, - (whole) => `{/*${whole.replace(/\*\//g, '*\u200b/')}*/}` - ); - - let renderResult = await renderMarkdown(markdownContent, { - ...renderOpts, - fileURL: fileUrl, - isAstroFlavoredMd: true, - isExperimentalContentCollections: settings.config.experimental.contentCollections, - contentDir: getContentPaths(settings.config).contentDir, - } as any); - let { code: astroResult, metadata } = renderResult; - const { layout = '', components = '', setup = '', ...content } = frontmatter; - content.astro = metadata; - content.url = getFileInfo(id, config).fileUrl; - content.file = filename; - - const prelude = `--- -import Slugger from 'github-slugger'; -${layout ? `import Layout from ${JSON.stringify(layout)};` : ''} -${components ? `import * from ${JSON.stringify(components)};` : ''} -${setup} - -const slugger = new Slugger(); -function $$slug(value) { - return slugger.slug(value); -} - -const $$content = ${JSON.stringify(content)}; - -Object.defineProperty($$content.astro, 'headers', { - get() { - console.warn('[${JSON.stringify(id)}] content.astro.headers is now content.astro.headings.'); - return this.headings; - } -}); ----`; - - const imports = `${layout ? `import Layout from ${JSON.stringify(layout)};` : ''} -${setup}`.trim(); - - // If the user imported "Layout", wrap the content in a Layout - if (/\bLayout\b/.test(imports)) { - astroResult = `${prelude}\n\n\n${astroResult}\n\n`; - } else { - // Note: without a Layout, we need to inject `head` manually so `maybeRenderHead` runs - astroResult = `${prelude}\n${astroResult}`; - } - - // Transform from `.astro` to valid `.ts` - const compileProps: CompileProps = { - astroConfig: config, - viteConfig: resolvedConfig, - filename, - source: astroResult, - id, - }; - - let transformResult = await cachedCompilation(compileProps); - let { code: tsResult } = transformResult; - - tsResult = `\nexport const metadata = ${JSON.stringify(metadata)}; -export const frontmatter = ${JSON.stringify(content)}; -export function rawContent() { - return ${JSON.stringify(markdownContent)}; -} -export function compiledContent() { - return ${JSON.stringify(renderResult.metadata.html)}; -} -${tsResult}`; - - // Compile from `.ts` to `.js` - const { code } = await transformWithEsbuild(tsResult, id, { - loader: 'ts', - sourcemap: false, - }); - - const astroMetadata: AstroPluginMetadata['astro'] = { - clientOnlyComponents: transformResult.clientOnlyComponents, - hydratedComponents: transformResult.hydratedComponents, - scripts: transformResult.scripts, - propagation: 'none', - pageOptions: {}, - }; - - return { - code: escapeViteEnvReferences(code), - map: null, - meta: { - astro: astroMetadata, - vite: { - lang: 'ts', - }, - }, - }; - } - - return null; - }, - }; -} - -// Converts the first dot in `import.meta.env` to its Unicode escape sequence, -// which prevents Vite from replacing strings like `import.meta.env.SITE` -// in our JS representation of loaded Markdown files -function escapeViteEnvReferences(code: string) { - return code.replace(/import\.meta\.env/g, 'import\\u002Emeta.env'); -} diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index fb2725763005..10e4cb8c0743 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -91,7 +91,7 @@ export default function markdown({ settings, logging }: AstroPluginOptions): Plu warn( logging, 'markdown', - `[${id}] Astro now supports MDX! Support for components in ".md" (or alternative extensions like ".markdown") files using the "setup" frontmatter is no longer enabled by default. Migrate this file to MDX or add the "legacy.astroFlavoredMarkdown" config flag to re-enable support.` + `[${id}] Astro now supports MDX! Support for components in ".md" (or alternative extensions like ".markdown") files using the "setup" frontmatter is no longer enabled by default. Migrate this file to MDX.` ); } diff --git a/packages/astro/test/astro-markdown-css.test.js b/packages/astro/test/astro-markdown-css.test.js deleted file mode 100644 index c6d8bc71ae87..000000000000 --- a/packages/astro/test/astro-markdown-css.test.js +++ /dev/null @@ -1,59 +0,0 @@ -import { expect } from 'chai'; -import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; - -let fixture; -const IMPORTED_ASTRO_COMPONENT_ID = 'imported-astro-component'; - -describe('Imported markdown CSS', function () { - before(async () => { - fixture = await loadFixture({ root: './fixtures/astro-markdown-css/' }); - }); - describe('build', () => { - let $; - let bundledCSS; - - before(async () => { - this.timeout(45000); // test needs a little more time in CI - await fixture.build(); - - // get bundled CSS (will be hashed, hence DOM query) - const html = await fixture.readFile('/index.html'); - $ = cheerio.load(html); - const bundledCSSHREF = $('link[rel=stylesheet][href^=/assets/]').attr('href'); - bundledCSS = await fixture.readFile(bundledCSSHREF.replace(/^\/?/, '/')); - }); - - it('Compiles styles for Astro components within imported markdown', () => { - const importedAstroComponent = $(`#${IMPORTED_ASTRO_COMPONENT_ID}`)?.[0]; - expect(importedAstroComponent?.name).to.equal('h2'); - const cssClass = $(importedAstroComponent).attr('class')?.split(/\s+/)?.[0]; - - expect(bundledCSS).to.include(`h2:where(.${cssClass}){color:#00f}`); - }); - }); - describe('dev', () => { - let devServer; - let html; - let $; - - before(async () => { - devServer = await fixture.startDevServer(); - html = await fixture.fetch('/').then((res) => res.text()); - $ = cheerio.load(html); - }); - - after(async () => { - await devServer.stop(); - }); - - it('Compiles styles for Astro components within imported markdown', async () => { - const importedAstroComponent = $(`#${IMPORTED_ASTRO_COMPONENT_ID}`)?.[0]; - expect(importedAstroComponent?.name).to.equal('h2'); - const cssClass = $(importedAstroComponent).attr('class')?.split(/\s+/)?.[0]; - - const allInjectedStyles = $('style').text().replace(/\s*/g, ''); - expect(allInjectedStyles).to.include(`h2:where(.${cssClass}){color:#00f}`); - }); - }); -}); diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index 59eb07822d9c..ca0fcad385b6 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -14,19 +14,6 @@ describe('Astro Markdown', () => { await fixture.build(); }); - it('Leaves JSX expressions unprocessed', async () => { - const html = await fixture.readFile('/jsx-expressions/index.html'); - const $ = cheerio.load(html); - - expect($('h2').html()).to.equal('{frontmatter.title}'); - }); - - it('Leaves JSX components un-transformed', async () => { - const html = await fixture.readFile('/components/index.html'); - - expect(html).to.include(''); - }); - it('Exposes raw markdown content', async () => { const { raw } = JSON.parse(await fixture.readFile('/raw-content.json')); diff --git a/packages/astro/test/fixtures/astro-markdown-css/astro.config.mjs b/packages/astro/test/fixtures/astro-markdown-css/astro.config.mjs deleted file mode 100644 index 410c20408698..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/astro.config.mjs +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, - integrations: [] -}); diff --git a/packages/astro/test/fixtures/astro-markdown-css/package.json b/packages/astro/test/fixtures/astro-markdown-css/package.json deleted file mode 100644 index 9e566688f585..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@test/astro-markdown-css", - "version": "0.0.0", - "private": true, - "scripts": { - "build": "astro build", - "dev": "astro dev" - }, - "dependencies": { - "astro": "workspace:*" - } -} diff --git a/packages/astro/test/fixtures/astro-markdown-css/src/components/Visual.astro b/packages/astro/test/fixtures/astro-markdown-css/src/components/Visual.astro deleted file mode 100644 index 001bc83bf82a..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/src/components/Visual.astro +++ /dev/null @@ -1,7 +0,0 @@ -

I'm a visual!

- - diff --git a/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article.md b/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article.md deleted file mode 100644 index 17267e9b89fe..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Visual from '../components/Visual.astro' ---- - -# Example markdown document, with a Visual - - - - diff --git a/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article2.md b/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article2.md deleted file mode 100644 index e0d484d3f29b..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/src/markdown/article2.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Visual from '../components/Visual.astro' ---- - -# Example markdown document, with a more Visuals - - - - diff --git a/packages/astro/test/fixtures/astro-markdown-css/src/pages/index.astro b/packages/astro/test/fixtures/astro-markdown-css/src/pages/index.astro deleted file mode 100644 index 204f236f4529..000000000000 --- a/packages/astro/test/fixtures/astro-markdown-css/src/pages/index.astro +++ /dev/null @@ -1,15 +0,0 @@ ---- -const markdownDocs = await Astro.glob('../markdown/*.md') -const article2 = await import('../markdown/article2.md') ---- - - - - - Astro - - - {markdownDocs.map(markdownDoc => <>

{markdownDoc.url}

)} - - - diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/components.md b/packages/astro/test/fixtures/astro-markdown/src/pages/components.md deleted file mode 100644 index cd27bc09fff2..000000000000 --- a/packages/astro/test/fixtures/astro-markdown/src/pages/components.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -setup: import Counter from '../components/Counter.svelte' ---- - - diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/jsx-expressions.md b/packages/astro/test/fixtures/astro-markdown/src/pages/jsx-expressions.md deleted file mode 100644 index b87efbb2d889..000000000000 --- a/packages/astro/test/fixtures/astro-markdown/src/pages/jsx-expressions.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Blog Post with JSX expressions -paragraph: JSX at the start of the line! -list: ['test-1', 'test-2', 'test-3'] ---- - -## {frontmatter.title} - -{frontmatter.paragraph} - -
    - {frontmatter.list.map(item =>
  • {item}
  • )} -
diff --git a/packages/astro/test/fixtures/import-ts-with-js/astro.config.mjs b/packages/astro/test/fixtures/import-ts-with-js/astro.config.mjs index 410c20408698..50eaa792c79b 100644 --- a/packages/astro/test/fixtures/import-ts-with-js/astro.config.mjs +++ b/packages/astro/test/fixtures/import-ts-with-js/astro.config.mjs @@ -2,8 +2,5 @@ import { defineConfig } from 'astro/config'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [] }); diff --git a/packages/astro/test/fixtures/import-ts-with-js/src/pages/post.md b/packages/astro/test/fixtures/import-ts-with-js/src/pages/post.md deleted file mode 100644 index f2b81e605798..000000000000 --- a/packages/astro/test/fixtures/import-ts-with-js/src/pages/post.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -setup: | - import foo from '../foo.js' ---- - -# Testing - -## { foo() } diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/astro.config.mjs b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/astro.config.mjs deleted file mode 100644 index baefed8cc2c6..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/astro.config.mjs +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'astro/config'; -import preact from '@astrojs/preact'; -import svelte from "@astrojs/svelte"; - -// https://astro.build/config -export default defineConfig({ - integrations: [preact(), svelte()], - site: 'https://astro.build/', - legacy: { - astroFlavoredMarkdown: true, - } -}); diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json deleted file mode 100644 index ba6bd41cfbf6..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@test/astro-markdown", - "version": "0.0.0", - "private": true, - "dependencies": { - "@astrojs/preact": "workspace:*", - "@astrojs/svelte": "workspace:*", - "astro": "workspace:*", - "preact": "^10.11.0", - "svelte": "^3.48.0" - } -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Counter.jsx b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Counter.jsx deleted file mode 100644 index a75f858b518b..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Counter.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import { h } from 'preact'; -import { useState } from 'preact/hooks'; - -export default function () { - const [count, setCount] = useState(0); - return ; -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Example.jsx b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Example.jsx deleted file mode 100644 index e1f67ee506f4..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Example.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function () { - return
Testing
; -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Hello.jsx b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Hello.jsx deleted file mode 100644 index d30dec516e9e..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/Hello.jsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from 'preact'; - -export default function ({ name }) { - return
Hello {name}
; -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SlotComponent.astro b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SlotComponent.astro deleted file mode 100644 index f0aa9fc1c457..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SlotComponent.astro +++ /dev/null @@ -1,13 +0,0 @@ -
-
- ❌ Missing content for slot "fragmentSlot" -
- -
- ❌ Missing content for slot "pSlot" -
- -
- ❌ Missing content for default slot -
-
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SvelteButton.svelte b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SvelteButton.svelte deleted file mode 100644 index 74f3ff6a9c75..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/SvelteButton.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/TextBlock.jsx b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/TextBlock.jsx deleted file mode 100644 index d9ea2534fec2..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/TextBlock.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import { h } from 'preact'; - -const TextBlock = ({ - title, - children, - noPadding = false, -}) => { - return ( -
-

{title}

-

{children}

-
- ); -}; - -export default TextBlock; diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/index.js b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/index.js deleted file mode 100644 index e7cc94c588f2..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/components/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import Counter from './Counter'; - -export default { - Counter -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/content/code-element.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/content/code-element.md deleted file mode 100644 index b091decc0ffc..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/content/code-element.md +++ /dev/null @@ -1,3 +0,0 @@ -This should have `nospace` around it. - -This should have nospace around it. diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/plain.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/plain.md deleted file mode 100644 index d548b3356b65..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/plain.md +++ /dev/null @@ -1,6 +0,0 @@ ---- ---- - -## Plain jane - -I am plain markdown! diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/with-components.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/with-components.md deleted file mode 100644 index dc6c23bf9c19..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/imported-md/with-components.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -setup: | - import Counter from '../components/Counter.jsx' - import Hello from '../components/Hello.jsx' - import SvelteButton from '../components/SvelteButton.svelte' ---- - -## With components - -### Non-hydrated - - - -### Hydrated - - - diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/content.astro b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/content.astro deleted file mode 100644 index 925a243a9368..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/content.astro +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -
- -
- - diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/layout-props.astro b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/layout-props.astro deleted file mode 100644 index a11abb8fb5d1..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/layouts/layout-props.astro +++ /dev/null @@ -1,17 +0,0 @@ ---- - interface Props { - url: string; - file: string; - title: string; - } - - const { title, url, file } = Astro.props.content as Props; ---- - - - -
{title}
-
{url}
-
{file}
- - \ No newline at end of file diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/children.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/children.md deleted file mode 100644 index a22ee5f96148..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/children.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -setup: import TextBlock from '../components/TextBlock' ---- -{/* https://github.com/withastro/astro/issues/3319 */} - - -
    -
  • A
  • -
  • B
  • -
  • C
  • -
-
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-element.astro b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-element.astro deleted file mode 100644 index 43ca0bfc5a0e..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-element.astro +++ /dev/null @@ -1,7 +0,0 @@ ---- -const content = await Astro.glob('../content/*.md'); ---- - -
- {content.map(({ Content }) => )} -
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-in-md.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-in-md.md deleted file mode 100644 index 52a799ab1d07..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/code-in-md.md +++ /dev/null @@ -1,16 +0,0 @@ -# Inline code blocks - -`` tags without any problems. - -# Fenced code blocks - -```html - -
This should also work without any problems.
- -``` diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment-with-js.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment-with-js.md deleted file mode 100644 index 374463d2db11..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment-with-js.md +++ /dev/null @@ -1,23 +0,0 @@ - - - - -``` - -``` - -`` - -# It still works! diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment.md deleted file mode 100644 index 39a916351829..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/comment.md +++ /dev/null @@ -1,2 +0,0 @@ - -# It works! diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/dash.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/dash.md deleted file mode 100644 index 269a774f5a6d..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/dash.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: My Blog Post -layout: ../layouts/content.astro ---- - -## Title - -Hello world - -With this in the body --- - -## Another - -more content \ No newline at end of file diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/empty-code.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/empty-code.md deleted file mode 100644 index 93cb4eedb8a9..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/empty-code.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: My Blog Post -layout: ../layouts/content.astro ---- - -## Title - -Hello world - -With this in the body --- - -## Another - -more content - -``` - -``` - -

\ No newline at end of file
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/imported-md/with-components.astro b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/imported-md/with-components.astro
deleted file mode 100644
index 97cd8f211249..000000000000
--- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/imported-md/with-components.astro
+++ /dev/null
@@ -1,9 +0,0 @@
----
-import Layout from '../../layouts/content.astro'
-
-const posts = await Astro.glob('../../imported-md/*.md')
----
-
-
-	{posts.map(({ Content }) => )}
-
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/jsx-expressions.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/jsx-expressions.md
deleted file mode 100644
index b87efbb2d889..000000000000
--- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/jsx-expressions.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Blog Post with JSX expressions
-paragraph: JSX at the start of the line!
-list: ['test-1', 'test-2', 'test-3']
----
-
-## {frontmatter.title}
-
-{frontmatter.paragraph}
-
-
    - {frontmatter.list.map(item =>
  • {item}
  • )} -
diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/layout-props.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/layout-props.md deleted file mode 100644 index 0f87c1bd0aef..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/layout-props.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: 'Hello world!' -layout: '../layouts/layout-props.astro' ---- \ No newline at end of file diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/namespace.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/namespace.md deleted file mode 100644 index abbe26a3b027..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/namespace.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -setup: import ns from '../components/index.js'; ---- - -# Hello Namespace! - -Click me! diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/raw-content.json.js b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/raw-content.json.js deleted file mode 100644 index 21be533e1020..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/raw-content.json.js +++ /dev/null @@ -1,10 +0,0 @@ -import { rawContent, compiledContent } from '../imported-md/with-components.md'; - -export async function get() { - return { - body: JSON.stringify({ - raw: rawContent(), - compiled: await compiledContent(), - }), - } -} diff --git a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/script.md b/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/script.md deleted file mode 100644 index f2b8bca88293..000000000000 --- a/packages/astro/test/fixtures/legacy-astro-flavored-markdown/src/pages/script.md +++ /dev/null @@ -1,7 +0,0 @@ -# Test - -## Let's try a script... - -This should work! - - diff --git a/packages/astro/test/fixtures/legacy-build/src/components/Greeting.vue b/packages/astro/test/fixtures/legacy-build/src/components/Greeting.vue deleted file mode 100644 index a94f586bf8fb..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/components/Greeting.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/packages/astro/test/fixtures/legacy-build/src/components/InlineHoisted.astro b/packages/astro/test/fixtures/legacy-build/src/components/InlineHoisted.astro deleted file mode 100644 index ba6c0ab4d4e0..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/components/InlineHoisted.astro +++ /dev/null @@ -1,13 +0,0 @@ - -
diff --git a/packages/astro/test/fixtures/legacy-build/src/pages/[pokemon].astro b/packages/astro/test/fixtures/legacy-build/src/pages/[pokemon].astro deleted file mode 100644 index bb3372123533..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/pages/[pokemon].astro +++ /dev/null @@ -1,18 +0,0 @@ ---- -import Greeting from '../components/Greeting.vue'; - -export async function getStaticPaths() { - const allPokemon = [{name: 'Charmander'}, {name: 'Charmander'}, {name: 'Charizard'}]; - return allPokemon.map(pokemon => ({params: {pokemon: pokemon.name}, props: {pokemon}})); -} ---- - - - Hello - - - -

{Astro.props.pokemon.name}

- - - \ No newline at end of file diff --git a/packages/astro/test/fixtures/legacy-build/src/pages/index.astro b/packages/astro/test/fixtures/legacy-build/src/pages/index.astro deleted file mode 100644 index ef93bf5535d0..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/pages/index.astro +++ /dev/null @@ -1,60 +0,0 @@ ---- -import Greeting from '../components/Greeting.vue'; -import Counter from '../components/Counter.vue'; -import InlineHoisted from '../components/InlineHoisted.astro'; ---- - - - - Demo app - - - - - - -
-

Component CSS

- -
- -
-

ImageTools

-
- -
-

Astro components

-
- -
-

Hydrated component

- -
- -
-

Hoisted scripts

- -
- -
-

define:vars

-

- -
- - diff --git a/packages/astro/test/fixtures/legacy-build/src/scripts/external-hoist.ts b/packages/astro/test/fixtures/legacy-build/src/scripts/external-hoist.ts deleted file mode 100644 index ff7ee0bcfd19..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/scripts/external-hoist.ts +++ /dev/null @@ -1,2 +0,0 @@ -const el = document.querySelector('#external-hoist'); -el.textContent = `This was loaded externally`; diff --git a/packages/astro/test/fixtures/legacy-build/src/styles/_global.scss b/packages/astro/test/fixtures/legacy-build/src/styles/_global.scss deleted file mode 100644 index 27620a7460f2..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/styles/_global.scss +++ /dev/null @@ -1 +0,0 @@ -$color: tan; diff --git a/packages/astro/test/fixtures/legacy-build/src/styles/global.css b/packages/astro/test/fixtures/legacy-build/src/styles/global.css deleted file mode 100644 index ab5ca9bfe44e..000000000000 --- a/packages/astro/test/fixtures/legacy-build/src/styles/global.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background: lightcoral; -} diff --git a/packages/astro/test/fixtures/slots-preact/astro.config.mjs b/packages/astro/test/fixtures/slots-preact/astro.config.mjs index 01ce725cc261..db84c5f33f56 100644 --- a/packages/astro/test/fixtures/slots-preact/astro.config.mjs +++ b/packages/astro/test/fixtures/slots-preact/astro.config.mjs @@ -4,8 +4,5 @@ import preact from '@astrojs/preact'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [preact(), mdx()], }); diff --git a/packages/astro/test/fixtures/slots-preact/src/pages/markdown.md b/packages/astro/test/fixtures/slots-preact/src/pages/markdown.md deleted file mode 100644 index f86720fea9e0..000000000000 --- a/packages/astro/test/fixtures/slots-preact/src/pages/markdown.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Counter from '../components/Counter.jsx' ---- - -# Slots: Preact - -

Hello world!

-

/ Named

-

/ Dash Case

diff --git a/packages/astro/test/fixtures/slots-react/astro.config.mjs b/packages/astro/test/fixtures/slots-react/astro.config.mjs index 20fa1428ec0e..5d0c06b6dec4 100644 --- a/packages/astro/test/fixtures/slots-react/astro.config.mjs +++ b/packages/astro/test/fixtures/slots-react/astro.config.mjs @@ -4,8 +4,5 @@ import react from '@astrojs/react'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [react(), mdx()], }); diff --git a/packages/astro/test/fixtures/slots-react/src/pages/markdown.md b/packages/astro/test/fixtures/slots-react/src/pages/markdown.md deleted file mode 100644 index 308450506164..000000000000 --- a/packages/astro/test/fixtures/slots-react/src/pages/markdown.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Counter from '../components/Counter.jsx' ---- - -# Slots: React - -

Hello world!

-

/ Named

-

/ Dash Case

diff --git a/packages/astro/test/fixtures/slots-solid/astro.config.mjs b/packages/astro/test/fixtures/slots-solid/astro.config.mjs index 35d38c8f1566..f527c69b4ab3 100644 --- a/packages/astro/test/fixtures/slots-solid/astro.config.mjs +++ b/packages/astro/test/fixtures/slots-solid/astro.config.mjs @@ -4,8 +4,5 @@ import solid from '@astrojs/solid-js'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [solid(), mdx()], }); diff --git a/packages/astro/test/fixtures/slots-solid/src/pages/markdown.md b/packages/astro/test/fixtures/slots-solid/src/pages/markdown.md deleted file mode 100644 index d9bc2dabd07a..000000000000 --- a/packages/astro/test/fixtures/slots-solid/src/pages/markdown.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Counter from '../components/Counter.jsx' ---- - -# Slots: Solid - -

Hello world!

-

/ Named

-

/ Dash Case

diff --git a/packages/astro/test/fixtures/slots-svelte/astro.config.mjs b/packages/astro/test/fixtures/slots-svelte/astro.config.mjs index afd7dd326797..19aeea56ab09 100644 --- a/packages/astro/test/fixtures/slots-svelte/astro.config.mjs +++ b/packages/astro/test/fixtures/slots-svelte/astro.config.mjs @@ -4,8 +4,5 @@ import svelte from '@astrojs/svelte'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [svelte(), mdx()], }); diff --git a/packages/astro/test/fixtures/slots-svelte/src/pages/markdown.md b/packages/astro/test/fixtures/slots-svelte/src/pages/markdown.md deleted file mode 100644 index e5e415921166..000000000000 --- a/packages/astro/test/fixtures/slots-svelte/src/pages/markdown.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Counter from '../components/Counter.svelte' ---- - -# Slots: Svelte - -

Hello world!

-

/ Named

-

/ Dash Case

diff --git a/packages/astro/test/fixtures/slots-vue/astro.config.mjs b/packages/astro/test/fixtures/slots-vue/astro.config.mjs index 1fbe9ba8e23b..d8d0c7130a65 100644 --- a/packages/astro/test/fixtures/slots-vue/astro.config.mjs +++ b/packages/astro/test/fixtures/slots-vue/astro.config.mjs @@ -4,8 +4,5 @@ import vue from '@astrojs/vue'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [vue(), mdx()], }); diff --git a/packages/astro/test/fixtures/slots-vue/src/pages/markdown.md b/packages/astro/test/fixtures/slots-vue/src/pages/markdown.md deleted file mode 100644 index 6a08515f273d..000000000000 --- a/packages/astro/test/fixtures/slots-vue/src/pages/markdown.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -setup: import Counter from '../components/Counter.vue' ---- - -# Slots: Vue - -

Hello world!

-

/ Named

-

/ Dash Case

diff --git a/packages/astro/test/fixtures/tailwindcss/astro.config.mjs b/packages/astro/test/fixtures/tailwindcss/astro.config.mjs index 31f537fd004b..8274fd3b9e58 100644 --- a/packages/astro/test/fixtures/tailwindcss/astro.config.mjs +++ b/packages/astro/test/fixtures/tailwindcss/astro.config.mjs @@ -4,9 +4,6 @@ import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [tailwind(), mdx()], vite: { build: { diff --git a/packages/astro/test/import-ts-with-js.test.js b/packages/astro/test/import-ts-with-js.test.js index d3882ae8f2cd..afe4a1618b00 100644 --- a/packages/astro/test/import-ts-with-js.test.js +++ b/packages/astro/test/import-ts-with-js.test.js @@ -16,10 +16,4 @@ describe('Using .js extension on .ts file', () => { const $ = cheerio.load(html); expect($('h1').text()).to.equal('bar'); }); - - it('works in .md files', async () => { - const html = await fixture.readFile('/post/index.html'); - const $ = cheerio.load(html); - expect($('h2').text()).to.equal('bar'); - }); }); diff --git a/packages/astro/test/legacy-astro-flavored-markdown.test.js b/packages/astro/test/legacy-astro-flavored-markdown.test.js deleted file mode 100644 index e9199d1a2618..000000000000 --- a/packages/astro/test/legacy-astro-flavored-markdown.test.js +++ /dev/null @@ -1,200 +0,0 @@ -import { expect } from 'chai'; -import * as cheerio from 'cheerio'; -import { loadFixture, fixLineEndings } from './test-utils.js'; - -describe('Legacy Astro-flavored Markdown', () => { - let fixture; - - before(async () => { - fixture = await loadFixture({ - root: './fixtures/legacy-astro-flavored-markdown/', - }); - await fixture.build(); - }); - - it('Can parse JSX expressions in markdown pages', async () => { - const html = await fixture.readFile('/jsx-expressions/index.html'); - const $ = cheerio.load(html); - - expect($('h2').html()).to.equal('Blog Post with JSX expressions'); - - expect(html).to.contain('JSX at the start of the line!'); - for (let listItem of ['test-1', 'test-2', 'test-3']) { - expect($(`#${listItem}`).html()).to.equal(`${listItem}`); - } - }); - - it('Can handle slugs with JSX expressions in markdown pages', async () => { - const html = await fixture.readFile('/slug/index.html'); - const $ = cheerio.load(html); - - expect($('h1').attr('id')).to.equal('my-blog-post'); - }); - - it('Can handle code elements without extra spacing', async () => { - const html = await fixture.readFile('/code-element/index.html'); - const $ = cheerio.load(html); - - $('code').each((_, el) => { - expect($(el).html()).to.equal($(el).html().trim()); - }); - }); - - it('Can handle namespaced components in markdown', async () => { - const html = await fixture.readFile('/namespace/index.html'); - const $ = cheerio.load(html); - - expect($('h1').text()).to.equal('Hello Namespace!'); - expect($('button').length).to.equal(1); - }); - - it('Correctly handles component children in markdown pages (#3319)', async () => { - const html = await fixture.readFile('/children/index.html'); - - expect(html).not.to.contain('

'); - }); - - it('Can handle HTML comments in markdown pages', async () => { - const html = await fixture.readFile('/comment/index.html'); - const $ = cheerio.load(html); - - expect($('h1').text()).to.equal('It works!'); - }); - - it('Prevents `*/` sequences from breaking HTML comments (#3476)', async () => { - const html = await fixture.readFile('/comment-with-js/index.html'); - const $ = cheerio.load(html); - - expect($('h1').text()).to.equal('It still works!'); - }); - - it('Can handle HTML comments in inline code', async () => { - const html = await fixture.readFile('/comment-with-js/index.html'); - const $ = cheerio.load(html); - - expect($('p code').text()).to.equal(''); - }); - - it('Can handle HTML comments in code fences', async () => { - const html = await fixture.readFile('/comment-with-js/index.html'); - const $ = cheerio.load(html); - - expect($('pre > code').text()).to.equal(''); - }); - - // https://github.com/withastro/astro/issues/3254 - it('Can handle scripts in markdown pages', async () => { - const html = await fixture.readFile('/script/index.html'); - expect(html).not.to.match(new RegExp('/src/scripts/test.js')); - }); - - it('Empty code blocks do not fail', async () => { - const html = await fixture.readFile('/empty-code/index.html'); - const $ = cheerio.load(html); - - // test 1: There is not a `` in the codeblock - expect($('pre')[0].children).to.have.lengthOf(1); - - // test 2: The empty `
` failed to render
-		expect($('pre')[1].children).to.have.lengthOf(0);
-	});
-
-	it('Can render markdown with --- for horizontal rule', async () => {
-		const html = await fixture.readFile('/dash/index.html');
-		expect(!!html).to.equal(true);
-	});
-
-	it('Exposes raw markdown content', async () => {
-		const { raw } = JSON.parse(await fixture.readFile('/raw-content.json'));
-
-		expect(fixLineEndings(raw)).to.equal(
-			`\n## With components\n\n### Non-hydrated\n\n\n\n### Hydrated\n\n\n\n`
-		);
-	});
-
-	it('Exposes compiled HTML content', async () => {
-		const { compiled } = JSON.parse(await fixture.readFile('/raw-content.json'));
-
-		expect(fixLineEndings(compiled)).to.equal(
-			`

With components

\n

Non-hydrated

\n\n

Hydrated

\n\n` - ); - }); - - it('Allows referencing Vite env var names in markdown (#3412)', async () => { - const html = await fixture.readFile('/vite-env-vars/index.html'); - const $ = cheerio.load(html); - - // test 1: referencing an existing var name - expect($('code').eq(0).text()).to.equal('import.meta.env.SITE'); - expect($('li').eq(0).text()).to.equal('import.meta.env.SITE'); - expect($('code').eq(3).text()).to.contain('site: import.meta.env.SITE'); - expect($('blockquote').text()).to.contain('import.meta.env.SITE'); - - // test 2: referencing a non-existing var name - expect($('code').eq(1).text()).to.equal('import.meta.env.TITLE'); - expect($('li').eq(1).text()).to.equal('import.meta.env.TITLE'); - expect($('code').eq(3).text()).to.contain('title: import.meta.env.TITLE'); - expect($('blockquote').text()).to.contain('import.meta.env.TITLE'); - - // test 3: referencing `import.meta.env` itself (without any var name) - expect($('code').eq(2).text()).to.equal('import.meta.env'); - expect($('li').eq(2).text()).to.equal('import.meta.env'); - expect($('code').eq(3).text()).to.contain('// Use Vite env vars with import.meta.env'); - expect($('blockquote').text()).to.match(/import\.meta\.env\s*$/); - }); - - it('Escapes HTML tags in code blocks', async () => { - const html = await fixture.readFile('/code-in-md/index.html'); - const $ = cheerio.load(html); - - expect($('code').eq(0).html()).to.equal('<script>'); - expect($('blockquote').length).to.equal(1); - expect($('code').eq(1).html()).to.equal('</script>'); - expect($('pre').html()).to.contain('>This should also work without any problems.<'); - }); - - it('Allows defining slot contents in component children', async () => { - const html = await fixture.readFile('/slots/index.html'); - const $ = cheerio.load(html); - - const slots = $('article').eq(0); - expect(slots.find('> .fragmentSlot > div').text()).to.contain('1:'); - expect(slots.find('> .fragmentSlot > div + p').text()).to.contain('2:'); - expect(slots.find('> .pSlot > p[title="hello"]').text()).to.contain('3:'); - expect(slots.find('> .defaultSlot').html()).to.match( - new RegExp( - `
4: Div in default slot
` + - // Optional extra paragraph due to the line breaks between components - `(

)?` + - `

5: Paragraph in fragment in default slot

` + - // Optional whitespace due to the line breaks between components - `[\s\n]*` + - `6: Regular text in default slot` - ) - ); - - const nestedSlots = $('article').eq(1); - expect(nestedSlots.find('> .fragmentSlot').html()).to.contain('1:'); - expect(nestedSlots.find('> .pSlot > p').text()).to.contain('2:'); - expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal( - ` - 3: nested fragmentSlot - 4: nested pSlot - 5: nested text in default slot - `.replace(/\s+/g, ' ') - ); - - expect($('article').eq(3).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - - expect($('article').eq(4).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - }); - - it('Generate the right props for the layout', async () => { - const html = await fixture.readFile('/layout-props/index.html'); - const $ = cheerio.load(html); - - expect($('#title').text()).to.equal('Hello world!'); - expect($('#url').text()).to.equal('/layout-props'); - expect($('#file').text()).to.match(/.*\/layout-props.md$/); - }); -}); diff --git a/packages/astro/test/slots-preact.test.js b/packages/astro/test/slots-preact.test.js index b7330a18242d..893c2dd8a980 100644 --- a/packages/astro/test/slots-preact.test.js +++ b/packages/astro/test/slots-preact.test.js @@ -34,26 +34,6 @@ describe('Slots: Preact', () => { expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); - describe('For Markdown Pages', () => { - it('Renders default slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#content').text().trim()).to.equal('Hello world!'); - }); - - it('Renders named slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#named').text().trim()).to.equal('Fallback / Named'); - }); - - it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); - }); - }); - describe('For MDX Pages', () => { it('Renders default slot', async () => { const html = await fixture.readFile('/mdx/index.html'); diff --git a/packages/astro/test/slots-react.test.js b/packages/astro/test/slots-react.test.js index a5ac46ab3034..64644515720b 100644 --- a/packages/astro/test/slots-react.test.js +++ b/packages/astro/test/slots-react.test.js @@ -34,26 +34,6 @@ describe('Slots: React', () => { expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); - describe('For Markdown Pages', () => { - it('Renders default slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#content').text().trim()).to.equal('Hello world!'); - }); - - it('Renders named slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#named').text().trim()).to.equal('Fallback / Named'); - }); - - it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); - }); - }); - describe('For MDX Pages', () => { it('Renders default slot', async () => { const html = await fixture.readFile('/mdx/index.html'); diff --git a/packages/astro/test/slots-solid.test.js b/packages/astro/test/slots-solid.test.js index 60e3231c9fa0..c7bbda434beb 100644 --- a/packages/astro/test/slots-solid.test.js +++ b/packages/astro/test/slots-solid.test.js @@ -34,26 +34,6 @@ describe('Slots: Solid', () => { expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); - describe('For Markdown Pages', () => { - it('Renders default slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#content').text().trim()).to.equal('Hello world!'); - }); - - it('Renders named slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#named').text().trim()).to.equal('Fallback / Named'); - }); - - it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); - }); - }); - describe('For MDX Pages', () => { it('Renders default slot', async () => { const html = await fixture.readFile('/mdx/index.html'); diff --git a/packages/astro/test/slots-svelte.test.js b/packages/astro/test/slots-svelte.test.js index a96a397e3e5d..9aeb4c106a8a 100644 --- a/packages/astro/test/slots-svelte.test.js +++ b/packages/astro/test/slots-svelte.test.js @@ -34,26 +34,6 @@ describe('Slots: Svelte', () => { expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); - describe('For Markdown Pages', () => { - it('Renders default slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#content').text().trim()).to.equal('Hello world!'); - }); - - it('Renders named slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#named').text().trim()).to.equal('Fallback / Named'); - }); - - it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); - }); - }); - describe('For MDX Pages', () => { it('Renders default slot', async () => { const html = await fixture.readFile('/mdx/index.html'); diff --git a/packages/astro/test/slots-vue.test.js b/packages/astro/test/slots-vue.test.js index 2999904b7555..2193c7772674 100644 --- a/packages/astro/test/slots-vue.test.js +++ b/packages/astro/test/slots-vue.test.js @@ -34,26 +34,6 @@ describe('Slots: Vue', () => { expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); - describe('For Markdown Pages', () => { - it('Renders default slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#content').text().trim()).to.equal('Hello world!'); - }); - - it('Renders named slot', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#named').text().trim()).to.equal('Fallback / Named'); - }); - - it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); - const $ = cheerio.load(html); - expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); - }); - }); - describe('For MDX Pages', () => { it('Renders default slot', async () => { const html = await fixture.readFile('/mdx/index.html'); @@ -68,7 +48,7 @@ describe('Slots: Vue', () => { }); it('Converts dash-case slot to camelCase', async () => { - const html = await fixture.readFile('/markdown/index.html'); + const html = await fixture.readFile('/mdx/index.html'); const $ = cheerio.load(html); expect($('#dash-case').text().trim()).to.equal('Fallback / Dash Case'); }); diff --git a/packages/markdown/component/test/astro-markdown.test.js b/packages/markdown/component/test/astro-markdown.test.js index e5a1382a59c6..d2b156334535 100644 --- a/packages/markdown/component/test/astro-markdown.test.js +++ b/packages/markdown/component/test/astro-markdown.test.js @@ -25,25 +25,6 @@ describe('Astro Markdown', () => { expect($('#test').length).to.be.ok; }); - it('Can parse JSX expressions in markdown pages', async () => { - const html = await fixture.readFile('/jsx-expressions/index.html'); - const $ = cheerio.load(html); - - expect($('h2').html()).to.equal('Blog Post with JSX expressions'); - - expect(html).to.contain('JSX at the start of the line!'); - for (let listItem of ['test-1', 'test-2', 'test-3']) { - expect($(`#${listItem}`).html()).to.equal(`${listItem}`); - } - }); - - it('Can handle slugs with JSX expressions in markdown pages', async () => { - const html = await fixture.readFile('/slug/index.html'); - const $ = cheerio.load(html); - - expect($('h1').attr('id')).to.equal('my-blog-post'); - }); - it('Can handle code elements without extra spacing', async () => { const html = await fixture.readFile('/code-element/index.html'); const $ = cheerio.load(html); @@ -53,14 +34,6 @@ describe('Astro Markdown', () => { }); }); - it('Can handle namespaced components in markdown', async () => { - const html = await fixture.readFile('/namespace/index.html'); - const $ = cheerio.load(html); - - expect($('h1').text()).to.equal('Hello Namespace!'); - expect($('button').length).to.equal(1); - }); - it('Correctly handles component children in markdown pages (#3319)', async () => { const html = await fixture.readFile('/children/index.html'); @@ -95,12 +68,6 @@ describe('Astro Markdown', () => { expect($('pre > code').text()).to.equal(''); }); - // https://github.com/withastro/astro/issues/3254 - it('Can handle scripts in markdown pages', async () => { - const html = await fixture.readFile('/script/index.html'); - expect(html).not.to.match(new RegExp('/src/scripts/test.js')); - }); - it('Can load more complex jsxy stuff', async () => { const html = await fixture.readFile('/complex/index.html'); const $ = cheerio.load(html); @@ -256,45 +223,6 @@ describe('Astro Markdown', () => { expect($('#target > ol > li > ol > li').text()).to.equal('nested hello'); }); - it('Exposes raw markdown content', async () => { - const { raw } = JSON.parse(await fixture.readFile('/raw-content.json')); - - expect(fixLineEndings(raw)).to.equal( - `\n## With components\n\n### Non-hydrated\n\n\n\n### Hydrated\n\n\n\n` - ); - }); - - it('Exposes HTML parser for raw markdown content', async () => { - const { compiled } = JSON.parse(await fixture.readFile('/raw-content.json')); - - expect(fixLineEndings(compiled)).to.equal( - `

With components

\n

Non-hydrated

\n\n

Hydrated

\n\n` - ); - }); - - it('Allows referencing Vite env var names in markdown (#3412)', async () => { - const html = await fixture.readFile('/vite-env-vars/index.html'); - const $ = cheerio.load(html); - - // test 1: referencing an existing var name - expect($('code').eq(0).text()).to.equal('import.meta.env.SITE'); - expect($('li').eq(0).text()).to.equal('import.meta.env.SITE'); - expect($('code').eq(3).text()).to.contain('site: import.meta.env.SITE'); - expect($('blockquote').text()).to.contain('import.meta.env.SITE'); - - // test 2: referencing a non-existing var name - expect($('code').eq(1).text()).to.equal('import.meta.env.TITLE'); - expect($('li').eq(1).text()).to.equal('import.meta.env.TITLE'); - expect($('code').eq(3).text()).to.contain('title: import.meta.env.TITLE'); - expect($('blockquote').text()).to.contain('import.meta.env.TITLE'); - - // test 3: referencing `import.meta.env` itself (without any var name) - expect($('code').eq(2).text()).to.equal('import.meta.env'); - expect($('li').eq(2).text()).to.equal('import.meta.env'); - expect($('code').eq(3).text()).to.contain('// Use Vite env vars with import.meta.env'); - expect($('blockquote').text()).to.match(/import\.meta\.env\s*$/); - }); - it('Escapes HTML tags in code blocks', async () => { const html = await fixture.readFile('/code-in-md/index.html'); const $ = cheerio.load(html); @@ -305,42 +233,6 @@ describe('Astro Markdown', () => { expect($('pre').html()).to.contain('>This should also work without any problems.<'); }); - it('Allows defining slot contents in component children', async () => { - const html = await fixture.readFile('/slots/index.html'); - const $ = cheerio.load(html); - - const slots = $('article').eq(0); - expect(slots.find('> .fragmentSlot > div').text()).to.contain('1:'); - expect(slots.find('> .fragmentSlot > div + p').text()).to.contain('2:'); - expect(slots.find('> .pSlot > p[title="hello"]').text()).to.contain('3:'); - expect(slots.find('> .defaultSlot').html()).to.match( - new RegExp( - `
4: Div in default slot
` + - // Optional extra paragraph due to the line breaks between components - `(

)?` + - `

5: Paragraph in fragment in default slot

` + - // Optional whitespace due to the line breaks between components - `[\s\n]*` + - `6: Regular text in default slot` - ) - ); - - const nestedSlots = $('article').eq(1); - expect(nestedSlots.find('> .fragmentSlot').html()).to.contain('1:'); - expect(nestedSlots.find('> .pSlot > p').text()).to.contain('2:'); - expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal( - ` - 3: nested fragmentSlot - 4: nested pSlot - 5: nested text in default slot - `.replace(/\s+/g, ' ') - ); - - expect($('article').eq(3).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - - expect($('article').eq(4).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - }); - it('Generate the right props for the layout', async () => { const html = await fixture.readFile('/layout-props/index.html'); const $ = cheerio.load(html); diff --git a/packages/markdown/component/test/fixtures/astro-markdown/astro.config.mjs b/packages/markdown/component/test/fixtures/astro-markdown/astro.config.mjs index 405776c2bf0e..be33a26cced0 100644 --- a/packages/markdown/component/test/fixtures/astro-markdown/astro.config.mjs +++ b/packages/markdown/component/test/fixtures/astro-markdown/astro.config.mjs @@ -4,9 +4,6 @@ import svelte from "@astrojs/svelte"; // https://astro.build/config export default defineConfig({ - legacy: { - astroFlavoredMarkdown: true, - }, integrations: [preact(), svelte()], site: 'https://astro.build/', }); diff --git a/packages/markdown/component/test/fixtures/astro-markdown/src/imported-md/with-components.md b/packages/markdown/component/test/fixtures/astro-markdown/src/imported-md/with-components.md deleted file mode 100644 index dc6c23bf9c19..000000000000 --- a/packages/markdown/component/test/fixtures/astro-markdown/src/imported-md/with-components.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -setup: | - import Counter from '../components/Counter.jsx' - import Hello from '../components/Hello.jsx' - import SvelteButton from '../components/SvelteButton.svelte' ---- - -## With components - -### Non-hydrated - - - -### Hydrated - - - diff --git a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/jsx-expressions.md b/packages/markdown/component/test/fixtures/astro-markdown/src/pages/jsx-expressions.md deleted file mode 100644 index b87efbb2d889..000000000000 --- a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/jsx-expressions.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Blog Post with JSX expressions -paragraph: JSX at the start of the line! -list: ['test-1', 'test-2', 'test-3'] ---- - -## {frontmatter.title} - -{frontmatter.paragraph} - -
    - {frontmatter.list.map(item =>
  • {item}
  • )} -
diff --git a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/namespace.md b/packages/markdown/component/test/fixtures/astro-markdown/src/pages/namespace.md deleted file mode 100644 index abbe26a3b027..000000000000 --- a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/namespace.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -setup: import ns from '../components/index.js'; ---- - -# Hello Namespace! - -Click me! diff --git a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/raw-content.json.js b/packages/markdown/component/test/fixtures/astro-markdown/src/pages/raw-content.json.js deleted file mode 100644 index 21be533e1020..000000000000 --- a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/raw-content.json.js +++ /dev/null @@ -1,10 +0,0 @@ -import { rawContent, compiledContent } from '../imported-md/with-components.md'; - -export async function get() { - return { - body: JSON.stringify({ - raw: rawContent(), - compiled: await compiledContent(), - }), - } -} diff --git a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/script.md b/packages/markdown/component/test/fixtures/astro-markdown/src/pages/script.md deleted file mode 100644 index f2b8bca88293..000000000000 --- a/packages/markdown/component/test/fixtures/astro-markdown/src/pages/script.md +++ /dev/null @@ -1,7 +0,0 @@ -# Test - -## Let's try a script... - -This should work! - -