0.0.7 • Published 2 months ago

@hyvor/hyvor-talk-svelte v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Installation

npm install @hyvor/hyvor-talk-svelte

Usage

The library contains two components:

Comments

All props in the <Comments> component are the same as the base hyvor-talk-comments Web Component.

<script>
    import { Comments } from '@hyvor/hyvor-talk-svelte';
</script>

<Comments
    website-id={YOUR_WEBSITE_ID}
    page-id={UNIQUE_PAGE_ID}
/>

Use the on: directive to listen to events emitted by the component.

<Comments
    website-id={YOUR_WEBSITE_ID}
    page-id={UNIQUE_PAGE_ID}

    on:loaded={() => console.log('Comments loaded')}
    on:comment:published={() => console.log('Comment published')}
/>

Comment Counts

All props in the <CommentCount> component are the same as the base hyvor-talk-comment-count Web Component.

If you only have one <CommentCount> on the page, use the component directly:

<script>
    import { CommentCount } from '@hyvor/hyvor-talk-svelte';
</script>

<CommentCount
    page-id={PAGE_ID}
    website-id={YOUR_WEBSITE_ID}
/>

If you have multiple <CommentCount> in the page, use loading="manual" prop on each component and call loadCommentCounts() function when the components are mounted. This will reduce the number of API calls needed.

<script>
    import { CommentCount, loadCommentCounts } from '@hyvor/hyvor-talk-svelte';
    import { onMount } from 'svelte';

    onMount(() => {
        loadCommentCounts({
            'website-id': YOUR_WEBSITE_ID,
        });
    });
</script>

<div>
    <CommentCount
        page-id={PAGE_ID_1}
        loading="manual"
    />
    <CommentCount
        page-id={PAGE_ID_2}
        loading="manual"
    />
</div>

loadCommentCounts function has the following signature:

loadCommentCounts(
    options: {
        "website-id"?: number,
        mode?: 'text' | 'number',
        language?: string,
    } = {},
    callback: ((count: number | string, el: Element) => string | number) | null = null
): void

See the comment counts documentation for more details.

0.0.7

2 months ago

0.0.6

4 months ago

0.0.3

10 months ago

0.0.4-beta.1

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.2

1 year ago

0.0.1-beta.10

1 year ago

0.0.1

1 year ago

0.0.1-beta.3

1 year ago

0.0.1-beta.2

1 year ago

0.0.1-beta.1

1 year ago