parse.ts
getAttribute
function
Get element attribute value.
function getAttribute(el: Element, name: string): string | undefined
Returns
string | undefined -
parseProps
function
Parse JSX-style props from attributes.
function parseProps(el: Element): Record<string, unknown>
Returns
Record<string, unknown> -
findComponentElement
function
Find the component element inside <Island>.
function findComponentElement(children: Element["children"]): Element | null
Returns
Element | null -
getComponentName
function
Get component name from child element.
function getComponentName(el: Element): string
Returns
string -
resetIslandCounter
function
Reset island counter (for testing).
export function resetIslandCounter(): void
Returns
void -
rehypeIslands
function
Rehype plugin to transform Island components.
function rehypeIslands(collectedIslands: IslandInfo[])
transformIslands
function
Transform Island components in HTML. Converts:
<Island load="visible">
<Counter initial={0} />
</Island>
To:
<div id="ox-island-0"
data-ox-island="Counter"
data-ox-load="visible"
data-ox-props='{"initial":0}'
class="ox-island">
<!-- fallback content -->
</div>
export async function transformIslands(html: string): Promise<ParseIslandsResult>
Returns
Promise<ParseIslandsResult> -
hasIslands
function
Check if HTML contains any Island components.
export function hasIslands(html: string): boolean
Returns
boolean -
extractIslandInfo
function
Extract island info without transforming HTML. Useful for analysis/bundling purposes.
export async function extractIslandInfo(html: string): Promise<IslandInfo[]>
Returns
Promise<IslandInfo[]> -
generateHydrationScript
function
Generate client-side hydration script. This is a minimal script that imports and initializes islands.
export function generateHydrationScript(components: string[]): string
Returns
string -