refactor: isPerfBenchmark

This commit is contained in:
bholmesdev 2023-02-27 14:00:06 -05:00
parent f0135576af
commit 6c80241c88

View file

@ -39,6 +39,9 @@ export const markdownConfigDefaults: Omit<Required<AstroMarkdownOptions>, 'draft
smartypants: true, smartypants: true,
}; };
// Skip nonessential plugins during performance benchmark runs
const isPerformanceBenchmark = Boolean(process.env.ASTRO_CI_PERFORMANCE_RUN);
/** Shared utility for rendering markdown */ /** Shared utility for rendering markdown */
export async function renderMarkdown( export async function renderMarkdown(
content: string, content: string,
@ -56,7 +59,6 @@ export async function renderMarkdown(
contentDir, contentDir,
frontmatter: userFrontmatter = {}, frontmatter: userFrontmatter = {},
} = opts; } = opts;
const performanceRun = Boolean(process.env.ASTRO_CI_PERFORMANCE_RUN);
const input = new VFile({ value: content, path: fileURL }); const input = new VFile({ value: content, path: fileURL });
const scopedClassName = opts.$?.scopedClassName; const scopedClassName = opts.$?.scopedClassName;
@ -65,7 +67,7 @@ export async function renderMarkdown(
.use(toRemarkInitializeAstroData({ userFrontmatter })) .use(toRemarkInitializeAstroData({ userFrontmatter }))
.use([]); .use([]);
if (!performanceRun) { if (!isPerformanceBenchmark) {
if (gfm) { if (gfm) {
parser.use(remarkGfm); parser.use(remarkGfm);
} }
@ -82,7 +84,7 @@ export async function renderMarkdown(
parser.use([[plugin, pluginOpts]]); parser.use([[plugin, pluginOpts]]);
}); });
if (!performanceRun) { if (!isPerformanceBenchmark) {
if (scopedClassName) { if (scopedClassName) {
parser.use([scopedStyles(scopedClassName)]); parser.use([scopedStyles(scopedClassName)]);
} }
@ -112,7 +114,7 @@ export async function renderMarkdown(
parser.use([[plugin, pluginOpts]]); parser.use([[plugin, pluginOpts]]);
}); });
if (!performanceRun) { if (!isPerformanceBenchmark) {
parser.use([rehypeHeadingIds]); parser.use([rehypeHeadingIds]);
} }