diff options
author | 2023-06-10 13:43:26 -0400 | |
---|---|---|
committer | 2023-06-10 13:43:26 -0400 | |
commit | a30f2f3de440c39c88a4e0ed3f47064a6b5a54f7 (patch) | |
tree | 32ea351ef5ce789d423226fbe703cf3a46efc260 /packages/integrations/markdoc/src/index.ts | |
parent | 491c2db424434167327e780ad57b8f665498003d (diff) | |
download | astro-a30f2f3de440c39c88a4e0ed3f47064a6b5a54f7.tar.gz astro-a30f2f3de440c39c88a4e0ed3f47064a6b5a54f7.tar.zst astro-a30f2f3de440c39c88a4e0ed3f47064a6b5a54f7.zip |
Fix Markdoc cloudflare errors (#7351)
* fix: move `node:` libs out of utils
* fix: node -> default
* chore: remove kleur from markdoc ex (why was this there??)
* chore: lock
* chore: changeset
Diffstat (limited to 'packages/integrations/markdoc/src/index.ts')
-rw-r--r-- | packages/integrations/markdoc/src/index.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/integrations/markdoc/src/index.ts b/packages/integrations/markdoc/src/index.ts index 781ae392e..71edf3095 100644 --- a/packages/integrations/markdoc/src/index.ts +++ b/packages/integrations/markdoc/src/index.ts @@ -4,8 +4,8 @@ import Markdoc from '@markdoc/markdoc'; import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro'; import fs from 'node:fs'; import { fileURLToPath, pathToFileURL } from 'node:url'; +import crypto from 'node:crypto'; import { - createNameHash, hasContentFlag, isValidUrl, MarkdocError, @@ -292,3 +292,18 @@ function shouldOptimizeImage(src: string) { // Optimize anything that is NOT external or an absolute path to `public/` return !isValidUrl(src) && !src.startsWith('/'); } + +/** + * Create build hash for manual Rollup chunks. + * @see 'packages/astro/src/core/build/plugins/plugin-css.ts' + */ +function createNameHash(baseId: string, hashIds: string[]): string { + const baseName = baseId ? path.parse(baseId).name : 'index'; + const hash = crypto.createHash('sha256'); + for (const id of hashIds) { + hash.update(id, 'utf-8'); + } + const h = hash.digest('hex').slice(0, 8); + const proposedName = baseName + '.' + h; + return proposedName; +} |