Skip to content

Commit 14f44f9

Browse files
committed
pagination example
1 parent bccba50 commit 14f44f9

6 files changed

Lines changed: 258 additions & 182 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ export default Vue.extend({
5353
## Updating The Current Page (SPA Example)
5454

5555
In FastComments we call the article id, or page the comments get tied to, the URL ID as it can be a url or an ID.
56-
Define the URL ID in the following manner. The component watches for changes in config object, and will reload, so you can update the URL ID.
56+
Define the URL ID in the following manner. The component watches for changes in config object, and will reload, so you can just update the "url" and "urlId" settings.
57+
58+
See a full working example [here](dev/serve-pagination.ts).
59+
60+
Run the pagination example via:
61+
62+
```
63+
npm run serve-pagination
64+
```
5765

5866
```vue
59-
<fast-comments-vue v-bind:config="{tenantId: 'demo', urlId: 'some-page-id'}" />
67+
<fast-comments-vue v-bind:config="{tenantId: 'demo', url: 'https://example.com', urlId: 'some-page-id'}" />
6068
```
6169

6270

dev/serve-dark-mode-toggle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import FastCommentsVue from '@/fastcomments-vue.vue';
44
55
export default Vue.extend({
6-
name: 'ServeDev',
6+
name: 'ServeDarkModeToggle',
77
components: {
88
FastCommentsVue
99
},

dev/serve-pagination.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Vue, { VNode } from 'vue';
2+
import Dev from './serve-pagination.vue';
3+
import Router from 'vue-router';
4+
5+
Vue.config.productionTip = false;
6+
7+
const routes = [
8+
{
9+
path: '/demo',
10+
component: Dev
11+
}
12+
];
13+
14+
const router = new Router({
15+
routes
16+
});
17+
18+
Vue.use(Router);
19+
20+
new Vue({
21+
router,
22+
render: (h): VNode => h(Dev),
23+
}).$mount('#app');

dev/serve-pagination.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script lang="ts">
2+
import Vue from 'vue';
3+
import FastCommentsVue from '@/fastcomments-vue.vue';
4+
5+
export default Vue.extend({
6+
name: 'ServePagination',
7+
components: {
8+
FastCommentsVue
9+
},
10+
methods: {
11+
updatePage: function(pageNumber: number) {
12+
this.$router.push('/demo#page-' + pageNumber);
13+
this.page = pageNumber;
14+
}
15+
},
16+
data() {
17+
return {
18+
page: 0,
19+
url: null
20+
}
21+
},
22+
watch: {
23+
$route() {
24+
this.url = window.location.href;
25+
}
26+
}
27+
});
28+
</script>
29+
30+
<template>
31+
<div id="app">
32+
<div>Page: <span v-html="page"></span></div>
33+
<button @click="updatePage(page - 1)" style="margin-right: 5px">Prev</button>
34+
<button @click="updatePage(page + 1)">Next</button>
35+
<fast-comments-vue v-bind:config="{tenantId: 'nYrnfYEv', urlId: url, url: url}"/>
36+
</div>
37+
</template>

0 commit comments

Comments
 (0)