Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone experiencing issue with list being individually wrap in <ul>? #85

Open
psntr opened this issue Mar 1, 2024 · 3 comments
Open

Comments

@psntr
Copy link

psntr commented Mar 1, 2024

I'm having an issue where each lines of my list item are individually wrapped in a <ul> tag.

Not sure if there is a way around that? In case it helps to debug, I'm attaching what I have in Sanity:
ScreenShot 2024-03-01 at 19 31 21
ScreenShot 2024-03-01 at 19 32 17

@abteilung
Copy link

I actually was facing the same issue too. I was building a PageBuilder module in which I was iterating through all blocks to render them individually according to their type. Problem was that each listItem was returned as an individual block.

I got around it by just using the types property in PortableText.

@psntr
Copy link
Author

psntr commented May 16, 2024

Thanks for the insights, could you expand a bit more regarding the property in PortableText?

@abteilung
Copy link

abteilung commented May 17, 2024

Here is how I configure my PortableText component.

<script>
	import { PortableText } from '@portabletext/svelte';

	import ListsWrapper from '$lib/components/Lists.svelte';
	import ListItemWrapper from '$lib/components/ListItems.svelte';

	import Code from '$lib/components/Code.svelte'
	import Video from '$lib/components/Video.svelte'
	import ProductReference from '$lib/components/ProductReference.svelte'
</script>

<PortableText
	value={content}
	components={{
		types: {
			code: Code,
			video: Video,
			productReference: ProductReference,
		},
		list: {
			bullet: ListsWrapper,
			number: ListsWrapper
		},
		listItem: {
			normal: ListItemWrapper
		}
	}}
/>

Does this help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants