diff options
author | 2023-03-24 07:58:56 -0400 | |
---|---|---|
committer | 2023-03-24 07:58:56 -0400 | |
commit | cfcf2e2ffdaa68ace5c84329c05b83559a29d638 (patch) | |
tree | 9f979bf4ac02ebea69192bd239f9ed41efac3c43 /packages/integrations/markdoc/src/utils.ts | |
parent | dfbd09b711f45da230e75a09b12a186320a632a9 (diff) | |
download | astro-cfcf2e2ffdaa68ace5c84329c05b83559a29d638.tar.gz astro-cfcf2e2ffdaa68ace5c84329c05b83559a29d638.tar.zst astro-cfcf2e2ffdaa68ace5c84329c05b83559a29d638.zip |
[Markdoc] Support automatic image optimization with `experimental.assets` (#6630)
* wip: scrappy implementation. It works! 🥳
* chore: add code comments on inline utils
* fix: code cleanup, run on experimental.assets
* feat: support ~/assets alias
* fix: spoof `astro:assets` when outside experimental
* test: image paths in dev and prod
* feat: support any vite alias with ctx.resolve
* fix: avoid trying to process absolute paths
* fix: raise helpful error for invalid vite paths
* refactor: revert URL support on emitAsset
* chore: lint
* refactor: expose emitESMImage from assets base
* wip: why doesn't assets exist
* scary chore: make @astrojs/markdoc truly depend on astro
* fix: import emitESMImage straight from dist
* chore: remove type def from assets package
* chore: screw it, just ts ignore
* deps: rollup types
* refactor: optimize images during parse step
* chore: remove unneeded `.flat()`
* fix: use file-based relative paths
* fix: add back helpful error
* chore: changeset
* deps: move astro back to dev dep
* fix: put emit assets behind flag
* chore: change to markdoc patch
Diffstat (limited to 'packages/integrations/markdoc/src/utils.ts')
-rw-r--r-- | packages/integrations/markdoc/src/utils.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/integrations/markdoc/src/utils.ts b/packages/integrations/markdoc/src/utils.ts index 275c711f0..9d6e5af26 100644 --- a/packages/integrations/markdoc/src/utils.ts +++ b/packages/integrations/markdoc/src/utils.ts @@ -145,3 +145,12 @@ const componentsPropValidator = z.record( export function isCapitalized(str: string) { return str.length > 0 && str[0] === str[0].toUpperCase(); } + +export function isValidUrl(str: string): boolean { + try { + new URL(str); + return true; + } catch { + return false; + } +} |