diff --git a/.changeset/blue-bottles-explode.md b/.changeset/blue-bottles-explode.md deleted file mode 100644 index d6858d3c1025..000000000000 --- a/.changeset/blue-bottles-explode.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Logs: Add "ssr.noExternal" hint for CSS loaded from npm packages diff --git a/.changeset/fair-bananas-camp.md b/.changeset/fair-bananas-camp.md deleted file mode 100644 index 64f55b3ea408..000000000000 --- a/.changeset/fair-bananas-camp.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Respect user's configured vite logLevel during build diff --git a/.changeset/friendly-ways-collect.md b/.changeset/friendly-ways-collect.md deleted file mode 100644 index 8d65c2b0b7c1..000000000000 --- a/.changeset/friendly-ways-collect.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix relative inline scripts on Windows diff --git a/.changeset/orange-colts-march.md b/.changeset/orange-colts-march.md deleted file mode 100644 index 825130de2428..000000000000 --- a/.changeset/orange-colts-march.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/partytown': patch ---- - -Fix partytown script generation to get astro base config option diff --git a/.changeset/red-tables-hang.md b/.changeset/red-tables-hang.md deleted file mode 100644 index bc2c54b8d1ae..000000000000 --- a/.changeset/red-tables-hang.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix long-standing bug where a `class` attribute inside of a spread prop will cause duplicate `class` attributes diff --git a/.changeset/silly-ears-unite.md b/.changeset/silly-ears-unite.md deleted file mode 100644 index b4e23917b4bf..000000000000 --- a/.changeset/silly-ears-unite.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix build issue where hoisted scripts would be duplicated per page diff --git a/.changeset/wet-beds-act.md b/.changeset/wet-beds-act.md deleted file mode 100644 index da9367a9d9d2..000000000000 --- a/.changeset/wet-beds-act.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Updates component hydration scripts to use absolute paths for script imports diff --git a/.changeset/wicked-adults-pull.md b/.changeset/wicked-adults-pull.md deleted file mode 100644 index f36d0a054517..000000000000 --- a/.changeset/wicked-adults-pull.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'astro': patch -'@astrojs/markdown-remark': minor ---- - -Significantally more stable behavior for "Markdown + Components" usage, which now handles component serialization much more similarly to MDX. Also supports switching between Components and Markdown without extra newlines, removes wrapping `

` tags from standalone components, and improves JSX expression handling. diff --git a/examples/basics/package.json b/examples/basics/package.json index a2cf93d91d66..97eee792c62e 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -9,6 +9,6 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/blog-multiple-authors/package.json b/examples/blog-multiple-authors/package.json index ada3ba9e2a0e..c97155b674cb 100644 --- a/examples/blog-multiple-authors/package.json +++ b/examples/blog-multiple-authors/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/preact": "^0.1.2", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "sass": "^1.52.1" }, "dependencies": { diff --git a/examples/blog/package.json b/examples/blog/package.json index 7f3b449a530e..a596bf7d8db2 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/preact": "^0.1.2", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "preact": "^10.7.2" diff --git a/examples/component/demo/package.json b/examples/component/demo/package.json index 99d83c1a27a7..db6a1665f615 100644 --- a/examples/component/demo/package.json +++ b/examples/component/demo/package.json @@ -10,6 +10,6 @@ }, "devDependencies": { "@example/my-component": "workspace:*", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/component/package.json b/examples/component/package.json index 43b80f75a5f2..4ba7a5d52164 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -8,6 +8,6 @@ "serve": "astro --root demo preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/docs/package.json b/examples/docs/package.json index d5ac178f1a8f..df2e616f9f8a 100644 --- a/examples/docs/package.json +++ b/examples/docs/package.json @@ -20,6 +20,6 @@ "devDependencies": { "@astrojs/preact": "^0.1.2", "@astrojs/react": "^0.1.2", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/env-vars/package.json b/examples/env-vars/package.json index bc76a4dec8ae..ea5abbc03289 100644 --- a/examples/env-vars/package.json +++ b/examples/env-vars/package.json @@ -9,6 +9,6 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index dea03dab97a8..539c7fbcb6ef 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -9,7 +9,7 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "alpinejs": "^3.10.2" diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 0608a1b67877..ec9e9d3af8b0 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/lit": "^0.1.3", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "@webcomponents/template-shadowroot": "^0.1.0", diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index bc3439fda125..63d38eb2594f 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -15,7 +15,7 @@ "@astrojs/solid-js": "^0.1.2", "@astrojs/svelte": "^0.1.3", "@astrojs/vue": "^0.1.4", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "@webcomponents/template-shadowroot": "^0.1.0", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index f98a43545e7b..ae34abc2f73f 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/preact": "^0.1.2", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "preact": "^10.7.2" diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index d4af947f62e0..7584560ab9ff 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/react": "^0.1.2", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "@types/react": "^18.0.9", diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 653c1cb87b83..76c06e645128 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/solid-js": "^0.1.2", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "solid-js": "^1.4.2" diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 99ac0301165e..4c1b3a1fdfa3 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/svelte": "^0.1.3", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "svelte": "^3.48.0" diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 636a9a4a1200..480ef95d2939 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/vue": "^0.1.4", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "vue": "^3.2.36" diff --git a/examples/integrations-playground/package.json b/examples/integrations-playground/package.json index 859cd7353ef9..e03aa3daa47c 100644 --- a/examples/integrations-playground/package.json +++ b/examples/integrations-playground/package.json @@ -10,13 +10,13 @@ }, "devDependencies": { "@astrojs/lit": "^0.1.3", - "@astrojs/partytown": "^0.1.3", + "@astrojs/partytown": "^0.1.4", "@astrojs/react": "^0.1.2", "@astrojs/sitemap": "^0.1.0", "@astrojs/solid-js": "0.1.2", "@astrojs/tailwind": "^0.2.1", "@astrojs/turbolinks": "^0.1.3", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "solid-js": "^1.4.2" }, "dependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 68e54bb62f35..c4313fb4c94d 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -9,6 +9,6 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index c2d27424b379..eeafe3d22f04 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -9,6 +9,6 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 0cc48cce489a..a4ead09d0975 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/preact": "^0.1.2", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "sass": "^1.52.1" }, "dependencies": { diff --git a/examples/ssr/package.json b/examples/ssr/package.json index ff0d1013c7b9..d4585e8a2056 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -11,7 +11,7 @@ "devDependencies": { "@astrojs/node": "^0.1.2", "@astrojs/svelte": "^0.1.3", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "concurrently": "^7.2.1", "lightcookie": "^1.0.25", "unocss": "^0.15.6", diff --git a/examples/starter/package.json b/examples/starter/package.json index 38fa8928a77a..cffa686a9aa2 100644 --- a/examples/starter/package.json +++ b/examples/starter/package.json @@ -9,6 +9,6 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/subpath/package.json b/examples/subpath/package.json index 5f854cf31d10..6f43397331a7 100644 --- a/examples/subpath/package.json +++ b/examples/subpath/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/react": "^0.1.2", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "sass": "^1.52.1" }, "dependencies": { diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 8b8ecfc3488d..bb4189895b72 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -9,8 +9,8 @@ "preview": "astro preview" }, "devDependencies": { - "@astrojs/markdown-remark": "^0.9.4", - "astro": "^1.0.0-beta.32", + "@astrojs/markdown-remark": "^0.10.0", + "astro": "^1.0.0-beta.33", "hast-util-select": "5.0.1", "rehype-autolink-headings": "^6.1.1", "rehype-slug": "^5.0.1", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 8b50aa13dbc9..455fe4f09711 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -9,7 +9,7 @@ "preview": "astro preview" }, "devDependencies": { - "@astrojs/markdown-remark": "^0.9.4", - "astro": "^1.0.0-beta.32" + "@astrojs/markdown-remark": "^0.10.0", + "astro": "^1.0.0-beta.33" } } diff --git a/examples/with-markdown/package.json b/examples/with-markdown/package.json index 1ee11f39cab7..e0b269d8f3e2 100644 --- a/examples/with-markdown/package.json +++ b/examples/with-markdown/package.json @@ -9,12 +9,12 @@ "preview": "astro preview" }, "devDependencies": { - "@astrojs/markdown-remark": "^0.9.4", + "@astrojs/markdown-remark": "^0.10.0", "@astrojs/preact": "^0.1.2", "@astrojs/react": "^0.1.2", "@astrojs/svelte": "^0.1.3", "@astrojs/vue": "^0.1.4", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" }, "dependencies": { "preact": "^10.7.2", diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 8dfaf5241c39..6ba496e7bb1d 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -25,6 +25,6 @@ "@astrojs/solid-js": "^0.1.2", "@astrojs/svelte": "^0.1.3", "@astrojs/vue": "^0.1.4", - "astro": "^1.0.0-beta.32" + "astro": "^1.0.0-beta.33" } } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 7fafc8c2d2db..2e7d4294a69f 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@astrojs/tailwind": "^0.2.1", - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "autoprefixer": "^10.4.7", "canvas-confetti": "^1.5.1", "postcss": "^8.4.14", diff --git a/examples/with-vite-plugin-pwa/package.json b/examples/with-vite-plugin-pwa/package.json index 40a94ec0b024..fdd822d13eda 100644 --- a/examples/with-vite-plugin-pwa/package.json +++ b/examples/with-vite-plugin-pwa/package.json @@ -9,7 +9,7 @@ "preview": "astro preview" }, "devDependencies": { - "astro": "^1.0.0-beta.32", + "astro": "^1.0.0-beta.33", "vite-plugin-pwa": "0.11.11", "workbox-window": "^6.5.3" } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 289aaa6cd2ff..59b1c3026e09 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,26 @@ # astro +## 1.0.0-beta.33 + +### Patch Changes + +- [#3426](https://github.com/withastro/astro/pull/3426) [`946630a1`](https://github.com/withastro/astro/commit/946630a112dca39d6afc32ef02edceda94a604cb) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Logs: Add "ssr.noExternal" hint for CSS loaded from npm packages + +* [#3434](https://github.com/withastro/astro/pull/3434) [`4e3b405e`](https://github.com/withastro/astro/commit/4e3b405e9eb03f7c286234a30ca45c26e3e17fcf) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Respect user's configured vite logLevel during build + +- [#3423](https://github.com/withastro/astro/pull/3423) [`463a1c21`](https://github.com/withastro/astro/commit/463a1c214779e0558bcd99c30294e1a14a97232e) Thanks [@matthewp](https://github.com/matthewp)! - Fix relative inline scripts on Windows + +* [#3384](https://github.com/withastro/astro/pull/3384) [`296fff2c`](https://github.com/withastro/astro/commit/296fff2cffd4632f2d2e891069f52f6859a5c076) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix long-standing bug where a `class` attribute inside of a spread prop will cause duplicate `class` attributes + +- [#3433](https://github.com/withastro/astro/pull/3433) [`4ca60e93`](https://github.com/withastro/astro/commit/4ca60e9344f882ee1a216ec66fb409c88c740641) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Fix build issue where hoisted scripts would be duplicated per page + +* [#3422](https://github.com/withastro/astro/pull/3422) [`0209d627`](https://github.com/withastro/astro/commit/0209d6276c6ed86914b6433e223628010b6a7dfd) Thanks [@tony-sull](https://github.com/tony-sull)! - Updates component hydration scripts to use absolute paths for script imports + +- [#3410](https://github.com/withastro/astro/pull/3410) [`cfae9760`](https://github.com/withastro/astro/commit/cfae9760b252052b6189e96398b819a4337634a8) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Significantally more stable behavior for "Markdown + Components" usage, which now handles component serialization much more similarly to MDX. Also supports switching between Components and Markdown without extra newlines, removes wrapping `

` tags from standalone components, and improves JSX expression handling. + +- Updated dependencies [[`cfae9760`](https://github.com/withastro/astro/commit/cfae9760b252052b6189e96398b819a4337634a8)]: + - @astrojs/markdown-remark@0.10.0 + ## 1.0.0-beta.32 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index ca162467f88e..155d8116451c 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "1.0.0-beta.32", + "version": "1.0.0-beta.33", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -79,7 +79,7 @@ "dependencies": { "@astrojs/compiler": "^0.15.0", "@astrojs/language-server": "^0.13.4", - "@astrojs/markdown-remark": "^0.9.4", + "@astrojs/markdown-remark": "^0.10.0", "@astrojs/prism": "0.4.1", "@astrojs/telemetry": "^0.1.2", "@astrojs/webapi": "^0.12.0", diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index d7c02192cc52..b3c916bcdbaa 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -125,9 +125,15 @@ export default function markdown({ config }: AstroPluginOptions): Plugin { let { data: frontmatter, content: markdownContent } = matter(source); // Turn HTML comments into JS comments - markdownContent = markdownContent.replace(/<\s*!--([^-->]*)(.*?)-->/gs, (whole) => `{/*${whole}*/}`) - - let renderResult = await renderMarkdown(markdownContent, { ...renderOpts, fileURL: fileUrl } as any); + markdownContent = markdownContent.replace( + /<\s*!--([^-->]*)(.*?)-->/gs, + (whole) => `{/*${whole}*/}` + ); + + let renderResult = await renderMarkdown(markdownContent, { + ...renderOpts, + fileURL: fileUrl, + } as any); let { code: astroResult, metadata } = renderResult; const { layout = '', components = '', setup = '', ...content } = frontmatter; content.astro = metadata; diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index 0f9d28c86e68..52552231640e 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -39,7 +39,7 @@ describe('Astro Markdown', () => { const html = await fixture.readFile('/slug/index.html'); const $ = cheerio.load(html); - expect($('h1').attr("id")).to.equal('my-blog-post'); + expect($('h1').attr('id')).to.equal('my-blog-post'); }); it('Can handle code elements without extra spacing', async () => { @@ -47,7 +47,7 @@ describe('Astro Markdown', () => { const $ = cheerio.load(html); $('code').each((_, el) => { - expect($(el).html()).to.equal($(el).html().trim()) + expect($(el).html()).to.equal($(el).html().trim()); }); }); @@ -76,7 +76,7 @@ describe('Astro Markdown', () => { it('Can handle scripts in markdown pages', async () => { const html = await fixture.readFile('/script/index.html'); console.log(html); - expect(html).not.to.match(new RegExp("\/src\/scripts\/test\.js")); + expect(html).not.to.match(new RegExp('/src/scripts/test.js')); }); it('Can load more complex jsxy stuff', async () => { diff --git a/packages/integrations/partytown/CHANGELOG.md b/packages/integrations/partytown/CHANGELOG.md index b2d9ec219aca..4bcd931bf2dc 100644 --- a/packages/integrations/partytown/CHANGELOG.md +++ b/packages/integrations/partytown/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/partytown +## 0.1.4 + +### Patch Changes + +- [#3437](https://github.com/withastro/astro/pull/3437) [`78e962f7`](https://github.com/withastro/astro/commit/78e962f744a495b587bc691ad6b109543a5a5dde) Thanks [@caioferrarezi](https://github.com/caioferrarezi)! - Fix partytown script generation to get astro base config option + ## 0.1.3 ### Patch Changes diff --git a/packages/integrations/partytown/package.json b/packages/integrations/partytown/package.json index 131e57964a02..ec00c34b0898 100644 --- a/packages/integrations/partytown/package.json +++ b/packages/integrations/partytown/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/partytown", "description": "Astro + Partytown integration", - "version": "0.1.3", + "version": "0.1.4", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/markdown/remark/CHANGELOG.md b/packages/markdown/remark/CHANGELOG.md index 4fb764bd89f2..2d5100979ad2 100644 --- a/packages/markdown/remark/CHANGELOG.md +++ b/packages/markdown/remark/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/markdown-remark +## 0.10.0 + +### Minor Changes + +- [#3410](https://github.com/withastro/astro/pull/3410) [`cfae9760`](https://github.com/withastro/astro/commit/cfae9760b252052b6189e96398b819a4337634a8) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Significantally more stable behavior for "Markdown + Components" usage, which now handles component serialization much more similarly to MDX. Also supports switching between Components and Markdown without extra newlines, removes wrapping `

