Import Waline via CDN

Less than 1 minute...

This cookbook is about importing Waline via CDN.

For China Mainland users, we recommend using unpkgopen in new window. For foreign users, we recommend using jsDelivr.

To make Waline SSR friendly, we split Waline's styles in V2 version. This means, you need to import Waline's CSS style file, and import Waline script file and call Waline.

Comment

Normally, you may want Waline to render a list of comments, you can import Waline as follows:

<!-- style file -->
<link
  rel="stylesheet"
  href="https://unpkg.com/@waline/client@v2/dist/waline.css"
/>
<!-- script file -->
<script type="module">
  import { init } from 'https://unpkg.com/@waline/client@v2/dist/waline.mjs';

  init({
    // options
  });
</script>

Pageviews and comments

Sometimes, you may want to display the number of page views and comments of the article on the home page or article list, but do not need to load the comment component, then you can import a Gzip < 1KB script file in the following ways:

Pageviews:

<script type="module">
  import { pageviewCount } from 'https://unpkg.com/@waline/client@v2/dist/pageview.mjs';

  pageviewCount({
    // options
  });
</script>

Comments count:

<script type="module">
  import { commentCount } from 'https://unpkg.com/@waline/client@v2/dist/comment.mjs';

  commentCount({
    // options
  });
</script>

More

Specifies version

You may have noticed that in the above cases, we have explicitly declared the @v2 version after @aline/client. Your website is not working properly.

TIPS: The comment area is only for demo. If you have any questions, please go to Github Discussion to ask.
What do you think?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v2.14.7