@fy-/fws-vue 2.1.25 → 2.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,6 @@ import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/vue/24/solid'
9
9
  import { useServerHead } from '@unhead/vue'
10
10
  import {
11
11
  computed,
12
- onMounted,
13
- onUnmounted,
14
12
  ref,
15
13
  watch,
16
14
  } from 'vue'
@@ -33,7 +31,6 @@ const props = withDefaults(
33
31
  const route = useRoute()
34
32
  const eventBus = useEventBus()
35
33
  const history = useServerRouter()
36
- const prevNextSeo = ref<any>({})
37
34
  function isNewPage(page: number) {
38
35
  return (
39
36
  page >= 1 && page <= props.items.page_max && page !== props.items.page_no
@@ -75,55 +72,46 @@ function page(page: number): RouteLocationRaw {
75
72
  }
76
73
  }
77
74
 
78
- function checkPageNumber(page: number = 1) {
79
- prevNextSeo.value.next = undefined
80
- prevNextSeo.value.prev = undefined
81
-
82
- if (hasFW()) {
83
- const url = getURL()
84
- if (page + 1 <= props.items.page_max && url) {
85
- prevNextSeo.value.next
86
- = `${url.Scheme}://${url.Host}${url.Path}?page=${page + 1}${
87
- props.hash !== '' ? `#${props.hash}` : ''}`
88
- }
89
- if (page - 1 >= 1 && url) {
90
- prevNextSeo.value.prev
91
- = `${url.Scheme}://${url.Host}${url.Path}?page=${page - 1}${
92
- props.hash !== '' ? `#${props.hash}` : ''}`
93
- }
94
- }
95
- }
96
-
97
75
  pageWatcher.value = watch(
98
76
  () => route.query.page,
99
77
  (v) => {
100
78
  eventBus.emit(`${props.id}GoToPage`, v || 1)
101
79
  },
102
80
  )
103
- onMounted(() => {
104
- eventBus.on(`${props.id}GoToPage`, checkPageNumber)
105
- })
106
- onUnmounted(() => {
107
- eventBus.off(`${props.id}GoToPage`, checkPageNumber)
108
- // if (pageWatcher.value) pageWatcher.value();
109
- })
110
-
111
- checkPageNumber(props.items.page_no)
112
81
 
113
82
  useServerHead({
114
83
  link: computed(() => {
115
84
  const result: any = []
116
- checkPageNumber(props.items.page_no)
117
- if (prevNextSeo.value.next) {
85
+ const page = props.items.page_no
86
+ const page_max = props.items.page_max
87
+
88
+ let next
89
+ let prev
90
+
91
+ if (hasFW()) {
92
+ const url = getURL()
93
+ if (page + 1 <= page_max && url) {
94
+ next = `${url.Scheme}://${url.Host}${url.Path}?page=${page + 1}${
95
+ props.hash !== '' ? `#${props.hash}` : ''
96
+ }`
97
+ }
98
+ if (page - 1 >= 1 && url) {
99
+ prev = `${url.Scheme}://${url.Host}${url.Path}?page=${page - 1}${
100
+ props.hash !== '' ? `#${props.hash}` : ''
101
+ }`
102
+ }
103
+ }
104
+
105
+ if (next) {
118
106
  result.push({
119
- href: prevNextSeo.value.next,
107
+ href: next,
120
108
  rel: 'next',
121
109
  key: 'paging-next',
122
110
  })
123
111
  }
124
- if (prevNextSeo.value.prev) {
112
+ if (prev) {
125
113
  result.push({
126
- href: prevNextSeo.value.prev,
114
+ href: prev,
127
115
  rel: 'prev',
128
116
  key: 'paging-prev',
129
117
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "2.1.25",
3
+ "version": "2.1.27",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/fy-to/FWJS#readme",