mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
[ci] format
This commit is contained in:
parent
00fab4ce13
commit
41f4a8f9cb
7 changed files with 33 additions and 31 deletions
|
@ -703,7 +703,7 @@ export interface AstroUserConfig {
|
|||
* @see https://docs.astro.build/en/guides/integrations-guide/mdx/
|
||||
* Default: false
|
||||
*/
|
||||
astroFlavoredMarkdown?: boolean;
|
||||
astroFlavoredMarkdown?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
|
|||
vite: {},
|
||||
legacy: {
|
||||
astroFlavoredMarkdown: false,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
|
||||
|
@ -214,7 +214,10 @@ export const AstroConfigSchema = z.object({
|
|||
.default(ASTRO_CONFIG_DEFAULTS.vite),
|
||||
legacy: z
|
||||
.object({
|
||||
astroFlavoredMarkdown: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown),
|
||||
astroFlavoredMarkdown: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown),
|
||||
})
|
||||
.optional()
|
||||
.default({}),
|
||||
|
|
|
@ -175,7 +175,7 @@ export async function render(
|
|||
logging,
|
||||
markdown: {
|
||||
...astroConfig.markdown,
|
||||
isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown
|
||||
isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown,
|
||||
},
|
||||
mod,
|
||||
mode,
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
|
|||
|
||||
if (vnode.type) {
|
||||
if (typeof vnode.type === 'function' && (vnode.type as any)['astro:renderer']) {
|
||||
skipAstroJSXCheck.add(vnode.type)
|
||||
skipAstroJSXCheck.add(vnode.type);
|
||||
}
|
||||
if (typeof vnode.type === 'function' && vnode.props['server:root']) {
|
||||
const output = await vnode.type(vnode.props ?? {});
|
||||
|
@ -91,7 +91,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
|
|||
}
|
||||
if (!isVNode(child)) {
|
||||
_slots.default.push(child);
|
||||
return
|
||||
return;
|
||||
}
|
||||
if ('slot' in child.props) {
|
||||
_slots[child.props.slot] = [...(_slots[child.props.slot] ?? []), child];
|
||||
|
@ -110,10 +110,12 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
|
|||
const slotPromises = [];
|
||||
const slots: Record<string, any> = {};
|
||||
for (const [key, value] of Object.entries(_slots)) {
|
||||
slotPromises.push(renderJSX(result, value).then(output => {
|
||||
if (output.toString().trim().length === 0) return;
|
||||
slots[key] = () => output;
|
||||
}))
|
||||
slotPromises.push(
|
||||
renderJSX(result, value).then((output) => {
|
||||
if (output.toString().trim().length === 0) return;
|
||||
slots[key] = () => output;
|
||||
})
|
||||
);
|
||||
}
|
||||
await Promise.all(slotPromises);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export const DEFAULT_REHYPE_PLUGINS = [];
|
|||
/** Shared utility for rendering markdown */
|
||||
export async function renderMarkdown(
|
||||
content: string,
|
||||
opts: MarkdownRenderingOptions,
|
||||
opts: MarkdownRenderingOptions
|
||||
): Promise<MarkdownRenderingResult> {
|
||||
let {
|
||||
fileURL,
|
||||
|
|
|
@ -5,26 +5,26 @@ describe('autolinking', () => {
|
|||
describe('plain md', () => {
|
||||
it('autolinks URLs starting with a protocol in plain text', async () => {
|
||||
const { code } = await renderMarkdown(`See https://example.com for more.`, {});
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.replace(/\n/g, ''))
|
||||
.to.equal(`<p>See <a href="https://example.com">https://example.com</a> for more.</p>`);
|
||||
});
|
||||
|
||||
|
||||
it('autolinks URLs starting with "www." in plain text', async () => {
|
||||
const { code } = await renderMarkdown(`See www.example.com for more.`, {});
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.trim())
|
||||
.to.equal(`<p>See <a href="http://www.example.com">www.example.com</a> for more.</p>`);
|
||||
});
|
||||
|
||||
|
||||
it('does not autolink URLs in code blocks', async () => {
|
||||
const { code } = await renderMarkdown(
|
||||
'See `https://example.com` or `www.example.com` for more.',
|
||||
{}
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.trim())
|
||||
.to.equal(
|
||||
|
@ -35,14 +35,14 @@ describe('autolinking', () => {
|
|||
});
|
||||
|
||||
describe('astro-flavored md', () => {
|
||||
const renderAstroMd = text => renderMarkdown(text, { isAstroFlavoredMd: true });
|
||||
const renderAstroMd = (text) => renderMarkdown(text, { isAstroFlavoredMd: true });
|
||||
|
||||
it('does not autolink URLs in code blocks', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
'See `https://example.com` or `www.example.com` for more.',
|
||||
{}
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.trim())
|
||||
.to.equal(
|
||||
|
@ -50,24 +50,24 @@ describe('autolinking', () => {
|
|||
`<code is:raw>www.example.com</code> for more.</p>`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('does not autolink URLs in fenced code blocks', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
'Example:\n```\nGo to https://example.com or www.example.com now.\n```'
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code)
|
||||
.to.contain(`<pre is:raw`)
|
||||
.to.contain(`Go to https://example.com or www.example.com now.`);
|
||||
});
|
||||
|
||||
|
||||
it('does not autolink URLs starting with a protocol when nested inside links', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
`See [http://example.com](http://example.com) or ` +
|
||||
`<a test href="https://example.com">https://example.com</a>`
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.replace(/\n/g, ''))
|
||||
.to.equal(
|
||||
|
@ -75,13 +75,13 @@ describe('autolinking', () => {
|
|||
`<a test href="https://example.com">https://example.com</a></p>`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('does not autolink URLs starting with "www." when nested inside links', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
`See [www.example.com](https://www.example.com) or ` +
|
||||
`<a test href="https://www.example.com">www.example.com</a>`
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.replace(/\n/g, ''))
|
||||
.to.equal(
|
||||
|
@ -89,13 +89,13 @@ describe('autolinking', () => {
|
|||
`<a test href="https://www.example.com">www.example.com</a></p>`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('does not autolink URLs when nested several layers deep inside links', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
`<a href="https://www.example.com">**Visit _our www.example.com or ` +
|
||||
`http://localhost pages_ for more!**</a>`
|
||||
);
|
||||
|
||||
|
||||
chai
|
||||
.expect(code.replace(/\n/g, ''))
|
||||
.to.equal(
|
||||
|
@ -104,5 +104,5 @@ describe('autolinking', () => {
|
|||
`</strong></a>`
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -67,10 +67,7 @@ describe('strictness in Astro-flavored markdown', () => {
|
|||
});
|
||||
|
||||
it('should allow attribute names starting with "@" after attribute names', async () => {
|
||||
const { code } = await renderAstroMd(
|
||||
`<button disabled @click="handleClick">Test</button>`,
|
||||
{}
|
||||
);
|
||||
const { code } = await renderAstroMd(`<button disabled @click="handleClick">Test</button>`, {});
|
||||
|
||||
chai.expect(code.trim()).to.equal(`<button disabled @click="handleClick">Test</button>`);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue