Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/integrations/mdx/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { AstroError } from 'astro/errors';
import { AstroJSX, jsx } from 'astro/jsx-runtime';
import { renderJSX } from 'astro/runtime/server/index.js';

const slotName = (str: string) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
export const slotName = (str: string) =>
str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());

// NOTE: In practice, MDX components are always tagged with `__astro_tag_component__`, so the right renderer
// is used directly, and this check is not often used to return true.
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/mdx/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { MdxjsEsm } from 'mdast-util-mdx';
import colors from 'piccolore';
import type { PluggableList } from 'unified';

function appendForwardSlash(path: string) {
export function appendForwardSlash(path: string) {
return path.endsWith('/') ? path : path + '/';
}

Expand Down
10 changes: 5 additions & 5 deletions packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function vitePluginMdxPostprocess(astroConfig: AstroConfig): Plugin {
/**
* Inject `Fragment` identifier import if not already present.
*/
function injectUnderscoreFragmentImport(code: string, imports: readonly ImportSpecifier[]) {
export function injectUnderscoreFragmentImport(code: string, imports: readonly ImportSpecifier[]) {
if (!isSpecifierImported(code, imports, underscoreFragmentImportRegex, 'astro/jsx-runtime')) {
code += `\nimport { Fragment as _Fragment } from 'astro/jsx-runtime';`;
}
Expand All @@ -55,7 +55,7 @@ function injectUnderscoreFragmentImport(code: string, imports: readonly ImportSp
/**
* Inject MDX metadata as exports of the module.
*/
function injectMetadataExports(
export function injectMetadataExports(
code: string,
exports: readonly ExportSpecifier[],
fileInfo: FileInfo,
Expand All @@ -73,7 +73,7 @@ function injectMetadataExports(
* Transforms the `MDXContent` default export as `Content`, which wraps `MDXContent` and
* passes additional `components` props.
*/
function transformContentExport(code: string, exports: readonly ExportSpecifier[]) {
export function transformContentExport(code: string, exports: readonly ExportSpecifier[]) {
if (exports.find(({ n }) => n === 'Content')) return code;

// If have `export const components`, pass that as props to `Content` as fallback
Expand Down Expand Up @@ -105,7 +105,7 @@ export default Content;`;
/**
* Add properties to the `Content` export.
*/
function annotateContentExport(
export function annotateContentExport(
code: string,
id: string,
ssr: boolean,
Expand Down Expand Up @@ -139,7 +139,7 @@ function annotateContentExport(
/**
* Check whether the `specifierRegex` matches for an import of `source` in the `code`.
*/
function isSpecifierImported(
export function isSpecifierImported(
code: string,
imports: readonly ImportSpecifier[],
specifierRegex: RegExp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { parse } from 'node:path';
const components = Object.values(import.meta.glob('../components/*.mdx', { eager: true }));
const components = Object.values(import.meta.glob('../../components/component/*.mdx', { eager: true }));
---

<div data-default-export>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import Test from '../../components/component/Test.mdx';
---

<Test />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import WithFragment from '../../components/component/WithFragment.mdx';
---

<WithFragment />
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Using YAML frontmatter'
layout: '../layouts/Base.astro'
layout: '../../layouts/Base.astro'
illThrowIfIDontExist: "Oh no, that's scary!"
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: '../layouts/Base.astro'
layout: '../../layouts/Base.astro'
---

## Section 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
const components = Object.values(import.meta.glob('../components/*.mdx', { eager: true }));
const components = Object.values(import.meta.glob('../../components/slots/*.mdx', { eager: true }));
---

<div data-default-export>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
import Test from '../../components/slots/Test.mdx';
---

<Test />
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
export const getStaticPaths = async () => {
const content = Object.values(import.meta.glob('../content/*.mdx', { eager: true }));
const content = Object.values(import.meta.glob('../../content/*.mdx', { eager: true }));

return content
.filter((page) => !page.frontmatter.draft) // skip drafts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# I'm a page with a url of "/url-export/test-1!"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# I'm a page with a url of "/url-export/test-2!"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading