Skip to main content

value

value

value: Array<{ id: string; content: string; author?: { id: number; name: string; }; user?: number; date: Date; }>

this property initializes the comments widget with an array of comment objects. The default value is an empty array.

Usage

Initializing comments widget with data and embedded authors

<script>
import { Comments } from 'wx-svelte-comments';

const value = [
{
id: "1",
content: "Hello, world!",
author:{ id: 1, name: "John Doe" },
date: new Date(),
},
];
</script>

<Comments {value} />

Initializing comments widget with data and list of users

<script>
import { Comments } from 'wx-svelte-comments';

const value = [
{
id: "1",
content: "Hello, world!",
user: 1,
date: new Date(),
},
];

const users = [
{ id: 1, name: "John Doe" },
{ id: 2, name: "Jane Doe" },
];
</script>

<Comments {value} {users} />

Initializing empty comments widget

<script>
import { Comments } from 'wx-svelte-comments';
</script>

<Comments />

Initializing widget and loading comments

<script>
import { Comments } from 'wx-svelte-comments';

let value = [];

fetch('/api/comments')
.then(r => r.json())
.then(x => value = x);
</script>

{#await value}
<Comments {value} />
{/await}