dineway 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/{apply-CAPvMfoU.mjs → apply-iVSqz2qs.mjs} +132 -39
- package/dist/astro/index.d.mts +18 -9
- package/dist/astro/index.mjs +238 -16
- package/dist/astro/middleware/auth.d.mts +16 -5
- package/dist/astro/middleware/auth.mjs +74 -37
- package/dist/astro/middleware/redirect.mjs +24 -8
- package/dist/astro/middleware/request-context.mjs +18 -5
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.mjs +411 -169
- package/dist/astro/types.d.mts +25 -8
- package/dist/{byline-DeWCMU_i.mjs → byline-OhH2dlRu.mjs} +6 -21
- package/dist/{bylines-DyqBV9EQ.mjs → bylines-BGpD9_hy.mjs} +16 -6
- package/dist/cache-BdSY-gQN.mjs +42 -0
- package/dist/chunks--4F8ddV4.mjs +18 -0
- package/dist/cli/index.mjs +935 -15
- package/dist/client/external-auth-headers.d.mts +1 -1
- package/dist/client/index.d.mts +11 -3
- package/dist/client/index.mjs +4 -3
- package/dist/{connection-C9pxzuag.mjs → connection-BCNICDWN.mjs} +22 -5
- package/dist/{content-zSgdNmnt.mjs → content-DWi4d0rT.mjs} +41 -2
- package/dist/database/instrumentation.d.mts +34 -0
- package/dist/database/instrumentation.mjs +53 -0
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +2 -2
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/libsql.mjs +11 -5
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/db/sqlite.mjs +7 -1
- package/dist/db-errors-CEqD7qH9.mjs +23 -0
- package/dist/{default-WYlzADZL.mjs → default-VjJyuuG9.mjs} +2 -0
- package/dist/{dialect-helpers-B9uSp2GJ.mjs → dialect-helpers-DhTzaUxP.mjs} +3 -0
- package/dist/{error-DrxtnGPg.mjs → error-BmL6QipT.mjs} +7 -3
- package/dist/{index-C-jx21qs.d.mts → index-yvc6E_17.d.mts} +157 -30
- package/dist/index.d.mts +11 -11
- package/dist/index.mjs +24 -22
- package/dist/{loader-qKmo0wAY.mjs → loader-sMG4TZ-u.mjs} +9 -3
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +1 -1
- package/dist/media/local-runtime.d.mts +7 -7
- package/dist/page/index.d.mts +10 -2
- package/dist/page/index.mjs +22 -1
- package/dist/patterns-CrCYkMBb.mjs +92 -0
- package/dist/{placeholder-bOx1xCTY.d.mts → placeholder--wOi4TbO.d.mts} +1 -1
- package/dist/{placeholder-B3knXwNc.mjs → placeholder-Cp8g5Emj.mjs} +1 -1
- package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
- package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
- package/dist/{query-BiaPl_g2.mjs → query-kDmwCsHh.mjs} +118 -50
- package/dist/{redirect-JPqLAbxa.mjs → redirect-DnEWAkVg.mjs} +43 -99
- package/dist/{registry-DSd1GWB8.mjs → registry-C0zjeB9P.mjs} +191 -123
- package/dist/request-cache-Dk5qPSOx.mjs +66 -0
- package/dist/request-context.d.mts +4 -16
- package/dist/{runner-B5l1JfOj.d.mts → runner-CFI6B6J2.d.mts} +1 -1
- package/dist/{runner-BGUGywgG.mjs → runner-DWZm2KQm.mjs} +589 -137
- package/dist/runtime.d.mts +6 -6
- package/dist/runtime.mjs +2 -2
- package/dist/{search-BNruJHDL.mjs → search-ByRGV2pq.mjs} +570 -424
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +11 -10
- package/dist/seo/index.d.mts +1 -1
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +11 -3
- package/dist/storage/s3.mjs +78 -15
- package/dist/taxonomies-1s5PaS_8.mjs +266 -0
- package/dist/transaction-Cn2rjY78.mjs +27 -0
- package/dist/{types-BgQeVaPj.d.mts → types-BuMDPy5C.d.mts} +52 -3
- package/dist/{types-DuNbGKjF.mjs → types-COeOq9nK.mjs} +6 -1
- package/dist/{types-ju-_ORz7.d.mts → types-CWbdtiux.d.mts} +13 -5
- package/dist/{types-D38djUXv.d.mts → types-Cj0KMIZV.d.mts} +16 -3
- package/dist/{types-DkvMXalq.d.mts → types-DOrVigru.d.mts} +159 -0
- package/dist/{validate-CXnRKfJK.mjs → validate-BZ5wnLLp.mjs} +2 -1
- package/dist/{validate-DVKJJ-M_.d.mts → validate-IPf8n4Fj.d.mts} +4 -51
- package/dist/{validate-CqRJb_xU.mjs → validate-VPnKoIzW.mjs} +10 -10
- package/dist/version-BKXPsfmJ.mjs +6 -0
- package/package.json +53 -39
- package/src/astro/routes/PluginRegistry.tsx +21 -0
- package/src/astro/routes/admin.astro +99 -0
- package/src/astro/routes/api/admin/allowed-domains/[domain].ts +112 -0
- package/src/astro/routes/api/admin/allowed-domains/index.ts +108 -0
- package/src/astro/routes/api/admin/api-tokens/[id].ts +44 -0
- package/src/astro/routes/api/admin/api-tokens/index.ts +90 -0
- package/src/astro/routes/api/admin/briefing.ts +76 -0
- package/src/astro/routes/api/admin/bylines/[id]/index.ts +90 -0
- package/src/astro/routes/api/admin/bylines/index.ts +74 -0
- package/src/astro/routes/api/admin/comments/[id]/status.ts +120 -0
- package/src/astro/routes/api/admin/comments/[id].ts +64 -0
- package/src/astro/routes/api/admin/comments/bulk.ts +42 -0
- package/src/astro/routes/api/admin/comments/counts.ts +30 -0
- package/src/astro/routes/api/admin/comments/index.ts +46 -0
- package/src/astro/routes/api/admin/context/[id]/history.ts +35 -0
- package/src/astro/routes/api/admin/context/[id]/index.ts +35 -0
- package/src/astro/routes/api/admin/context/[id]/review.ts +57 -0
- package/src/astro/routes/api/admin/context/[id]/supersede.ts +58 -0
- package/src/astro/routes/api/admin/context/diff.ts +35 -0
- package/src/astro/routes/api/admin/context/index.ts +69 -0
- package/src/astro/routes/api/admin/context/stale.ts +35 -0
- package/src/astro/routes/api/admin/hitl-requests/[id]/index.ts +38 -0
- package/src/astro/routes/api/admin/hitl-requests/[id]/resolve.ts +54 -0
- package/src/astro/routes/api/admin/hitl-requests/index.ts +38 -0
- package/src/astro/routes/api/admin/hooks/exclusive/[hookName].ts +132 -0
- package/src/astro/routes/api/admin/hooks/exclusive/index.ts +51 -0
- package/src/astro/routes/api/admin/oauth-clients/[id].ts +137 -0
- package/src/astro/routes/api/admin/oauth-clients/index.ts +95 -0
- package/src/astro/routes/api/admin/plugins/[id]/disable.ts +91 -0
- package/src/astro/routes/api/admin/plugins/[id]/enable.ts +91 -0
- package/src/astro/routes/api/admin/plugins/[id]/index.ts +38 -0
- package/src/astro/routes/api/admin/plugins/[id]/uninstall.ts +98 -0
- package/src/astro/routes/api/admin/plugins/[id]/update.ts +154 -0
- package/src/astro/routes/api/admin/plugins/index.ts +32 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/icon.ts +62 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/index.ts +33 -0
- package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +135 -0
- package/src/astro/routes/api/admin/plugins/marketplace/index.ts +38 -0
- package/src/astro/routes/api/admin/plugins/updates.ts +28 -0
- package/src/astro/routes/api/admin/review-requests/[id]/index.ts +35 -0
- package/src/astro/routes/api/admin/review-requests/[id]/resolve.ts +52 -0
- package/src/astro/routes/api/admin/review-requests/index.ts +35 -0
- package/src/astro/routes/api/admin/themes/marketplace/[id]/index.ts +33 -0
- package/src/astro/routes/api/admin/themes/marketplace/[id]/thumbnail.ts +62 -0
- package/src/astro/routes/api/admin/themes/marketplace/index.ts +45 -0
- package/src/astro/routes/api/admin/users/[id]/disable.ts +72 -0
- package/src/astro/routes/api/admin/users/[id]/enable.ts +48 -0
- package/src/astro/routes/api/admin/users/[id]/index.ts +166 -0
- package/src/astro/routes/api/admin/users/[id]/send-recovery.ts +72 -0
- package/src/astro/routes/api/admin/users/index.ts +66 -0
- package/src/astro/routes/api/auth/dev-bypass.ts +139 -0
- package/src/astro/routes/api/auth/invite/accept.ts +52 -0
- package/src/astro/routes/api/auth/invite/complete.ts +86 -0
- package/src/astro/routes/api/auth/invite/index.ts +99 -0
- package/src/astro/routes/api/auth/invite/register-options.ts +73 -0
- package/src/astro/routes/api/auth/logout.ts +40 -0
- package/src/astro/routes/api/auth/magic-link/send.ts +90 -0
- package/src/astro/routes/api/auth/magic-link/verify.ts +71 -0
- package/src/astro/routes/api/auth/me.ts +60 -0
- package/src/astro/routes/api/auth/oauth/[provider]/callback.ts +221 -0
- package/src/astro/routes/api/auth/oauth/[provider].ts +120 -0
- package/src/astro/routes/api/auth/passkey/[id].ts +124 -0
- package/src/astro/routes/api/auth/passkey/index.ts +54 -0
- package/src/astro/routes/api/auth/passkey/options.ts +85 -0
- package/src/astro/routes/api/auth/passkey/register/options.ts +88 -0
- package/src/astro/routes/api/auth/passkey/register/verify.ts +119 -0
- package/src/astro/routes/api/auth/passkey/verify.ts +72 -0
- package/src/astro/routes/api/auth/signup/complete.ts +87 -0
- package/src/astro/routes/api/auth/signup/request.ts +89 -0
- package/src/astro/routes/api/auth/signup/verify.ts +53 -0
- package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +310 -0
- package/src/astro/routes/api/content/[collection]/[id]/compare.ts +28 -0
- package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +68 -0
- package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +77 -0
- package/src/astro/routes/api/content/[collection]/[id]/permanent.ts +42 -0
- package/src/astro/routes/api/content/[collection]/[id]/preview-url.ts +107 -0
- package/src/astro/routes/api/content/[collection]/[id]/publish.ts +100 -0
- package/src/astro/routes/api/content/[collection]/[id]/restore.ts +64 -0
- package/src/astro/routes/api/content/[collection]/[id]/revisions.ts +31 -0
- package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +129 -0
- package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +143 -0
- package/src/astro/routes/api/content/[collection]/[id]/translations.ts +50 -0
- package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +69 -0
- package/src/astro/routes/api/content/[collection]/[id].ts +173 -0
- package/src/astro/routes/api/content/[collection]/index.ts +103 -0
- package/src/astro/routes/api/content/[collection]/trash.ts +33 -0
- package/src/astro/routes/api/dashboard.ts +32 -0
- package/src/astro/routes/api/dev/emails.ts +36 -0
- package/src/astro/routes/api/health.ts +54 -0
- package/src/astro/routes/api/import/probe.ts +47 -0
- package/src/astro/routes/api/import/wordpress/analyze.ts +523 -0
- package/src/astro/routes/api/import/wordpress/execute.ts +330 -0
- package/src/astro/routes/api/import/wordpress/media.ts +338 -0
- package/src/astro/routes/api/import/wordpress/prepare.ts +212 -0
- package/src/astro/routes/api/import/wordpress/rewrite-urls.ts +425 -0
- package/src/astro/routes/api/import/wordpress-plugin/analyze.ts +111 -0
- package/src/astro/routes/api/import/wordpress-plugin/callback.ts +58 -0
- package/src/astro/routes/api/import/wordpress-plugin/execute.ts +399 -0
- package/src/astro/routes/api/manifest.ts +75 -0
- package/src/astro/routes/api/mcp.ts +125 -0
- package/src/astro/routes/api/media/[id]/confirm.ts +93 -0
- package/src/astro/routes/api/media/[id].ts +145 -0
- package/src/astro/routes/api/media/file/[...key].ts +79 -0
- package/src/astro/routes/api/media/providers/[providerId]/[itemId].ts +91 -0
- package/src/astro/routes/api/media/providers/[providerId]/index.ts +111 -0
- package/src/astro/routes/api/media/providers/index.ts +30 -0
- package/src/astro/routes/api/media/upload-url.ts +146 -0
- package/src/astro/routes/api/media.ts +204 -0
- package/src/astro/routes/api/menus/[name]/items.ts +206 -0
- package/src/astro/routes/api/menus/[name]/reorder.ts +79 -0
- package/src/astro/routes/api/menus/[name].ts +145 -0
- package/src/astro/routes/api/menus/index.ts +91 -0
- package/src/astro/routes/api/oauth/authorize.ts +430 -0
- package/src/astro/routes/api/oauth/device/authorize.ts +45 -0
- package/src/astro/routes/api/oauth/device/code.ts +56 -0
- package/src/astro/routes/api/oauth/device/token.ts +70 -0
- package/src/astro/routes/api/oauth/register.ts +182 -0
- package/src/astro/routes/api/oauth/token/refresh.ts +38 -0
- package/src/astro/routes/api/oauth/token/revoke.ts +38 -0
- package/src/astro/routes/api/oauth/token.ts +195 -0
- package/src/astro/routes/api/openapi.json.ts +33 -0
- package/src/astro/routes/api/plugins/[pluginId]/[...path].ts +109 -0
- package/src/astro/routes/api/redirects/404s/index.ts +72 -0
- package/src/astro/routes/api/redirects/404s/summary.ts +33 -0
- package/src/astro/routes/api/redirects/[id].ts +183 -0
- package/src/astro/routes/api/redirects/index.ts +100 -0
- package/src/astro/routes/api/revisions/[revisionId]/index.ts +29 -0
- package/src/astro/routes/api/revisions/[revisionId]/restore.ts +62 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +104 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +67 -0
- package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +45 -0
- package/src/astro/routes/api/schema/collections/[slug]/index.ts +107 -0
- package/src/astro/routes/api/schema/collections/index.ts +61 -0
- package/src/astro/routes/api/schema/index.ts +109 -0
- package/src/astro/routes/api/schema/orphans/[slug].ts +36 -0
- package/src/astro/routes/api/schema/orphans/index.ts +26 -0
- package/src/astro/routes/api/search/enable.ts +64 -0
- package/src/astro/routes/api/search/index.ts +52 -0
- package/src/astro/routes/api/search/rebuild.ts +72 -0
- package/src/astro/routes/api/search/stats.ts +35 -0
- package/src/astro/routes/api/search/suggest.ts +50 -0
- package/src/astro/routes/api/sections/[slug].ts +203 -0
- package/src/astro/routes/api/sections/index.ts +107 -0
- package/src/astro/routes/api/settings/email.ts +150 -0
- package/src/astro/routes/api/settings.ts +116 -0
- package/src/astro/routes/api/setup/admin-verify.ts +122 -0
- package/src/astro/routes/api/setup/admin.ts +104 -0
- package/src/astro/routes/api/setup/dev-bypass.ts +200 -0
- package/src/astro/routes/api/setup/dev-reset.ts +40 -0
- package/src/astro/routes/api/setup/index.ts +128 -0
- package/src/astro/routes/api/setup/status.ts +122 -0
- package/src/astro/routes/api/snapshot.ts +76 -0
- package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +232 -0
- package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +131 -0
- package/src/astro/routes/api/taxonomies/index.ts +114 -0
- package/src/astro/routes/api/themes/preview.ts +78 -0
- package/src/astro/routes/api/typegen.ts +114 -0
- package/src/astro/routes/api/well-known/auth.ts +71 -0
- package/src/astro/routes/api/well-known/oauth-authorization-server.ts +48 -0
- package/src/astro/routes/api/well-known/oauth-protected-resource.ts +39 -0
- package/src/astro/routes/api/widget-areas/[name]/reorder.ts +114 -0
- package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +213 -0
- package/src/astro/routes/api/widget-areas/[name]/widgets.ts +126 -0
- package/src/astro/routes/api/widget-areas/[name].ts +135 -0
- package/src/astro/routes/api/widget-areas/index.ts +149 -0
- package/src/astro/routes/api/widget-components.ts +22 -0
- package/src/astro/routes/robots.txt.ts +81 -0
- package/src/astro/routes/sitemap-[collection].xml.ts +104 -0
- package/src/astro/routes/sitemap.xml.ts +92 -0
- package/src/components/Break.astro +45 -0
- package/src/components/Button.astro +71 -0
- package/src/components/Buttons.astro +49 -0
- package/src/components/Code.astro +59 -0
- package/src/components/Columns.astro +59 -0
- package/src/components/CommentForm.astro +315 -0
- package/src/components/Comments.astro +232 -0
- package/src/components/Cover.astro +128 -0
- package/src/components/DinewayBodyEnd.astro +32 -0
- package/src/components/DinewayBodyStart.astro +32 -0
- package/src/components/DinewayHead.astro +61 -0
- package/src/components/DinewayImage.astro +178 -0
- package/src/components/DinewayMedia.astro +167 -0
- package/src/components/Embed.astro +128 -0
- package/src/components/File.astro +122 -0
- package/src/components/Gallery.astro +93 -0
- package/src/components/HtmlBlock.astro +33 -0
- package/src/components/Image.astro +178 -0
- package/src/components/InlineEditor.astro +27 -0
- package/src/components/InlinePortableTextEditor.tsx +1937 -0
- package/src/components/LiveSearch.astro +614 -0
- package/src/components/PortableText.astro +51 -0
- package/src/components/Pullquote.astro +51 -0
- package/src/components/Table.astro +135 -0
- package/src/components/WidgetArea.astro +22 -0
- package/src/components/WidgetRenderer.astro +72 -0
- package/src/components/index.ts +106 -0
- package/src/components/marks/Link.astro +31 -0
- package/src/components/marks/StrikeThrough.astro +7 -0
- package/src/components/marks/Subscript.astro +7 -0
- package/src/components/marks/Superscript.astro +7 -0
- package/src/components/marks/Underline.astro +7 -0
- package/src/components/marks.ts +19 -0
- package/src/components/widgets/Archives.astro +65 -0
- package/src/components/widgets/Categories.astro +35 -0
- package/src/components/widgets/RecentPosts.astro +51 -0
- package/src/components/widgets/Search.astro +18 -0
- package/src/components/widgets/Tags.astro +38 -0
- package/src/ui.ts +75 -0
- package/LICENSE +0 -9
- /package/dist/{adapters-BlzWJG82.d.mts → adapters-C2ypTrZZ.d.mts} +0 -0
- /package/dist/{config-Cq8H0SfX.mjs → config-BXwuX8Bx.mjs} +0 -0
- /package/dist/{load-C6FCD1FU.mjs → load-Coc9HpHH.mjs} +0 -0
- /package/dist/{manifest-schema-CTSEyIJ3.mjs → manifest-schema-D1MSVnoI.mjs} +0 -0
- /package/dist/{mode-BlyYtIFO.mjs → mode-47goXBBK.mjs} +0 -0
- /package/dist/{tokens-4vgYuXsZ.mjs → tokens-CJz9ubV6.mjs} +0 -0
- /package/dist/{transport-C5FYnid7.mjs → transport-DB5eDN4x.mjs} +0 -0
- /package/dist/{transport-gIL-e43D.d.mts → transport-Wge_IzKl.d.mts} +0 -0
- /package/dist/{types-CLLdsG3g.d.mts → types-BzcUjoqg.d.mts} +0 -0
- /package/dist/{types-DShnjzb6.mjs → types-griIBQOQ.mjs} +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Dineway Media component
|
|
4
|
+
*
|
|
5
|
+
* Unified component for rendering media from any provider (local, remote image services, etc.)
|
|
6
|
+
* Calls the provider's getEmbed() method at render time for proper URL generation.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```astro
|
|
10
|
+
* ---
|
|
11
|
+
* import { Media } from "dineway/ui";
|
|
12
|
+
* ---
|
|
13
|
+
* <Media value={post.data.featured_image} />
|
|
14
|
+
*
|
|
15
|
+
* <!-- With size hints for optimization -->
|
|
16
|
+
* <Media value={post.data.hero} width={1200} height={630} />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import type { MediaValue } from "../fields/types.js";
|
|
20
|
+
import type { EmbedResult, EmbedOptions } from "../media/types.js";
|
|
21
|
+
import type { HTMLAttributes } from "astro/types";
|
|
22
|
+
import { getMediaProvider } from "../media/provider-loader.js";
|
|
23
|
+
|
|
24
|
+
interface Props extends Omit<HTMLAttributes<"img" | "video" | "audio">, "src" | "width" | "height"> {
|
|
25
|
+
/** Media value from content field */
|
|
26
|
+
value: MediaValue | string | undefined | null;
|
|
27
|
+
/** Override alt text */
|
|
28
|
+
alt?: string;
|
|
29
|
+
/** Desired width (for optimization) */
|
|
30
|
+
width?: number;
|
|
31
|
+
/** Desired height (for optimization) */
|
|
32
|
+
height?: number;
|
|
33
|
+
/** Image format preference */
|
|
34
|
+
format?: "webp" | "avif" | "jpeg" | "png" | "auto";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { value, alt, width, height, format, ...attrs } = Astro.props;
|
|
38
|
+
|
|
39
|
+
// Normalize string URLs to MediaValue
|
|
40
|
+
function normalizeValue(val: MediaValue | string | undefined | null): MediaValue | null {
|
|
41
|
+
if (!val) return null;
|
|
42
|
+
if (typeof val === "string") {
|
|
43
|
+
return { id: "", src: val, provider: "local" };
|
|
44
|
+
}
|
|
45
|
+
return val;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const media = normalizeValue(value);
|
|
49
|
+
let embed: EmbedResult | null = null;
|
|
50
|
+
|
|
51
|
+
if (media) {
|
|
52
|
+
const providerId = media.provider ?? "local";
|
|
53
|
+
|
|
54
|
+
// Get provider using lazy-loaded getMediaProvider (loads from virtual module)
|
|
55
|
+
const provider = await getMediaProvider(providerId);
|
|
56
|
+
|
|
57
|
+
if (provider) {
|
|
58
|
+
// Call provider's getEmbed to get render instructions
|
|
59
|
+
const embedOptions: EmbedOptions = { width, height, format };
|
|
60
|
+
try {
|
|
61
|
+
const result = provider.getEmbed(media, embedOptions);
|
|
62
|
+
// Handle both sync and async getEmbed
|
|
63
|
+
embed = result instanceof Promise ? await result : result;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn(`Failed to get embed for media ${media.id}:`, error);
|
|
66
|
+
}
|
|
67
|
+
} else if (media.src) {
|
|
68
|
+
// Fallback for direct URLs or missing provider
|
|
69
|
+
embed = {
|
|
70
|
+
type: "image",
|
|
71
|
+
src: media.src,
|
|
72
|
+
width: media.width,
|
|
73
|
+
height: media.height,
|
|
74
|
+
alt: media.alt,
|
|
75
|
+
};
|
|
76
|
+
} else if (providerId === "local") {
|
|
77
|
+
// Fallback for local provider without runtime
|
|
78
|
+
const storageKey = (media.meta?.storageKey as string) || media.id;
|
|
79
|
+
if (storageKey) {
|
|
80
|
+
const mimeType = media.mimeType || "";
|
|
81
|
+
if (mimeType.startsWith("video/")) {
|
|
82
|
+
embed = {
|
|
83
|
+
type: "video",
|
|
84
|
+
src: `/_dineway/api/media/file/${storageKey}`,
|
|
85
|
+
width: media.width,
|
|
86
|
+
height: media.height,
|
|
87
|
+
controls: true,
|
|
88
|
+
preload: "metadata",
|
|
89
|
+
};
|
|
90
|
+
} else if (mimeType.startsWith("audio/")) {
|
|
91
|
+
embed = {
|
|
92
|
+
type: "audio",
|
|
93
|
+
src: `/_dineway/api/media/file/${storageKey}`,
|
|
94
|
+
controls: true,
|
|
95
|
+
preload: "metadata",
|
|
96
|
+
};
|
|
97
|
+
} else {
|
|
98
|
+
embed = {
|
|
99
|
+
type: "image",
|
|
100
|
+
src: `/_dineway/api/media/file/${storageKey}`,
|
|
101
|
+
width: media.width,
|
|
102
|
+
height: media.height,
|
|
103
|
+
alt: media.alt,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Compute final values
|
|
111
|
+
const finalAlt = alt ?? (embed?.type === "image" ? embed.alt : undefined) ?? media?.alt ?? "";
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
{embed?.type === "image" && (
|
|
115
|
+
<img
|
|
116
|
+
src={embed.src}
|
|
117
|
+
srcset={embed.srcset}
|
|
118
|
+
sizes={embed.sizes}
|
|
119
|
+
width={embed.width}
|
|
120
|
+
height={embed.height}
|
|
121
|
+
alt={finalAlt}
|
|
122
|
+
loading="lazy"
|
|
123
|
+
decoding="async"
|
|
124
|
+
{...attrs}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
|
|
128
|
+
{embed?.type === "video" && (
|
|
129
|
+
<video
|
|
130
|
+
width={embed.width}
|
|
131
|
+
height={embed.height}
|
|
132
|
+
controls={embed.controls ?? true}
|
|
133
|
+
autoplay={embed.autoplay}
|
|
134
|
+
muted={embed.muted}
|
|
135
|
+
loop={embed.loop}
|
|
136
|
+
playsinline={embed.playsinline}
|
|
137
|
+
preload={embed.preload ?? "metadata"}
|
|
138
|
+
crossorigin={embed.crossorigin}
|
|
139
|
+
poster={embed.poster}
|
|
140
|
+
{...attrs}
|
|
141
|
+
>
|
|
142
|
+
{embed.src && <source src={embed.src} />}
|
|
143
|
+
{embed.sources?.map((s) => <source src={s.src} type={s.type} />)}
|
|
144
|
+
</video>
|
|
145
|
+
)}
|
|
146
|
+
|
|
147
|
+
{embed?.type === "audio" && (
|
|
148
|
+
<audio
|
|
149
|
+
controls={embed.controls ?? true}
|
|
150
|
+
autoplay={embed.autoplay}
|
|
151
|
+
muted={embed.muted}
|
|
152
|
+
loop={embed.loop}
|
|
153
|
+
preload={embed.preload ?? "metadata"}
|
|
154
|
+
{...attrs}
|
|
155
|
+
>
|
|
156
|
+
{embed.src && <source src={embed.src} />}
|
|
157
|
+
{embed.sources?.map((s) => <source src={s.src} type={s.type} />)}
|
|
158
|
+
</audio>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{embed?.type === "component" && (
|
|
162
|
+
<!-- Custom component embeds (Mux player, etc.) require dynamic import -->
|
|
163
|
+
<!-- For now, show a placeholder - full implementation TBD -->
|
|
164
|
+
<div class="dineway-media-component" data-package={embed.package} data-export={embed.export}>
|
|
165
|
+
<p>Custom media component: {embed.package}</p>
|
|
166
|
+
</div>
|
|
167
|
+
)}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { sanitizeHref } from "../utils/url.js";
|
|
3
|
+
import { sanitizeContent } from "../utils/sanitize.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Portable Text Embed block component
|
|
7
|
+
*
|
|
8
|
+
* Renders embeds from YouTube, Vimeo, Twitter, etc.
|
|
9
|
+
*/
|
|
10
|
+
export interface Props {
|
|
11
|
+
node: {
|
|
12
|
+
_type: "embed";
|
|
13
|
+
_key: string;
|
|
14
|
+
url: string;
|
|
15
|
+
provider?: string;
|
|
16
|
+
html?: string;
|
|
17
|
+
caption?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const { node } = Astro.props;
|
|
22
|
+
|
|
23
|
+
if (!node?.url) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { url: rawUrl, provider, html, caption } = node;
|
|
28
|
+
const url = sanitizeHref(rawUrl);
|
|
29
|
+
|
|
30
|
+
const YOUTUBE_ID_PATTERN = /(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
|
|
31
|
+
const VIMEO_ID_PATTERN = /vimeo\.com\/(\d+)/;
|
|
32
|
+
|
|
33
|
+
// Extract video ID for common providers
|
|
34
|
+
function getYouTubeId(input: string): string | null {
|
|
35
|
+
const match = input.match(YOUTUBE_ID_PATTERN);
|
|
36
|
+
return match?.[1] || null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getVimeoId(input: string): string | null {
|
|
40
|
+
const match = input.match(VIMEO_ID_PATTERN);
|
|
41
|
+
return match?.[1] || null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const youtubeId = getYouTubeId(url);
|
|
45
|
+
const vimeoId = getVimeoId(url);
|
|
46
|
+
|
|
47
|
+
// Check if this is a self-hosted video or audio
|
|
48
|
+
const isSelfHostedVideo = provider === "video";
|
|
49
|
+
const isSelfHostedAudio = provider === "audio";
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<figure class="dineway-embed">
|
|
53
|
+
{
|
|
54
|
+
isSelfHostedVideo ? (
|
|
55
|
+
<div class="dineway-embed-video">
|
|
56
|
+
<video controls preload="metadata">
|
|
57
|
+
<source src={url} />
|
|
58
|
+
Your browser does not support the video element.
|
|
59
|
+
</video>
|
|
60
|
+
</div>
|
|
61
|
+
) : isSelfHostedAudio ? (
|
|
62
|
+
<div class="dineway-embed-audio">
|
|
63
|
+
<audio controls preload="metadata">
|
|
64
|
+
<source src={url} />
|
|
65
|
+
Your browser does not support the audio element.
|
|
66
|
+
</audio>
|
|
67
|
+
</div>
|
|
68
|
+
) : youtubeId ? (
|
|
69
|
+
<div class="dineway-embed-video">
|
|
70
|
+
<iframe
|
|
71
|
+
src={`https://www.youtube.com/embed/${youtubeId}`}
|
|
72
|
+
title="YouTube video"
|
|
73
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
74
|
+
allowfullscreen
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
) : vimeoId ? (
|
|
78
|
+
<div class="dineway-embed-video">
|
|
79
|
+
<iframe
|
|
80
|
+
src={`https://player.vimeo.com/video/${vimeoId}`}
|
|
81
|
+
title="Vimeo video"
|
|
82
|
+
allow="autoplay; fullscreen; picture-in-picture"
|
|
83
|
+
allowfullscreen
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
) : html ? (
|
|
87
|
+
<div class="dineway-embed-html" set:html={sanitizeContent(html)} />
|
|
88
|
+
) : (
|
|
89
|
+
<a href={url} target="_blank" rel="noopener noreferrer">
|
|
90
|
+
{url}
|
|
91
|
+
</a>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
95
|
+
</figure>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
.dineway-embed {
|
|
99
|
+
margin: 1.5rem 0;
|
|
100
|
+
}
|
|
101
|
+
.dineway-embed-video {
|
|
102
|
+
position: relative;
|
|
103
|
+
padding-bottom: 56.25%; /* 16:9 */
|
|
104
|
+
height: 0;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
}
|
|
107
|
+
.dineway-embed-video iframe,
|
|
108
|
+
.dineway-embed-video video {
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 0;
|
|
111
|
+
left: 0;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
border: 0;
|
|
115
|
+
}
|
|
116
|
+
.dineway-embed-audio {
|
|
117
|
+
width: 100%;
|
|
118
|
+
}
|
|
119
|
+
.dineway-embed-audio audio {
|
|
120
|
+
width: 100%;
|
|
121
|
+
}
|
|
122
|
+
.dineway-embed figcaption {
|
|
123
|
+
font-size: 0.875rem;
|
|
124
|
+
color: #666;
|
|
125
|
+
margin-top: 0.5rem;
|
|
126
|
+
text-align: center;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { sanitizeHref } from "../utils/url.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Portable Text File block component
|
|
6
|
+
*
|
|
7
|
+
* Renders a downloadable file link from WordPress imports.
|
|
8
|
+
*/
|
|
9
|
+
export interface Props {
|
|
10
|
+
node: {
|
|
11
|
+
_type: "file";
|
|
12
|
+
_key: string;
|
|
13
|
+
url: string;
|
|
14
|
+
filename?: string;
|
|
15
|
+
showDownloadButton?: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { node } = Astro.props;
|
|
20
|
+
const { url: rawUrl, filename, showDownloadButton = true } = node ?? {};
|
|
21
|
+
const url = sanitizeHref(rawUrl);
|
|
22
|
+
|
|
23
|
+
// Extract filename from URL if not provided
|
|
24
|
+
const displayName = filename || url?.split("/").pop()?.split("?")[0] || "Download";
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<div class="dineway-file">
|
|
28
|
+
<a href={url} class="dineway-file__link" download={filename}>
|
|
29
|
+
<svg
|
|
30
|
+
class="dineway-file__icon"
|
|
31
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
32
|
+
viewBox="0 0 24 24"
|
|
33
|
+
fill="none"
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
stroke-width="2"
|
|
36
|
+
stroke-linecap="round"
|
|
37
|
+
stroke-linejoin="round"
|
|
38
|
+
>
|
|
39
|
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
40
|
+
<polyline points="14 2 14 8 20 8"></polyline>
|
|
41
|
+
</svg>
|
|
42
|
+
<span class="dineway-file__name">{displayName}</span>
|
|
43
|
+
</a>
|
|
44
|
+
{
|
|
45
|
+
showDownloadButton && (
|
|
46
|
+
<a href={url} class="dineway-file__download" download={filename} aria-label="Download file">
|
|
47
|
+
<svg
|
|
48
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
49
|
+
viewBox="0 0 24 24"
|
|
50
|
+
fill="none"
|
|
51
|
+
stroke="currentColor"
|
|
52
|
+
stroke-width="2"
|
|
53
|
+
stroke-linecap="round"
|
|
54
|
+
stroke-linejoin="round"
|
|
55
|
+
>
|
|
56
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
57
|
+
<polyline points="7 10 12 15 17 10" />
|
|
58
|
+
<line x1="12" y1="15" x2="12" y2="3" />
|
|
59
|
+
</svg>
|
|
60
|
+
</a>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<style>
|
|
66
|
+
.dineway-file {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 0.75rem;
|
|
70
|
+
padding: 1rem;
|
|
71
|
+
margin: 1rem 0;
|
|
72
|
+
background-color: var(--dineway-file-bg, #f5f5f5);
|
|
73
|
+
border-radius: 4px;
|
|
74
|
+
border: 1px solid var(--dineway-file-border, #e0e0e0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.dineway-file__link {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: 0.5rem;
|
|
81
|
+
flex: 1;
|
|
82
|
+
text-decoration: none;
|
|
83
|
+
color: var(--dineway-file-color, #333);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.dineway-file__link:hover {
|
|
87
|
+
text-decoration: underline;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.dineway-file__icon {
|
|
91
|
+
width: 1.5rem;
|
|
92
|
+
height: 1.5rem;
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
color: var(--dineway-file-icon-color, #666);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.dineway-file__name {
|
|
98
|
+
font-weight: 500;
|
|
99
|
+
word-break: break-all;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.dineway-file__download {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
width: 2.5rem;
|
|
107
|
+
height: 2.5rem;
|
|
108
|
+
background-color: var(--dineway-button-bg, #0073aa);
|
|
109
|
+
color: var(--dineway-button-color, #fff);
|
|
110
|
+
border-radius: 4px;
|
|
111
|
+
transition: background-color 0.2s;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dineway-file__download:hover {
|
|
115
|
+
background-color: var(--dineway-button-bg-hover, #005177);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.dineway-file__download svg {
|
|
119
|
+
width: 1.25rem;
|
|
120
|
+
height: 1.25rem;
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Portable Text Gallery block component
|
|
4
|
+
*
|
|
5
|
+
* Renders image galleries from WordPress imports.
|
|
6
|
+
* Uses Astro's Image component for optimization when dimensions are available.
|
|
7
|
+
*/
|
|
8
|
+
import { Image as AstroImage } from "astro:assets";
|
|
9
|
+
|
|
10
|
+
export interface Props {
|
|
11
|
+
node: {
|
|
12
|
+
_type: "gallery";
|
|
13
|
+
_key: string;
|
|
14
|
+
images: Array<{
|
|
15
|
+
_type: "image";
|
|
16
|
+
_key: string;
|
|
17
|
+
asset: {
|
|
18
|
+
_ref: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
};
|
|
21
|
+
alt?: string;
|
|
22
|
+
caption?: string;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
}>;
|
|
26
|
+
columns?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { node } = Astro.props;
|
|
31
|
+
const images = node?.images ?? [];
|
|
32
|
+
const columns = node?.columns ?? 3;
|
|
33
|
+
|
|
34
|
+
if (!images.length) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
<div class="dineway-gallery" style={`--columns: ${columns}`}>
|
|
40
|
+
{
|
|
41
|
+
images.map((image) => {
|
|
42
|
+
const src =
|
|
43
|
+
image.asset.url ||
|
|
44
|
+
`/_dineway/api/media/file/${image.asset._ref}`;
|
|
45
|
+
const hasSize = image.width && image.height;
|
|
46
|
+
return (
|
|
47
|
+
<figure class="dineway-gallery-item">
|
|
48
|
+
{hasSize ? (
|
|
49
|
+
<AstroImage
|
|
50
|
+
src={src}
|
|
51
|
+
alt={image.alt || ""}
|
|
52
|
+
width={image.width!}
|
|
53
|
+
height={image.height!}
|
|
54
|
+
layout="constrained"
|
|
55
|
+
/>
|
|
56
|
+
) : (
|
|
57
|
+
<img src={src} alt={image.alt || ""} loading="lazy" decoding="async" />
|
|
58
|
+
)}
|
|
59
|
+
{image.caption && <figcaption>{image.caption}</figcaption>}
|
|
60
|
+
</figure>
|
|
61
|
+
);
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<style>
|
|
67
|
+
.dineway-gallery {
|
|
68
|
+
display: grid;
|
|
69
|
+
grid-template-columns: repeat(var(--columns, 3), 1fr);
|
|
70
|
+
gap: 1rem;
|
|
71
|
+
margin: 1.5rem 0;
|
|
72
|
+
}
|
|
73
|
+
.dineway-gallery-item {
|
|
74
|
+
margin: 0;
|
|
75
|
+
}
|
|
76
|
+
.dineway-gallery-item img {
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: auto;
|
|
79
|
+
object-fit: cover;
|
|
80
|
+
aspect-ratio: 1;
|
|
81
|
+
}
|
|
82
|
+
.dineway-gallery-item figcaption {
|
|
83
|
+
font-size: 0.75rem;
|
|
84
|
+
color: #666;
|
|
85
|
+
margin-top: 0.25rem;
|
|
86
|
+
text-align: center;
|
|
87
|
+
}
|
|
88
|
+
@media (max-width: 640px) {
|
|
89
|
+
.dineway-gallery {
|
|
90
|
+
grid-template-columns: repeat(2, 1fr);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Portable Text HTML block component
|
|
4
|
+
*
|
|
5
|
+
* Renders raw HTML blocks that couldn't be converted to Portable Text.
|
|
6
|
+
* Sanitizes HTML to prevent XSS attacks.
|
|
7
|
+
*/
|
|
8
|
+
import { sanitizeContent } from "../utils/sanitize.js";
|
|
9
|
+
|
|
10
|
+
export interface Props {
|
|
11
|
+
node: {
|
|
12
|
+
_type: "htmlBlock";
|
|
13
|
+
_key: string;
|
|
14
|
+
html: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { node } = Astro.props;
|
|
19
|
+
|
|
20
|
+
if (!node?.html) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const sanitized = sanitizeContent(node.html);
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<div class="dineway-html-block" set:html={sanitized} />
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.dineway-html-block {
|
|
31
|
+
margin: 1.5rem 0;
|
|
32
|
+
}
|
|
33
|
+
</style>
|