1.0.1 • Published 10 months ago

@hyvor/hyvor-talk-svelte v1.0.1

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

Installation

npm install @hyvor/hyvor-talk-svelte

Usage

The following components are available:

Comments

Use the <Comments> component to add comments to your webpage. The props are the same as the attributes of hyvor-talk-comments.

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

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

Comment Counts

Use the <CommentCount> component to display the number of comments on a page. All props are the same as the base hyvor-talk-comment-count Web Component.

First, add the <CommentCount> components to your app. Then, call CommentCounts.load() in onMount to load the comment counts.

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

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

<CommentCount page-id="my-page-1" />
<CommentCount page-id="my-page-2" />

Newsletter Form

Use the <NewsletterForm> component to add a newsletter form to your webpage. The props are the same as the attributes of hyvor-talk-newsletter.

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

<NewsletterForm
    website-id={YOUR_WEBSITE_ID}
/>

Memberships & Gated Content

Use the <Memberships> component to add memberships to your webpage. The props are the same as the attributes of hyvor-talk-memberships.

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

<Memberships
    website-id={YOUR_WEBSITE_ID}
/>

Once you have memberships set up, you can use the <GatedContent> component to show content only to members. The props are the same as the attributes of hyvor-talk-gated-content.

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

<GatedContent key="my-content" />

Listening to Events

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

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

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

Accessing the Web Component Instance

Bind the element prop to a variable to access the underlying Web Component instance. This is useful to call API methods.

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

    let element;

    function onLoad() {
        console.log(element.api.page());
    }
</script>

<Comments
    website-id={YOUR_WEBSITE_ID}
    page-id={UNIQUE_PAGE_ID}
    bind:element
    on:loaded={onLoad}
/>
1.0.1

10 months ago

1.0.0

10 months ago

1.0.0-beta.2

11 months ago

1.0.0-beta.1

11 months ago

0.0.7

1 year ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.4-beta.1

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1-beta.10

2 years ago

0.0.1

2 years ago

0.0.1-beta.3

2 years ago

0.0.1-beta.2

2 years ago

0.0.1-beta.1

2 years ago