From e74ebcd7dd3f05cff188ac401f9e3cbf7dbff39d Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 11 Jul 2022 21:51:17 -0500 Subject: [PATCH] Fix: reintroduce smoke tests across example projects (#3669) * chore: update smoke tests * chore: bump smoke tests to node@16 * chore: remove gitmodules * chore(ci): prefer node@14 * wip: remove path from smoke clone step * feat: run build:examples from test:smoke * fix: remove no-frozen-lockfile * fix: checkout monorepo last for pnpm setup * wip: replace @astrojs/markdown/remark import from md * fix: remove type defs from generated file * fix: function order * chore: remove ssr-utils export * wip: remove windows from smoke test * fix: instantiate slugger in snippet * fix: exclude with-mdx from smoke (for now) * fix: add quotes on filter flag for safety * chore: changeset * wip: try reintroducing windows smoke * sad chore: remove client: directive from with-mdx * Revert "wip: try reintroducing windows smoke" This reverts commit 9529b1a45c007286c22861e106b82200545e4198. Co-authored-by: Nate Moore Co-authored-by: bholmesdev --- package.json | 1 + src/vite-plugin-markdown/index.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d8fc426fc22..a19f5009265d 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "estree-walker": "^3.0.1", "execa": "^6.1.0", "fast-glob": "^3.2.11", + "github-slugger": "^1.4.0", "gray-matter": "^4.0.3", "html-entities": "^2.3.3", "html-escaper": "^3.0.3", diff --git a/src/vite-plugin-markdown/index.ts b/src/vite-plugin-markdown/index.ts index c2078d937e1e..ffaa8afc7acd 100644 --- a/src/vite-plugin-markdown/index.ts +++ b/src/vite-plugin-markdown/index.ts @@ -161,12 +161,17 @@ export default function markdown({ config }: AstroPluginOptions): Plugin { const { layout = '', components = '', setup = '', ...content } = frontmatter; content.astro = metadata; const prelude = `--- -import { slug as $$slug } from '@astrojs/markdown-remark/ssr-utils'; +import Slugger from 'github-slugger'; ${layout ? `import Layout from '${layout}';` : ''} ${components ? `import * from '${components}';` : ''} ${hasInjectedScript ? `import '${PAGE_SSR_SCRIPT_ID}';` : ''} ${setup} +const slugger = new Slugger(); +function $$slug(value) { + return slugger.slug(value); +} + const $$content = ${JSON.stringify(content)} ---`; const imports = `${layout ? `import Layout from '${layout}';` : ''}