Skip to content

Svelte Components

FrontMark can compile Svelte sources into a small client bundle and mount them from Markdown with a ::: svelte directive.

The directive passes configuration as component props. Hyphenated attributes are converted to camelCase, so supabase-url becomes supabaseUrl and button-text becomes buttonText.

CommandAction
make svelteCompile svelte-components/src/** into public/svelte/.
make svelte_watchRebuild the Svelte bundle when component sources change.
make svelte_testBuild the site and verify the Svelte docs page with Playwright.
make buildCompile Svelte, rebuild tags and build Astro.
make previewBuild everything and preview the production output.

The Docker image uses npm run build, so the Svelte bundle is compiled inside the build stage before Astro writes dist/.

The modal component can display Markdown/HTML passed inside the directive.

::: svelte { component=modal title="FrontMark modal" button-text="Open modal" width="min(34rem, 92vw)" }
<p><strong>Svelte receives this HTML from Markdown.</strong></p>
<p>The component can also load remote HTML with the `url` prop.</p>
:::
Loading modal...

Svelte receives this HTML from Markdown.

The component can also load remote HTML with the `url` prop.

:::

Use url when the modal must fetch content only when it opens.

::: svelte { component=modal title="Wikipedia: Markdown" button-text="Open Wikipedia article" url="https://en.wikipedia.org/api/rest_v1/page/html/Markdown" width="min(54rem, 94vw)" }
:::
Loading modal...

The example Supabase components do not hardcode the project URL or anon key. Pass them from Markdown:

supabase-url="https://supabase.newkube.ia86.cc"
supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw"

The map component uses local icon definitions from /icons/icons.json by default. The matching marker image is /icons/marker.png. Override icons-url and marker-url when a project ships its own icon set. FrontMark also bundles the matching custom IcoFont font so table and statistics icons render from <i class="icofont-..."> tags.

This result calls Supabase directly from the browser with the public anon key passed by Markdown. The department prop is set explicitly so the example works on localhost and on preview domains.

::: svelte { component=supabase-map supabase-url="https://supabase.newkube.ia86.cc" supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw" department="lot" height=380 }
:::
Loading supabase-map...
::: svelte {
component=supabase-map
supabase-url="https://supabase.newkube.ia86.cc"
supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw"
domain-suffix=".example.org"
department="lot"
icons-url="/icons/icons.json"
marker-url="/icons/marker.png"
detail-url-template="~detail?id={id}"
height="620px"
}
:::

Useful props:

PropDefaultPurpose
departmentDerived from domain-suffixDepartment name used in Supabase queries.
department-tabledepartementTable storing the map center and zoom.
department-center-orderlng-latOrder used by the departement.zoom field.
geojson-rpcget_geojson_by_departmentRPC returning GeoJSON features.
coordinates-orderlat-lngUse lng-lat for standard GeoJSON coordinates.
icons-url/icons/icons.jsonJSON file mapping POI types to Leaflet glyph icons.
marker-url/icons/marker.pngMarker bitmap used behind glyph icons.
detail-url-template~detail?id={id}Popup URL template.
::: svelte { component=supabase-table supabase-url="https://supabase.newkube.ia86.cc" supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw" department="lot" page-size=5 }
:::
Loading supabase-table...
::: svelte {
component=supabase-table
supabase-url="https://supabase.newkube.ia86.cc"
supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw"
domain-suffix=".example.org"
department="lot"
table-name="patrimoine"
page-size=25
}
:::

Useful props:

PropDefaultPurpose
table-namepatrimoineSupabase table to query.
select*, commune!inner(id, titre, departement!inner(nom))Supabase select expression.
status-columnstatutPublication status column.
published-valuepublieValue required for published rows.
department-filter-pathcommune.departement.nomNested filter path for the department.
::: svelte { component=supabase-stats supabase-url="https://supabase.newkube.ia86.cc" supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw" department="lot" link-base="#" }
:::
Loading supabase-stats...
::: svelte {
component=supabase-stats
supabase-url="https://supabase.newkube.ia86.cc"
supabase-anon-key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzQwMTc4ODAwLAogICJleHAiOiAxODk3OTQ1MjAwCn0.omZ615aeCi9LuWt5fforhMYeoaFEshFgCutMkOqY9xw"
domain-suffix=".example.org"
department="lot"
link-base="*trimulticritere"
}
:::

Useful props:

PropDefaultPurpose
stats-rpcstats_patrimoine_par_departementMain type/statistics RPC.
particularities-rpcstats_patrimoine_par_particulariteParticularities RPC.
walk-rpcstats_patrimoine_par_marcheApproach difficulty RPC.
access-rpcstats_patrimoine_par_accesAccess RPC.
time-rpcstats_patrimoine_par_timeDuration RPC.
link-base*trimulticritereBase URL used for generated drill-down links.
svelte-components/
├── vite.config.mjs
└── src/
├── index.js
├── frontmark-svelte.css
├── components/
│ ├── Modal.svelte
│ ├── SupabaseMap.svelte
│ ├── SupabaseTable.svelte
│ └── SupabaseStats.svelte
└── lib/
└── supabase.js