-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
import type { Block, Props as $ } from "astro-portabletext/types"; | ||
import { usePortableText } from "astro-portabletext/utils"; | ||
export type Props = $<Block>; | ||
const props = Astro.props; | ||
const { getDefaultComponent } = usePortableText(props.node); | ||
const Default = getDefaultComponent(); | ||
--- | ||
|
||
<div data-block-index={props.index}> | ||
<Default {...props}> | ||
<slot /> | ||
</Default> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
import Layout from "../../layouts/Default.astro"; | ||
import { PortableText } from "astro-portabletext"; | ||
import Block from "../../components/BlockIndex.astro"; | ||
const blocks = [ | ||
{ | ||
_type: "block", | ||
style: "normal", | ||
children: [ | ||
{ | ||
_type: "span", | ||
text: "Paragraph 1", | ||
}, | ||
], | ||
}, | ||
{ | ||
_type: "block", | ||
style: "normal", | ||
children: [ | ||
{ | ||
_type: "span", | ||
text: "Paragraph 2", | ||
}, | ||
], | ||
}, | ||
{ | ||
_type: "block", | ||
style: "normal", | ||
children: [ | ||
{ | ||
_type: "span", | ||
text: "Paragraph 3", | ||
}, | ||
], | ||
}, | ||
]; | ||
--- | ||
|
||
<Layout> | ||
<PortableText value={blocks} components={{ block: Block }} /> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters