Import Waline via CDN
This cookbook is about importing Waline via CDN.
For China Mainland users, we recommend using unpkg. 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@v3/dist/waline.css"
/>
<!-- script file -->
<script type="module">
import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
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@v3/dist/pageview.js';
pageviewCount({
// options
});
</script>
Comments count:
<script type="module">
import { commentCount } from 'https://unpkg.com/@waline/client@v3/dist/comment.js';
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.
- 0
- 0
- 0
- 0
- 0
- 0