itube-specs 0.0.369 → 0.0.372

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.
@@ -89,7 +89,7 @@ const isActive = computed(() => {
89
89
  }
90
90
 
91
91
  const current = route.path.replace(/^\/|\/$/g, '');
92
- const target = targetPath.value.replace(/^\/|\/$/g, '');
92
+ const target = generateLink(targetPath.value).replace(/^\/|\/$/g, '');
93
93
 
94
94
  return current === target;
95
95
  });
@@ -3,7 +3,7 @@ import type { Ref } from 'vue';
3
3
  import { useRoute } from 'vue-router';
4
4
  import type { IChipsItem } from '../types';
5
5
 
6
- export function useMeta(t, page: string, brandName: string, sortOptions?: IChipsItem[], text?: Ref<string>, secondText?: Ref<string>) {
6
+ export function useMeta(t, page: string, brandName: string, sortOptions?: IChipsItem[], text?: Ref<string>, secondText?: Ref<string>, thirdText?: Ref<string>, fourthText?: Ref<string>) {
7
7
  const route = useRoute();
8
8
 
9
9
  const sortType = computed(() => {
@@ -16,6 +16,8 @@ export function useMeta(t, page: string, brandName: string, sortOptions?: IChips
16
16
  function getPath(key: string) {
17
17
  const plainSlug = unref(text);
18
18
  const secondTextValue = unref(secondText);
19
+ const thirdTextValue = unref(thirdText);
20
+ const fourTextValue = unref(fourthText);
19
21
  const pageNumber = computed(() => route.query?.['page'] ? Number(route.query['page']) : 1);
20
22
  const pageText = unref(pageNumber) === 1 ? null : ` #${unref(pageNumber)}`;
21
23
 
@@ -24,6 +26,8 @@ export function useMeta(t, page: string, brandName: string, sortOptions?: IChips
24
26
  {
25
27
  text: plainSlug,
26
28
  secondText: secondTextValue,
29
+ thirdText: thirdTextValue,
30
+ fourText: fourTextValue,
27
31
  brandName: `| ${brandName}`, //черточка '|' нужна обязательно
28
32
  page: pageText,
29
33
  }
@@ -0,0 +1,99 @@
1
+ import type { IChipsItem, IModelFilter, IModelFilterOptions } from '../types'
2
+ import type { LocationQuery } from '#vue-router'
3
+ import { getMonth } from '../runtime'
4
+ import type { Ref } from 'vue';
5
+
6
+ export function useFilterChipsItems(
7
+ filters: Ref<IModelFilter[]>,
8
+ route: { query: LocationQuery },
9
+ t: (key: string) => string
10
+ ) {
11
+ const chipsItems = computed<IChipsItem[]>(() => {
12
+ const queryItems = Object.keys(route.query)
13
+ .filter(item => item.startsWith('filter_'))
14
+ .map(item =>
15
+ item
16
+ .replace('filter_', '')
17
+ .replace(/_/g, ' ')
18
+ )
19
+
20
+ const groups = Object.values(
21
+ queryItems.reduce((acc: Record<string, string[]>, str: string) => {
22
+ const parts = str.split(' ')
23
+ const last = parts.at(-1)
24
+
25
+ const key =
26
+ last === 'from' || last === 'to'
27
+ ? parts.slice(0, -1).join(' ')
28
+ : str
29
+
30
+ acc[key] ??= []
31
+
32
+ if (last === 'from') acc[key].unshift(str)
33
+ else acc[key].push(str)
34
+
35
+ return acc
36
+ }, {})
37
+ )
38
+
39
+ const getValue = (item: string, index: number) => {
40
+ const filter = filters.value.find(filter =>
41
+ filter.name ===
42
+ item
43
+ .replace(/ /g, '_')
44
+ .replace('_from', '')
45
+ .replace('_to', '')
46
+ )
47
+
48
+ const defaultValue =
49
+ index === 0
50
+ ? filter?.options[0]
51
+ : filter?.options.at(-1)
52
+
53
+ const value = route.query[`filter_${item.replace(/ /g, '_')}`]
54
+
55
+ if (item.includes('month')) {
56
+ return getMonth(
57
+ t,
58
+ Number(value ?? defaultValue?.name) - 1
59
+ )
60
+ }
61
+
62
+ if (!isNaN(Number(value))) {
63
+ return value
64
+ }
65
+
66
+ return (
67
+ filter?.options.find(
68
+ (option: IModelFilterOptions) =>
69
+ option.name === value
70
+ )?.title ??
71
+ defaultValue?.title
72
+ )
73
+ }
74
+
75
+ const getValueText = (items: string[]) =>
76
+ [...new Set(items.map(getValue))].join(' - ')
77
+
78
+ const chipsTitle = (items: string[]) => {
79
+ const key = items[0].replace(' from', '')
80
+ const filter = filters.value.find(
81
+ f => f.name.replace(/_/g, ' ') === key
82
+ )
83
+
84
+ const text = `${filter?.title}: ${getValueText(items)}`
85
+ return text.length > 30 ? getValueText(items) : text
86
+ }
87
+
88
+ return groups.map(item => ({
89
+ title: chipsTitle(item),
90
+ value: item.map(
91
+ sub => `filter_${sub.replace(/ /g, '_')}`
92
+ ),
93
+ }))
94
+ })
95
+
96
+ return {
97
+ chipsItems,
98
+ }
99
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.369",
4
+ "version": "0.0.372",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
@@ -25,4 +25,5 @@ export const cleanVideoData = (data: IRawVideoData): IVideoData => ({
25
25
  videoUrl: data.video_url || '',
26
26
  isDeleted: data.is_deleted || false,
27
27
  thumbNum: data.thumb_number || 0,
28
+ description: data.description || '',
28
29
  })
@@ -10,7 +10,7 @@ export interface IRawVideoData {
10
10
  is_hd: boolean; // unused
11
11
  title: string;
12
12
  header: string;
13
- description: string; // unused
13
+ description: string;
14
14
  views: number;
15
15
  likes: number;
16
16
  dislikes: number; // unused
@@ -34,4 +34,5 @@ export interface IVideoData {
34
34
  videoUrl: string;
35
35
  isDeleted: boolean;
36
36
  thumbNum: number;
37
+ description: string;
37
38
  }