` tags from standalone components, and improves JSX expression handling. + ## 0.9.4 ### Patch Changes diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json index 58be5e9d1abf..5eb312bd6841 100644 --- a/packages/markdown/remark/package.json +++ b/packages/markdown/remark/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/markdown-remark", - "version": "0.9.4", + "version": "0.10.0", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index d942bf7bf7e9..5df5566a1ae9 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -36,8 +36,15 @@ export async function renderMarkdown( content: string, opts: MarkdownRenderingOptions = {} ): Promise { - let { fileURL, mode = 'mdx', syntaxHighlight = 'shiki', shikiConfig = {}, remarkPlugins = [], rehypePlugins = [] } = opts; - const input = new VFile({ value: content, path: fileURL }) + let { + fileURL, + mode = 'mdx', + syntaxHighlight = 'shiki', + shikiConfig = {}, + remarkPlugins = [], + rehypePlugins = [], + } = opts; + const input = new VFile({ value: content, path: fileURL }); const scopedClassName = opts.$?.scopedClassName; const isMDX = mode === 'mdx'; const { headers, rehypeCollectHeaders } = createCollectHeaders(); diff --git a/packages/markdown/remark/src/mdast-util-mdxish.ts b/packages/markdown/remark/src/mdast-util-mdxish.ts index 52a99deeba43..10b19f5be0c9 100644 --- a/packages/markdown/remark/src/mdast-util-mdxish.ts +++ b/packages/markdown/remark/src/mdast-util-mdxish.ts @@ -1,18 +1,12 @@ -import { - mdxExpressionFromMarkdown, - mdxExpressionToMarkdown -} from 'mdast-util-mdx-expression' -import {mdxJsxFromMarkdown, mdxJsxToMarkdown} from 'mdast-util-mdx-jsx' +import { mdxExpressionFromMarkdown, mdxExpressionToMarkdown } from 'mdast-util-mdx-expression'; +import { mdxJsxFromMarkdown, mdxJsxToMarkdown } from 'mdast-util-mdx-jsx'; export function mdxFromMarkdown(): any { - return [mdxExpressionFromMarkdown, mdxJsxFromMarkdown] + return [mdxExpressionFromMarkdown, mdxJsxFromMarkdown]; } export function mdxToMarkdown(): any { - return { - extensions: [ - mdxExpressionToMarkdown, - mdxJsxToMarkdown, - ] - } + return { + extensions: [mdxExpressionToMarkdown, mdxJsxToMarkdown], + }; } diff --git a/packages/markdown/remark/src/rehype-collect-headers.ts b/packages/markdown/remark/src/rehype-collect-headers.ts index 77126ab7e57e..426b782a32ad 100644 --- a/packages/markdown/remark/src/rehype-collect-headers.ts +++ b/packages/markdown/remark/src/rehype-collect-headers.ts @@ -31,21 +31,22 @@ export default function createCollectHeaders() { return; } } - if (child.type === 'text' || child.type === 'raw') { + if (child.type === 'text' || child.type === 'raw') { raw += child.value; text += child.value; isJSX = isJSX || child.value.includes('{'); } }); - node.properties = node.properties || {}; if (typeof node.properties.id !== 'string') { if (isJSX) { // HACK: for ids that have JSX content, use $$slug helper to generate slug at runtime node.properties.id = `$$slug(\`${text.replace(/\{/g, '${')}\`)`; (node as any).type = 'raw'; - (node as any).value = `<${node.tagName} id={${node.properties.id}}>${raw}`; + ( + node as any + ).value = `<${node.tagName} id={${node.properties.id}}>${raw}`; } else { node.properties.id = slugger.slug(text); } diff --git a/packages/markdown/remark/src/rehype-jsx.ts b/packages/markdown/remark/src/rehype-jsx.ts index 62eb977c09a8..8549b2624495 100644 --- a/packages/markdown/remark/src/rehype-jsx.ts +++ b/packages/markdown/remark/src/rehype-jsx.ts @@ -9,36 +9,36 @@ export default function rehypeJsx(): any { } if (MDX_ELEMENTS.has(child.type)) { const attrs = child.attributes.reduce((acc: any[], entry: any) => { - let attr = entry.value; - if (attr && typeof attr === 'object') { - attr = `{${attr.value}}`; - } else if (attr && entry.type === 'mdxJsxExpressionAttribute') { - attr = `{${attr}}` - } else if (attr === null) { - attr = ""; - } else if (typeof attr === 'string') { - attr = `"${attr}"`; - } - if (!entry.name) { - return acc + ` ${attr}`; - } - return acc + ` ${entry.name}${attr ? '=' : ''}${attr}`; - }, ''); + let attr = entry.value; + if (attr && typeof attr === 'object') { + attr = `{${attr.value}}`; + } else if (attr && entry.type === 'mdxJsxExpressionAttribute') { + attr = `{${attr}}`; + } else if (attr === null) { + attr = ''; + } else if (typeof attr === 'string') { + attr = `"${attr}"`; + } + if (!entry.name) { + return acc + ` ${attr}`; + } + return acc + ` ${entry.name}${attr ? '=' : ''}${attr}`; + }, ''); if (child.children.length === 0) { return { type: 'raw', - value: `<${child.name}${attrs} />` + value: `<${child.name}${attrs} />`, }; } child.children.splice(0, 0, { type: 'raw', - value: `\n<${child.name}${attrs}>` - }) + value: `\n<${child.name}${attrs}>`, + }); child.children.push({ type: 'raw', - value: `\n` - }) + value: `\n`, + }); return { ...child, type: 'element', diff --git a/packages/markdown/remark/src/remark-mark-and-unravel.ts b/packages/markdown/remark/src/remark-mark-and-unravel.ts index 4490e4a93a6e..294d4211d7b0 100644 --- a/packages/markdown/remark/src/remark-mark-and-unravel.ts +++ b/packages/markdown/remark/src/remark-mark-and-unravel.ts @@ -8,7 +8,7 @@ * @typedef {import('remark-mdx')} DoNotTouchAsThisImportItIncludesMdxInTree */ -import {visit} from 'unist-util-visit' +import { visit } from 'unist-util-visit'; /** * A tiny plugin that unravels `

x

` but also @@ -19,63 +19,54 @@ import {visit} from 'unist-util-visit' * @type {import('unified').Plugin, Root>} */ export default function remarkMarkAndUnravel() { - return (tree: any) => { - visit(tree, (node, index, parent_) => { - const parent = /** @type {Parent} */ (parent_) - let offset = -1 - let all = true - /** @type {boolean|undefined} */ - let oneOrMore + return (tree: any) => { + visit(tree, (node, index, parent_) => { + const parent = /** @type {Parent} */ parent_; + let offset = -1; + let all = true; + /** @type {boolean|undefined} */ + let oneOrMore; - if (parent && typeof index === 'number' && node.type === 'paragraph') { - const children = node.children + if (parent && typeof index === 'number' && node.type === 'paragraph') { + const children = node.children; - while (++offset < children.length) { - const child = children[offset] + while (++offset < children.length) { + const child = children[offset]; - if ( - child.type === 'mdxJsxTextElement' || - child.type === 'mdxTextExpression' - ) { - oneOrMore = true - } else if ( - child.type === 'text' && - /^[\t\r\n ]+$/.test(String(child.value)) - ) { - // Empty. - } else { - all = false - break - } - } + if (child.type === 'mdxJsxTextElement' || child.type === 'mdxTextExpression') { + oneOrMore = true; + } else if (child.type === 'text' && /^[\t\r\n ]+$/.test(String(child.value))) { + // Empty. + } else { + all = false; + break; + } + } - if (all && oneOrMore) { - offset = -1 + if (all && oneOrMore) { + offset = -1; - while (++offset < children.length) { - const child = children[offset] + while (++offset < children.length) { + const child = children[offset]; - if (child.type === 'mdxJsxTextElement') { - child.type = 'mdxJsxFlowElement' - } + if (child.type === 'mdxJsxTextElement') { + child.type = 'mdxJsxFlowElement'; + } - if (child.type === 'mdxTextExpression') { - child.type = 'mdxFlowExpression' - } - } + if (child.type === 'mdxTextExpression') { + child.type = 'mdxFlowExpression'; + } + } - parent.children.splice(index, 1, ...children) - return index - } - } + parent.children.splice(index, 1, ...children); + return index; + } + } - if ( - node.type === 'mdxJsxFlowElement' || - node.type === 'mdxJsxTextElement' - ) { - const data = node.data || (node.data = {}) - data._mdxExplicitJsx = true - } - }) - } + if (node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') { + const data = node.data || (node.data = {}); + data._mdxExplicitJsx = true; + } + }); + }; } diff --git a/packages/markdown/remark/src/remark-mdxish.ts b/packages/markdown/remark/src/remark-mdxish.ts index b5d41d228382..0ad8cbf4f85b 100644 --- a/packages/markdown/remark/src/remark-mdxish.ts +++ b/packages/markdown/remark/src/remark-mdxish.ts @@ -1,15 +1,15 @@ -import {mdxjs} from 'micromark-extension-mdxjs' -import { mdxFromMarkdown, mdxToMarkdown } from './mdast-util-mdxish.js' +import { mdxjs } from 'micromark-extension-mdxjs'; +import { mdxFromMarkdown, mdxToMarkdown } from './mdast-util-mdxish.js'; export default function remarkMdxish(this: any, options = {}) { - const data = this.data() + const data = this.data(); - add('micromarkExtensions', mdxjs(options)) - add('fromMarkdownExtensions', mdxFromMarkdown()) - add('toMarkdownExtensions', mdxToMarkdown()) + add('micromarkExtensions', mdxjs(options)); + add('fromMarkdownExtensions', mdxFromMarkdown()); + add('toMarkdownExtensions', mdxToMarkdown()); - function add(field: string, value: unknown) { - const list = data[field] ? data[field] : (data[field] = []) - list.push(value) - } + function add(field: string, value: unknown) { + const list = data[field] ? data[field] : (data[field] = []); + list.push(value); + } } diff --git a/packages/markdown/remark/test/components.test.js b/packages/markdown/remark/test/components.test.js index 0f3418c24fb5..6e8017aa09ed 100644 --- a/packages/markdown/remark/test/components.test.js +++ b/packages/markdown/remark/test/components.test.js @@ -49,14 +49,23 @@ describe('components', () => { it('should normalize children', async () => { const { code } = await renderMarkdown(`Hello world!`, {}); - chai.expect(code).to.equal(`\nHello world!\n`); + chai + .expect(code) + .to.equal(`\nHello world!\n`); }); it('should allow markdown without many spaces', async () => { - const { code } = await renderMarkdown(` + const { code } = await renderMarkdown( + ` # Hello world! -`, {}); - - chai.expect(code).to.equal(`\n

Hello world!

\n
`); +
`, + {} + ); + + chai + .expect(code) + .to.equal( + `\n

Hello world!

\n
` + ); }); }); diff --git a/packages/markdown/remark/test/expressions.test.js b/packages/markdown/remark/test/expressions.test.js index bcc95cbede9a..17674c5439a6 100644 --- a/packages/markdown/remark/test/expressions.test.js +++ b/packages/markdown/remark/test/expressions.test.js @@ -17,24 +17,35 @@ describe('expressions', () => { it('should be able to serialize expression inside markdown', async () => { const { code } = await renderMarkdown(`# {frontmatter.title}`, {}); - chai.expect(code).to.equal(`

{frontmatter.title}

`); + chai + .expect(code) + .to.equal(`

{frontmatter.title}

`); }); it('should be able to serialize complex expression inside markdown', async () => { const { code } = await renderMarkdown(`# Hello {frontmatter.name}`, {}); - chai.expect(code).to.equal(`

Hello {frontmatter.name}

`); + chai + .expect(code) + .to.equal(`

Hello {frontmatter.name}

`); }); it('should be able to serialize complex expression with markup inside markdown', async () => { const { code } = await renderMarkdown(`# Hello {frontmatter.name}`, {}); - chai.expect(code).to.equal(`

Hello {frontmatter.name}

`); + chai + .expect(code) + .to.equal( + `

Hello {frontmatter.name}

` + ); }); it('should be able to serialize function expression', async () => { - const { code } = await renderMarkdown(`{frontmatter.list.map(item =>

{item}

)}` , {}); + const { code } = await renderMarkdown( + `{frontmatter.list.map(item =>

{item}

)}`, + {} + ); chai.expect(code).to.equal(`{frontmatter.list.map(item =>

{item}

)}`); - }) + }); }); diff --git a/packages/markdown/remark/test/plugins.test.js b/packages/markdown/remark/test/plugins.test.js index 4954047b51e6..a1abeb2ed242 100644 --- a/packages/markdown/remark/test/plugins.test.js +++ b/packages/markdown/remark/test/plugins.test.js @@ -16,11 +16,11 @@ describe('plugins', () => { }; return transformer; - } - ] + }, + ], }); chai.expect(typeof context).to.equal('object'); chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url))); }); -}) +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2b98c3d5f40..abc9097c3646 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -45,14 +45,14 @@ importers: examples/basics: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/blog: specifiers: '@astrojs/preact': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 dependencies: preact: 10.7.2 @@ -63,7 +63,7 @@ importers: examples/blog-multiple-authors: specifiers: '@astrojs/preact': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 sass: ^1.52.1 dependencies: @@ -75,14 +75,14 @@ importers: examples/component: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/component/demo: specifiers: '@example/my-component': workspace:* - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: '@example/my-component': link:../packages/my-component astro: link:../../../packages/astro @@ -98,7 +98,7 @@ importers: '@docsearch/css': ^3.1.0 '@docsearch/react': ^3.1.0 '@types/react': ^17.0.45 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 react: ^17.0.2 react-dom: ^17.0.2 @@ -117,14 +117,14 @@ importers: examples/env-vars: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/framework-alpine: specifiers: alpinejs: ^3.10.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 dependencies: alpinejs: 3.10.2 devDependencies: @@ -134,7 +134,7 @@ importers: specifiers: '@astrojs/lit': ^0.1.3 '@webcomponents/template-shadowroot': ^0.1.0 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 lit: ^2.2.4 dependencies: '@webcomponents/template-shadowroot': 0.1.0 @@ -152,7 +152,7 @@ importers: '@astrojs/svelte': ^0.1.3 '@astrojs/vue': ^0.1.4 '@webcomponents/template-shadowroot': ^0.1.0 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 lit: ^2.2.4 preact: ^10.7.2 react: ^18.1.0 @@ -181,7 +181,7 @@ importers: examples/framework-preact: specifiers: '@astrojs/preact': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 dependencies: preact: 10.7.2 @@ -194,7 +194,7 @@ importers: '@astrojs/react': ^0.1.2 '@types/react': ^18.0.9 '@types/react-dom': ^18.0.5 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 react: ^18.1.0 react-dom: ^18.1.0 dependencies: @@ -209,7 +209,7 @@ importers: examples/framework-solid: specifiers: '@astrojs/solid-js': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 solid-js: ^1.4.2 dependencies: solid-js: 1.4.2 @@ -220,7 +220,7 @@ importers: examples/framework-svelte: specifiers: '@astrojs/svelte': ^0.1.3 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 svelte: ^3.48.0 dependencies: svelte: 3.48.0 @@ -231,7 +231,7 @@ importers: examples/framework-vue: specifiers: '@astrojs/vue': ^0.1.4 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 vue: ^3.2.36 dependencies: vue: 3.2.36 @@ -242,14 +242,14 @@ importers: examples/integrations-playground: specifiers: '@astrojs/lit': ^0.1.3 - '@astrojs/partytown': ^0.1.3 + '@astrojs/partytown': ^0.1.4 '@astrojs/react': ^0.1.2 '@astrojs/sitemap': ^0.1.0 '@astrojs/solid-js': 0.1.2 '@astrojs/tailwind': ^0.2.1 '@astrojs/turbolinks': ^0.1.3 '@webcomponents/template-shadowroot': ^0.1.0 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 lit: ^2.2.4 preact: ^10.7.2 react: ^18.1.0 @@ -278,20 +278,20 @@ importers: examples/minimal: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/non-html-pages: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/portfolio: specifiers: '@astrojs/preact': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 sass: ^1.52.1 dependencies: @@ -305,7 +305,7 @@ importers: specifiers: '@astrojs/node': ^0.1.2 '@astrojs/svelte': ^0.1.3 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 concurrently: ^7.2.1 lightcookie: ^1.0.25 svelte: ^3.48.0 @@ -324,14 +324,14 @@ importers: examples/starter: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 devDependencies: astro: link:../../packages/astro examples/subpath: specifiers: '@astrojs/react': ^0.1.2 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 react: ^18.1.0 react-dom: ^18.1.0 sass: ^1.52.1 @@ -345,12 +345,12 @@ importers: examples/with-markdown: specifiers: - '@astrojs/markdown-remark': ^0.9.4 + '@astrojs/markdown-remark': ^0.10.0 '@astrojs/preact': ^0.1.2 '@astrojs/react': ^0.1.2 '@astrojs/svelte': ^0.1.3 '@astrojs/vue': ^0.1.4 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 preact: ^10.7.2 react: ^18.1.0 react-dom: ^18.1.0 @@ -372,8 +372,8 @@ importers: examples/with-markdown-plugins: specifiers: - '@astrojs/markdown-remark': ^0.9.4 - astro: ^1.0.0-beta.32 + '@astrojs/markdown-remark': ^0.10.0 + astro: ^1.0.0-beta.33 hast-util-select: 5.0.1 rehype-autolink-headings: ^6.1.1 rehype-slug: ^5.0.1 @@ -390,8 +390,8 @@ importers: examples/with-markdown-shiki: specifiers: - '@astrojs/markdown-remark': ^0.9.4 - astro: ^1.0.0-beta.32 + '@astrojs/markdown-remark': ^0.10.0 + astro: ^1.0.0-beta.33 devDependencies: '@astrojs/markdown-remark': link:../../packages/markdown/remark astro: link:../../packages/astro @@ -406,7 +406,7 @@ importers: '@nanostores/preact': ^0.1.3 '@nanostores/react': ^0.1.5 '@nanostores/vue': ^0.4.1 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 nanostores: ^0.5.12 preact: ^10.7.2 react: ^18.1.0 @@ -434,7 +434,7 @@ importers: examples/with-tailwindcss: specifiers: '@astrojs/tailwind': ^0.2.1 - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 autoprefixer: ^10.4.7 canvas-confetti: ^1.5.1 postcss: ^8.4.14 @@ -449,7 +449,7 @@ importers: examples/with-vite-plugin-pwa: specifiers: - astro: ^1.0.0-beta.32 + astro: ^1.0.0-beta.33 vite-plugin-pwa: 0.11.11 workbox-window: ^6.5.3 devDependencies: @@ -461,7 +461,7 @@ importers: specifiers: '@astrojs/compiler': ^0.15.0 '@astrojs/language-server': ^0.13.4 - '@astrojs/markdown-remark': ^0.9.4 + '@astrojs/markdown-remark': ^0.10.0 '@astrojs/prism': 0.4.1 '@astrojs/telemetry': ^0.1.2 '@astrojs/webapi': ^0.12.0 @@ -7877,11 +7877,6 @@ packages: /debug/3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true dependencies: ms: 2.1.3 dev: false @@ -10784,8 +10779,6 @@ packages: debug: 3.2.7 iconv-lite: 0.4.24 sax: 1.2.4 - transitivePeerDependencies: - - supports-color dev: false /netmask/2.0.2: @@ -10869,8 +10862,6 @@ packages: rimraf: 2.7.1 semver: 5.7.1 tar: 4.4.19 - transitivePeerDependencies: - - supports-color dev: false /node-releases/2.0.5: