@astrojs/mdx 1.0.0-beta.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +83 -19
  2. package/dist/index.d.ts +4 -2
  3. package/dist/index.js +83 -35
  4. package/dist/plugins.d.ts +4 -5
  5. package/dist/plugins.js +36 -80
  6. package/dist/rehype-collect-headings.d.ts +1 -1
  7. package/dist/rehype-meta-string.js +2 -3
  8. package/dist/rehype-optimize-static.d.ts +11 -0
  9. package/dist/rehype-optimize-static.js +62 -0
  10. package/dist/remark-images-to-component.d.ts +2 -0
  11. package/dist/remark-images-to-component.js +83 -0
  12. package/dist/utils.d.ts +2 -1
  13. package/dist/utils.js +23 -15
  14. package/package.json +39 -30
  15. package/template/content-module-types.d.ts +9 -0
  16. package/.turbo/turbo-build.log +0 -5
  17. package/CHANGELOG.md +0 -469
  18. package/src/index.ts +0 -201
  19. package/src/plugins.ts +0 -246
  20. package/src/rehype-collect-headings.ts +0 -11
  21. package/src/rehype-meta-string.ts +0 -17
  22. package/src/remark-prism.ts +0 -18
  23. package/src/remark-shiki.ts +0 -95
  24. package/src/utils.ts +0 -102
  25. package/test/fixtures/mdx-astro-markdown-remarkRehype/src/pages/index.mdx +0 -5
  26. package/test/fixtures/mdx-component/src/components/Test.mdx +0 -3
  27. package/test/fixtures/mdx-component/src/components/WithFragment.mdx +0 -3
  28. package/test/fixtures/mdx-component/src/pages/glob.astro +0 -20
  29. package/test/fixtures/mdx-component/src/pages/index.astro +0 -5
  30. package/test/fixtures/mdx-component/src/pages/w-fragment.astro +0 -5
  31. package/test/fixtures/mdx-escape/src/components/Em.astro +0 -7
  32. package/test/fixtures/mdx-escape/src/components/P.astro +0 -1
  33. package/test/fixtures/mdx-escape/src/components/Title.astro +0 -1
  34. package/test/fixtures/mdx-escape/src/pages/html-tag.mdx +0 -5
  35. package/test/fixtures/mdx-escape/src/pages/index.mdx +0 -13
  36. package/test/fixtures/mdx-frontmatter/src/layouts/Base.astro +0 -38
  37. package/test/fixtures/mdx-frontmatter/src/pages/glob.json.js +0 -9
  38. package/test/fixtures/mdx-frontmatter/src/pages/index.mdx +0 -10
  39. package/test/fixtures/mdx-frontmatter/src/pages/with-headings.mdx +0 -7
  40. package/test/fixtures/mdx-frontmatter-injection/astro.config.mjs +0 -12
  41. package/test/fixtures/mdx-frontmatter-injection/node_modules/.bin/astro +0 -17
  42. package/test/fixtures/mdx-frontmatter-injection/package.json +0 -12
  43. package/test/fixtures/mdx-frontmatter-injection/src/layouts/Base.astro +0 -17
  44. package/test/fixtures/mdx-frontmatter-injection/src/markdown-plugins.mjs +0 -27
  45. package/test/fixtures/mdx-frontmatter-injection/src/pages/glob.json.js +0 -6
  46. package/test/fixtures/mdx-frontmatter-injection/src/pages/page-1.mdx +0 -8
  47. package/test/fixtures/mdx-frontmatter-injection/src/pages/page-2.mdx +0 -24
  48. package/test/fixtures/mdx-get-headings/src/pages/pages.json.js +0 -11
  49. package/test/fixtures/mdx-get-headings/src/pages/test-with-jsx-expressions.mdx +0 -8
  50. package/test/fixtures/mdx-get-headings/src/pages/test.mdx +0 -9
  51. package/test/fixtures/mdx-get-static-paths/src/content/1.mdx +0 -5
  52. package/test/fixtures/mdx-get-static-paths/src/pages/[slug].astro +0 -34
  53. package/test/fixtures/mdx-infinite-loop/astro.config.ts +0 -6
  54. package/test/fixtures/mdx-infinite-loop/node_modules/.bin/astro +0 -17
  55. package/test/fixtures/mdx-infinite-loop/package.json +0 -10
  56. package/test/fixtures/mdx-infinite-loop/src/components/Test.js +0 -3
  57. package/test/fixtures/mdx-infinite-loop/src/pages/doc.mdx +0 -6
  58. package/test/fixtures/mdx-infinite-loop/src/pages/index.astro +0 -5
  59. package/test/fixtures/mdx-namespace/astro.config.mjs +0 -6
  60. package/test/fixtures/mdx-namespace/node_modules/.bin/astro +0 -17
  61. package/test/fixtures/mdx-namespace/package.json +0 -10
  62. package/test/fixtures/mdx-namespace/src/components/Component.jsx +0 -6
  63. package/test/fixtures/mdx-namespace/src/pages/object.mdx +0 -3
  64. package/test/fixtures/mdx-namespace/src/pages/star.mdx +0 -3
  65. package/test/fixtures/mdx-page/astro.config.ts +0 -5
  66. package/test/fixtures/mdx-page/node_modules/.bin/astro +0 -17
  67. package/test/fixtures/mdx-page/package.json +0 -9
  68. package/test/fixtures/mdx-page/src/pages/index.mdx +0 -3
  69. package/test/fixtures/mdx-page/src/styles.css +0 -3
  70. package/test/fixtures/mdx-plugins/src/pages/with-plugins.mdx +0 -25
  71. package/test/fixtures/mdx-plus-react/astro.config.mjs +0 -6
  72. package/test/fixtures/mdx-plus-react/node_modules/.bin/astro +0 -17
  73. package/test/fixtures/mdx-plus-react/package.json +0 -10
  74. package/test/fixtures/mdx-plus-react/src/components/Component.jsx +0 -5
  75. package/test/fixtures/mdx-plus-react/src/pages/index.astro +0 -11
  76. package/test/fixtures/mdx-slots/src/components/Slotted.astro +0 -4
  77. package/test/fixtures/mdx-slots/src/components/Test.mdx +0 -15
  78. package/test/fixtures/mdx-slots/src/pages/glob.astro +0 -11
  79. package/test/fixtures/mdx-slots/src/pages/index.astro +0 -5
  80. package/test/fixtures/mdx-syntax-hightlighting/src/pages/index.mdx +0 -9
  81. package/test/fixtures/mdx-url-export/src/pages/pages.json.js +0 -9
  82. package/test/fixtures/mdx-url-export/src/pages/test-1.mdx +0 -1
  83. package/test/fixtures/mdx-url-export/src/pages/test-2.mdx +0 -1
  84. package/test/fixtures/mdx-url-export/src/pages/with-url-override.mdx +0 -3
  85. package/test/fixtures/mdx-vite-env-vars/astro.config.mjs +0 -9
  86. package/test/fixtures/mdx-vite-env-vars/node_modules/.bin/astro +0 -17
  87. package/test/fixtures/mdx-vite-env-vars/package.json +0 -7
  88. package/test/fixtures/mdx-vite-env-vars/src/pages/frontmatter.json.js +0 -7
  89. package/test/fixtures/mdx-vite-env-vars/src/pages/vite-env-vars.mdx +0 -38
  90. package/test/mdx-astro-markdown-remarkRehype.test.js +0 -85
  91. package/test/mdx-component.test.js +0 -191
  92. package/test/mdx-escape.test.js +0 -32
  93. package/test/mdx-frontmatter-injection.test.js +0 -53
  94. package/test/mdx-frontmatter.test.js +0 -77
  95. package/test/mdx-get-headings.test.js +0 -151
  96. package/test/mdx-get-static-paths.test.js +0 -32
  97. package/test/mdx-infinite-loop.test.js +0 -30
  98. package/test/mdx-namespace.test.js +0 -83
  99. package/test/mdx-page.test.js +0 -64
  100. package/test/mdx-plugins.test.js +0 -250
  101. package/test/mdx-plus-react.test.js +0 -25
  102. package/test/mdx-slots.js +0 -124
  103. package/test/mdx-syntax-highlighting.test.js +0 -145
  104. package/test/mdx-url-export.test.js +0 -28
  105. package/test/mdx-vite-env-vars.test.js +0 -54
  106. package/tsconfig.json +0 -10
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,12 +0,0 @@
1
- {
2
- "name": "@test/mdx-frontmatter-injection",
3
- "version": "0.0.0",
4
- "private": true,
5
- "dependencies": {
6
- "astro": "workspace:*",
7
- "@astrojs/mdx": "workspace:*",
8
- "mdast-util-to-string": "^3.1.0",
9
- "reading-time": "^1.5.0",
10
- "unist-util-visit": "^4.1.0"
11
- }
12
- }
@@ -1,17 +0,0 @@
1
- ---
2
- const defaults = { title: 'Frontmatter not passed to layout!' }
3
- const { frontmatter = defaults, content = defaults } = Astro.props;
4
- ---
5
-
6
- <!DOCTYPE html>
7
- <html lang="en">
8
- <head>
9
- <meta charset="UTF-8">
10
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
11
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
12
- <title>{frontmatter.title}</title>
13
- </head>
14
- <body>
15
- <slot />
16
- </body>
17
- </html>
@@ -1,27 +0,0 @@
1
- import getReadingTime from 'reading-time';
2
- import { toString } from 'mdast-util-to-string';
3
- import { visit } from 'unist-util-visit';
4
-
5
- export function rehypeReadingTime() {
6
- return function (tree, { data }) {
7
- const readingTime = getReadingTime(toString(tree));
8
- data.astro.frontmatter.injectedReadingTime = readingTime;
9
- };
10
- }
11
-
12
- export function remarkTitle() {
13
- return function (tree, { data }) {
14
- visit(tree, ['heading'], (node) => {
15
- if (node.depth === 1) {
16
- data.astro.frontmatter.title = toString(node.children);
17
- }
18
- });
19
- };
20
- }
21
-
22
- export function remarkDescription() {
23
- return function (tree, vfile) {
24
- const { frontmatter } = vfile.data.astro;
25
- frontmatter.description = `Processed by remarkDescription plugin: ${frontmatter.description}`
26
- };
27
- }
@@ -1,6 +0,0 @@
1
- export async function get() {
2
- const docs = await import.meta.glob('./*.mdx', { eager: true });
3
- return {
4
- body: JSON.stringify(Object.values(docs).map(doc => doc.frontmatter)),
5
- }
6
- }
@@ -1,8 +0,0 @@
1
- ---
2
- layout: '../layouts/Base.astro'
3
- description: Page 1 description
4
- ---
5
-
6
- # Page 1
7
-
8
- Look at that!
@@ -1,24 +0,0 @@
1
- ---
2
- layout: '../layouts/Base.astro'
3
- description: Page 2 description
4
- ---
5
-
6
- # Page 2
7
-
8
- ## Table of contents
9
-
10
- ## Section 1
11
-
12
- Some text!
13
-
14
- ### Subsection 1
15
-
16
- Some subsection test!
17
-
18
- ### Subsection 2
19
-
20
- Oh cool, more text!
21
-
22
- ## Section 2
23
-
24
- More content
@@ -1,11 +0,0 @@
1
- export async function get() {
2
- const mdxPages = await import.meta.glob('./*.mdx', { eager: true });
3
-
4
- return {
5
- body: JSON.stringify({
6
- headingsByPage: Object.fromEntries(
7
- Object.entries(mdxPages ?? {}).map(([k, v]) => [k, v?.getHeadings()])
8
- ),
9
- }),
10
- }
11
- }
@@ -1,8 +0,0 @@
1
- export const h2Title = "Section 1"
2
- export const h3Title = "Subsection 1"
3
-
4
- # Heading test with JSX expressions
5
-
6
- ## {h2Title}
7
-
8
- ### {h3Title}
@@ -1,9 +0,0 @@
1
- # Heading test
2
-
3
- ## Section 1
4
-
5
- ### Subsection 1
6
-
7
- ### Subsection 2
8
-
9
- ## Section 2
@@ -1,5 +0,0 @@
1
- ---
2
- one: hello
3
- slug: one
4
- ---
5
- First mdx file
@@ -1,34 +0,0 @@
1
- ---
2
- export const getStaticPaths = async () => {
3
- const content = await Astro.glob('../content/*.mdx');
4
-
5
- return content
6
- .filter((page) => !page.frontmatter.draft) // skip drafts
7
- .map(({ default: MdxContent, frontmatter, url, file }) => {
8
- return {
9
- params: { slug: frontmatter.slug || "index" },
10
- props: {
11
- MdxContent,
12
- file,
13
- frontmatter,
14
- url
15
- }
16
- }
17
- })
18
- }
19
-
20
- const { MdxContent, frontmatter, url, file } = Astro.props;
21
- ---
22
-
23
- <html>
24
- <head>
25
- <title>Page</title>
26
- </head>
27
- <body>
28
- <MdxContent />
29
-
30
- <div id="one">{frontmatter.one}</div>
31
- <div id="url">{url}</div>
32
- <div id="file">{file}</div>
33
- </body>
34
- </html>
@@ -1,6 +0,0 @@
1
- import mdx from '@astrojs/mdx';
2
- import preact from '@astrojs/preact';
3
-
4
- export default {
5
- integrations: [mdx(), preact()]
6
- }
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@test/mdx-infinite-loop",
3
- "type": "module",
4
- "dependencies": {
5
- "@astrojs/mdx": "workspace:*",
6
- "@astrojs/preact": "workspace:*",
7
- "preact": "^10.7.3",
8
- "astro": "workspace:*"
9
- }
10
- }
@@ -1,3 +0,0 @@
1
- export default function () {
2
- return 'Hello world'
3
- }
@@ -1,6 +0,0 @@
1
- import Test, { Missing } from '../components/Test';
2
-
3
- # Hello page!
4
-
5
- <Test />
6
- <Missing />
@@ -1,5 +0,0 @@
1
- ---
2
- const files = await Astro.glob('./**/*.mdx')
3
- ---
4
-
5
- {files.map((file: any) => <file.Content />)}
@@ -1,6 +0,0 @@
1
- import mdx from '@astrojs/mdx';
2
- import react from '@astrojs/react';
3
-
4
- export default {
5
- integrations: [react(), mdx()]
6
- }
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@test/mdx-namespace",
3
- "dependencies": {
4
- "@astrojs/mdx": "workspace:*",
5
- "@astrojs/react": "workspace:*",
6
- "astro": "workspace:*",
7
- "react": "^18.2.0",
8
- "react-dom": "^18.1.0"
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- const Component = () => {
2
- return <p id="component">Hello world</p>;
3
- };
4
- export const ns = {
5
- Component
6
- }
@@ -1,3 +0,0 @@
1
- import * as mod from '../components/Component.jsx';
2
-
3
- <mod.ns.Component client:load />
@@ -1,3 +0,0 @@
1
- import { ns } from '../components/Component.jsx';
2
-
3
- <ns.Component client:load />
@@ -1,5 +0,0 @@
1
- import mdx from '@astrojs/mdx';
2
-
3
- export default {
4
- integrations: [mdx()]
5
- }
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,9 +0,0 @@
1
- {
2
- "name": "@test/mdx-page",
3
- "dependencies": {
4
- "@astrojs/mdx": "workspace:*",
5
- "astro": "workspace:*",
6
- "react": "^18.2.0",
7
- "react-dom": "^18.2.0"
8
- }
9
- }
@@ -1,3 +0,0 @@
1
- import '../styles.css'
2
-
3
- # Hello page!
@@ -1,3 +0,0 @@
1
- p {
2
- color: red;
3
- }
@@ -1,25 +0,0 @@
1
- export let recmaPluginWorking = false
2
-
3
- # TOC test
4
-
5
- ## Table of contents
6
-
7
- ## Section 1
8
-
9
- Some text!
10
-
11
- ### Subsection 1
12
-
13
- Some subsection test!
14
-
15
- ### Subsection 2
16
-
17
- Oh cool, more text!
18
-
19
- ## Section 2
20
-
21
- And section 2, with a hyperlink to check GFM is preserved: https://handle-me-gfm.com
22
-
23
- <div data-recma-plugin-works={recmaPluginWorking}></div>
24
-
25
- > "Smartypants" is -- awesome
@@ -1,6 +0,0 @@
1
- import mdx from '@astrojs/mdx';
2
- import react from '@astrojs/react';
3
-
4
- export default {
5
- integrations: [react(), mdx()]
6
- }
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@test/mdx-plus-react",
3
- "dependencies": {
4
- "@astrojs/mdx": "workspace:*",
5
- "@astrojs/react": "workspace:*",
6
- "astro": "workspace:*",
7
- "react": "^18.2.0",
8
- "react-dom": "^18.2.0"
9
- }
10
- }
@@ -1,5 +0,0 @@
1
- const Component = () => {
2
- return <p>Hello world</p>;
3
- };
4
-
5
- export default Component;
@@ -1,11 +0,0 @@
1
- ---
2
- import Component from "../components/Component.jsx";
3
- ---
4
- <html>
5
- <head>
6
- <title>Testing</title>
7
- </head>
8
- <body>
9
- <Component />
10
- </body>
11
- </html>
@@ -1,4 +0,0 @@
1
- <div class="slotted">
2
- <div data-default-slot><slot /></div>
3
- <div data-named-slot><slot name="named" /></div>
4
- </div>
@@ -1,15 +0,0 @@
1
- import Slotted from './Slotted.astro'
2
-
3
- # Hello slotted component!
4
-
5
- <Slotted>
6
-
7
- Default content.
8
-
9
- <Fragment slot="named">
10
-
11
- Content for named slot.
12
-
13
- </Fragment>
14
-
15
- </Slotted>
@@ -1,11 +0,0 @@
1
- ---
2
- const components = await Astro.glob('../components/*.mdx');
3
- ---
4
-
5
- <div data-default-export>
6
- {components.map(Component => <Component.default />)}
7
- </div>
8
-
9
- <div data-content-export>
10
- {components.map(({ Content }) => <Content />)}
11
- </div>
@@ -1,5 +0,0 @@
1
- ---
2
- import Test from '../components/Test.mdx';
3
- ---
4
-
5
- <Test />
@@ -1,9 +0,0 @@
1
- # Syntax highlighting
2
-
3
- ```astro {2}
4
- ---
5
- const handlesAstroSyntax = true
6
- ---
7
-
8
- <h1>{handlesAstroSyntax}</h1>
9
- ```
@@ -1,9 +0,0 @@
1
- export async function get() {
2
- const mdxPages = await import.meta.glob('./*.mdx', { eager: true });
3
-
4
- return {
5
- body: JSON.stringify({
6
- urls: Object.values(mdxPages ?? {}).map(v => v?.url),
7
- })
8
- }
9
- }
@@ -1 +0,0 @@
1
- # I'm a page with a url of "/test-1!"
@@ -1 +0,0 @@
1
- # I'm a page with a url of "/test-2!"
@@ -1,3 +0,0 @@
1
- export const url = '/AH!'
2
-
3
- # I'm a test with a url override!
@@ -1,9 +0,0 @@
1
- import mdx from '@astrojs/mdx';
2
-
3
- export default {
4
- site: 'https://mdx-is-neat.com/',
5
- markdown: {
6
- syntaxHighlight: false,
7
- },
8
- integrations: [mdx()],
9
- }
@@ -1,17 +0,0 @@
1
- #!/bin/sh
2
- basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
-
4
- case `uname` in
5
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6
- esac
7
-
8
- if [ -z "$NODE_PATH" ]; then
9
- export NODE_PATH="/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
10
- else
11
- export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
12
- fi
13
- if [ -x "$basedir/node" ]; then
14
- exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
15
- else
16
- exec node "$basedir/../../../../../../../astro/astro.js" "$@"
17
- fi
@@ -1,7 +0,0 @@
1
- {
2
- "name": "@test/mdx-env-variables",
3
- "dependencies": {
4
- "astro": "workspace:*",
5
- "@astrojs/mdx": "workspace:*"
6
- }
7
- }
@@ -1,7 +0,0 @@
1
- import { frontmatter } from './vite-env-vars.mdx';
2
-
3
- export function get() {
4
- return {
5
- body: JSON.stringify(frontmatter),
6
- }
7
- }
@@ -1,38 +0,0 @@
1
- ---
2
- title: Let's talk about my import.meta.env.SITE
3
- ---
4
-
5
- export const modeWorks =
6
- import.meta.env.MODE === 'production' ? 'MODE works' : 'MODE does not work!';
7
-
8
- # About my import.meta.env.SITE
9
-
10
- My `import.meta.env.SITE` is so cool, I can put env variables in code!
11
-
12
- ```js
13
- const site = import.meta.env.SITE;
14
- ```
15
-
16
- ## But I can use import.meta.env properly too
17
-
18
- <div data-env-site>
19
-
20
- I can compute my site, for example: {new URL('/blog/cool-post', import.meta.env.SITE)}
21
-
22
- </div>
23
-
24
- <div data-env-variable-exports>
25
-
26
- I can also use `import.meta.env` in variable exports: {modeWorks}
27
-
28
- </div>
29
-
30
- I can also use vars as HTML attributes:
31
-
32
- <div
33
- data-env-dump
34
- data-env-prod={import.meta.env.PROD}
35
- data-env-dev={import.meta.env.DEV}
36
- data-env-base-url={import.meta.env.BASE_URL}
37
- data-env-mode={import.meta.env.MODE}
38
- ></div>