itube-specs 0.0.367 → 0.0.368

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.
@@ -1,11 +1,17 @@
1
1
  import { computed, unref } from 'vue';
2
2
  import type { Ref } from 'vue';
3
3
  import { useRoute } from 'vue-router';
4
+ import type { IChipsItem } from '../types';
4
5
 
5
- export function useMeta(t, page: string, brandName: string, hasSort?: boolean, text?: Ref<string>, secondText?: Ref<string>) {
6
+ export function useMeta(t, page: string, brandName: string, sortOptions?: IChipsItem[], text?: Ref<string>, secondText?: Ref<string>) {
6
7
  const route = useRoute();
7
8
 
8
- const sortType = computed(() => route?.query?.['sort'] || 'trending');
9
+ const sortType = computed(() => {
10
+ const values = sortOptions?.map(item => item.value);
11
+ const queryValue = String(route?.query?.['sort']);
12
+ const DEFAULT_VALUE = 'trending';
13
+ return queryValue && values?.includes(queryValue) ? queryValue : DEFAULT_VALUE;
14
+ });
9
15
 
10
16
  function getPath(key: string) {
11
17
  const plainSlug = unref(text);
@@ -14,7 +20,7 @@ export function useMeta(t, page: string, brandName: string, hasSort?: boolean, t
14
20
  const pageText = unref(pageNumber) === 1 ? null : ` #${unref(pageNumber)}`;
15
21
 
16
22
  return t(
17
- `meta.${page}.${hasSort ? `${sortType.value}.` : ''}${key}`,
23
+ `meta.${page}.${sortOptions && sortOptions.length > 0 ? `${sortType.value}.` : ''}${key}`,
18
24
  {
19
25
  text: plainSlug,
20
26
  secondText: secondTextValue,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.367",
4
+ "version": "0.0.368",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {