@daeryun/dr_components 1.3.46 → 1.3.48

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.
@@ -22,7 +22,6 @@ const LawInfoNew = ({ data, tel }) => {
22
22
  const { template, contentsList, h2List, lawyerData, fieldData, successData, groupTopTenLawyerList, referenceLinkList, newsLinkList, shortsLinkList, youtubeLinkList, initialData, nextPost, prevPost, faqElementMaxCountInContents } = data;
23
23
  const { width } = useBrowser(true);
24
24
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState(lawyerData);
25
- const [isFaqActive, setIsFaqActive] = useState(false);
26
25
  const printRef = useRef(null);
27
26
  const h1Title = template
28
27
  .map(temp => temp.tag === 'h1' && temp.tag_title)
@@ -32,6 +31,7 @@ const LawInfoNew = ({ data, tel }) => {
32
31
  .map(temp => temp.tag === 'h1' && temp.description)
33
32
  .filter(temp => temp !== false)
34
33
  .toString();
34
+ const faqPageCountInContents = faqElementMaxCountInContents !== null && faqElementMaxCountInContents !== void 0 ? faqElementMaxCountInContents : 0;
35
35
  const handleScrollToElement = (idx) => {
36
36
  if (typeof window != 'undefined') {
37
37
  const element = document.getElementById(idx.toString());
@@ -44,31 +44,29 @@ const LawInfoNew = ({ data, tel }) => {
44
44
  }
45
45
  }
46
46
  };
47
- const handleFaqItemType = (isFaqActive, faqElementMaxCountInContents) => {
48
- if (isFaqActive && faqElementMaxCountInContents === 0) {
49
- return 'https://schema.org/FAQPage';
50
- }
51
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
47
+ const handleFaqItemType = () => {
48
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
49
+ if (faqPageCountInContents === 1) {
52
50
  return undefined;
53
51
  }
54
52
  return 'https://schema.org/FAQPage';
55
53
  };
56
- const handleFaqItemScope = (isFaqActive, faqElementMaxCountInContents) => {
57
- if (isFaqActive && faqElementMaxCountInContents === 0) {
58
- return true;
59
- }
60
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
54
+ const handleFaqItemScope = () => {
55
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
56
+ if (faqPageCountInContents === 1) {
61
57
  return undefined;
62
58
  }
63
59
  return true;
64
60
  };
65
61
  const convertFaqItemType = (template) => {
66
- if (faqElementMaxCountInContents >= 2) {
67
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
68
- template.description = template.description.replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
69
- return template;
62
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
63
+ if (faqPageCountInContents >= 2) {
64
+ const convertedDescription = template.description
65
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>')
66
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
67
+ return Object.assign(Object.assign({}, template), { description: convertedDescription });
70
68
  }
71
- return template;
69
+ return Object.assign({}, template);
72
70
  };
73
71
  // 변호사 6명 맞추기
74
72
  useEffect(() => {
@@ -88,19 +86,7 @@ const LawInfoNew = ({ data, tel }) => {
88
86
  setRelatedCaseLawyerList(lawyerData.slice(0, maxCount));
89
87
  }
90
88
  }, [lawyerData, groupTopTenLawyerList]);
91
- useEffect(() => {
92
- if (template) {
93
- // 초기화
94
- setIsFaqActive(false);
95
- for (const data of template) {
96
- // console.log("faq 활성화: ", data['active_faq']);
97
- if (data['active_faq']) {
98
- setIsFaqActive(true);
99
- }
100
- }
101
- }
102
- }, [template]);
103
- return (<div itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents)} itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents)} ref={printRef}>
89
+ return (<div itemScope={handleFaqItemScope()} itemType={handleFaqItemType()} ref={printRef}>
104
90
  <div id={'sub_contents'}>
105
91
  <div className="relative m-auto mb-[60px] w-[90%] max-w-screen-2xl max-xs:mb-[30px]">
106
92
  <div className={'m-auto mt-[100px] flex gap-[120px] lg:mt-[5em] ' +
@@ -43,7 +43,6 @@ const LawInfoNew = ({ data, tel }: ILawInfoNewPageTypes) => {
43
43
  } = data;
44
44
  const { width } = useBrowser(true);
45
45
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState<ILawyerTypes[]>(lawyerData);
46
- const [isFaqActive, setIsFaqActive] = useState<boolean>(false);
47
46
  const printRef = useRef<HTMLDivElement>(null);
48
47
 
49
48
  const h1Title: string = template
@@ -54,6 +53,7 @@ const LawInfoNew = ({ data, tel }: ILawInfoNewPageTypes) => {
54
53
  .map(temp => temp.tag === 'h1' && temp.description)
55
54
  .filter(temp => temp !== false)
56
55
  .toString();
56
+ const faqPageCountInContents = faqElementMaxCountInContents ?? 0;
57
57
 
58
58
  const handleScrollToElement = (idx: number) => {
59
59
  if (typeof window != 'undefined') {
@@ -68,24 +68,18 @@ const LawInfoNew = ({ data, tel }: ILawInfoNewPageTypes) => {
68
68
  }
69
69
  };
70
70
 
71
- const handleFaqItemType = (isFaqActive: boolean, faqElementMaxCountInContents?: number): string | undefined => {
72
- if (isFaqActive && faqElementMaxCountInContents === 0) {
73
- return 'https://schema.org/FAQPage';
74
- }
75
-
76
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
71
+ const handleFaqItemType = (): string | undefined => {
72
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
73
+ if (faqPageCountInContents === 1) {
77
74
  return undefined;
78
75
  }
79
76
 
80
77
  return 'https://schema.org/FAQPage';
81
78
  };
82
79
 
83
- const handleFaqItemScope = (isFaqActive: boolean, faqElementMaxCountInContents?: number): true | undefined => {
84
- if (isFaqActive && faqElementMaxCountInContents === 0) {
85
- return true;
86
- }
87
-
88
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
80
+ const handleFaqItemScope = (): true | undefined => {
81
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
82
+ if (faqPageCountInContents === 1) {
89
83
  return undefined;
90
84
  }
91
85
 
@@ -93,17 +87,22 @@ const LawInfoNew = ({ data, tel }: ILawInfoNewPageTypes) => {
93
87
  };
94
88
 
95
89
  const convertFaqItemType = (template: ISeoTemplateTypes): ISeoTemplateTypes => {
96
- if ((faqElementMaxCountInContents as number) >= 2) {
97
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
98
- template.description = template.description.replaceAll(
99
- '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
100
- '&lt;div&gt;'
101
- );
90
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
91
+ if (faqPageCountInContents >= 2) {
92
+ const convertedDescription = template.description
93
+ .replaceAll(
94
+ '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
95
+ '&lt;div&gt;'
96
+ )
97
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
102
98
 
103
- return template;
99
+ return {
100
+ ...template,
101
+ description: convertedDescription
102
+ };
104
103
  }
105
104
 
106
- return template;
105
+ return { ...template };
107
106
  };
108
107
 
109
108
  // 변호사 6명 맞추기
@@ -126,24 +125,10 @@ const LawInfoNew = ({ data, tel }: ILawInfoNewPageTypes) => {
126
125
  }
127
126
  }, [lawyerData, groupTopTenLawyerList]);
128
127
 
129
- useEffect(() => {
130
- if (template) {
131
- // 초기화
132
- setIsFaqActive(false);
133
-
134
- for (const data of template) {
135
- // console.log("faq 활성화: ", data['active_faq']);
136
- if (data['active_faq']) {
137
- setIsFaqActive(true);
138
- }
139
- }
140
- }
141
- }, [template]);
142
-
143
128
  return (
144
129
  <div
145
- itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents as number)}
146
- itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents as number)}
130
+ itemScope={handleFaqItemScope()}
131
+ itemType={handleFaqItemType()}
147
132
  ref={printRef}
148
133
  >
149
134
  <div id={'sub_contents'}>
@@ -23,8 +23,8 @@ const SuccessNew = ({ data, tel }) => {
23
23
  const { template, contentsList, h2List, imgData, lawyerData, fieldData, successData, groupTopTenLawyerList, referenceLinkList, newsLinkList, shortsLinkList, youtubeLinkList, pn, initialData, faqElementMaxCountInContents } = data;
24
24
  const { width } = useBrowser(true);
25
25
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState(lawyerData);
26
- const [isFaqActive, setIsFaqActive] = useState(false);
27
26
  const printRef = useRef(null);
27
+ const faqPageCountInContents = faqElementMaxCountInContents !== null && faqElementMaxCountInContents !== void 0 ? faqElementMaxCountInContents : 0;
28
28
  const typeIdxNum = template && template[0].type_idx;
29
29
  const successDataFiltered = successData.filter(data => Number(data.type_idx) !== typeIdxNum);
30
30
  const legalDocumentImageObject = imgData && imgData.length > 0 ? imgData[0] : null;
@@ -55,31 +55,29 @@ const SuccessNew = ({ data, tel }) => {
55
55
  const imgLocation = (_b = (_a = document.getElementById('img_wrap')) === null || _a === void 0 ? void 0 : _a.offsetTop) !== null && _b !== void 0 ? _b : 0;
56
56
  window.scrollTo({ top: imgLocation + (width > 680 ? 300 : 200), behavior: 'smooth' });
57
57
  };
58
- const handleFaqItemType = (isFaqActive, faqElementMaxCountInContents) => {
59
- if (isFaqActive && faqElementMaxCountInContents === 0) {
60
- return 'https://schema.org/FAQPage';
61
- }
62
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
58
+ const handleFaqItemType = () => {
59
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
60
+ if (faqPageCountInContents === 1) {
63
61
  return undefined;
64
62
  }
65
63
  return 'https://schema.org/FAQPage';
66
64
  };
67
- const handleFaqItemScope = (isFaqActive, faqElementMaxCountInContents) => {
68
- if (isFaqActive && faqElementMaxCountInContents === 0) {
69
- return true;
70
- }
71
- if (isFaqActive && faqElementMaxCountInContents >= 2) {
65
+ const handleFaqItemScope = () => {
66
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
67
+ if (faqPageCountInContents === 1) {
72
68
  return undefined;
73
69
  }
74
70
  return true;
75
71
  };
76
72
  const convertFaqItemType = (template) => {
77
- if (faqElementMaxCountInContents >= 2) {
78
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
79
- template.description = template.description.replaceAll('&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;', '&lt;div&gt;');
80
- return template;
73
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
74
+ if (faqPageCountInContents >= 2) {
75
+ const convertedDescription = template.description
76
+ .replaceAll('&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;', '&lt;div&gt;')
77
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
78
+ return Object.assign(Object.assign({}, template), { description: convertedDescription });
81
79
  }
82
- return template;
80
+ return Object.assign({}, template);
83
81
  };
84
82
  // 변호사 6명 맞추기
85
83
  useEffect(() => {
@@ -99,19 +97,7 @@ const SuccessNew = ({ data, tel }) => {
99
97
  setRelatedCaseLawyerList(lawyerData.slice(0, maxCount));
100
98
  }
101
99
  }, [lawyerData, groupTopTenLawyerList]);
102
- useEffect(() => {
103
- if (template) {
104
- // 초기화
105
- setIsFaqActive(false);
106
- for (const data of template) {
107
- // console.log("faq 활성화: ", data['active_faq']);
108
- if (data['active_faq']) {
109
- setIsFaqActive(true);
110
- }
111
- }
112
- }
113
- }, [template]);
114
- return (<div itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents)} itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents)} ref={printRef}>
100
+ return (<div itemScope={handleFaqItemScope()} itemType={handleFaqItemType()} ref={printRef}>
115
101
  <div className="relative m-auto mb-[100px] w-[90%] max-w-screen-2xl max-md2:mb-[40px] max-xs:mb-[30px]">
116
102
  <div className={'m-auto mt-[100px] flex gap-[120px] ' +
117
103
  //1700px
@@ -46,8 +46,8 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
46
46
  } = data;
47
47
  const { width } = useBrowser(true);
48
48
  const [relatedCaseLawyerList, setRelatedCaseLawyerList] = useState<ILawyerTypes[]>(lawyerData);
49
- const [isFaqActive, setIsFaqActive] = useState<boolean>(false);
50
49
  const printRef = useRef<HTMLDivElement>(null);
50
+ const faqPageCountInContents = faqElementMaxCountInContents ?? 0;
51
51
  const typeIdxNum: number | null = template && (template[0].type_idx as number);
52
52
  const successDataFiltered: ISuccessTypes[] = successData.filter(data => Number(data.type_idx) !== typeIdxNum);
53
53
 
@@ -85,24 +85,18 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
85
85
  window.scrollTo({ top: imgLocation + (width > 680 ? 300 : 200), behavior: 'smooth' });
86
86
  };
87
87
 
88
- const handleFaqItemType = (isFaqActive: boolean, faqElementMaxCountInContents?: number): string | undefined => {
89
- if (isFaqActive && faqElementMaxCountInContents === 0) {
90
- return 'https://schema.org/FAQPage';
91
- }
92
-
93
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
88
+ const handleFaqItemType = (): string | undefined => {
89
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
90
+ if (faqPageCountInContents === 1) {
94
91
  return undefined;
95
92
  }
96
93
 
97
94
  return 'https://schema.org/FAQPage';
98
95
  };
99
96
 
100
- const handleFaqItemScope = (isFaqActive: boolean, faqElementMaxCountInContents?: number): true | undefined => {
101
- if (isFaqActive && faqElementMaxCountInContents === 0) {
102
- return true;
103
- }
104
-
105
- if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
97
+ const handleFaqItemScope = (): true | undefined => {
98
+ // 작성자 FAQPage가 1개일 때만 루트 FAQPage를 제거한다.
99
+ if (faqPageCountInContents === 1) {
106
100
  return undefined;
107
101
  }
108
102
 
@@ -110,17 +104,22 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
110
104
  };
111
105
 
112
106
  const convertFaqItemType = (template: ISeoTemplateTypes): ISeoTemplateTypes => {
113
- if ((faqElementMaxCountInContents as number) >= 2) {
114
- // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
115
- template.description = template.description.replaceAll(
116
- '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
117
- '&lt;div&gt;'
118
- );
119
-
120
- return template;
107
+ // 작성자 FAQPage가 2개 이상이면 내부 FAQPage를 지우고 루트 FAQPage 1개만 유지한다.
108
+ if (faqPageCountInContents >= 2) {
109
+ const convertedDescription = template.description
110
+ .replaceAll(
111
+ '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
112
+ '&lt;div&gt;'
113
+ )
114
+ .replaceAll('<div itemscope="" itemtype="https://schema.org/FAQPage">', '<div>');
115
+
116
+ return {
117
+ ...template,
118
+ description: convertedDescription
119
+ };
121
120
  }
122
121
 
123
- return template;
122
+ return { ...template };
124
123
  };
125
124
 
126
125
  // 변호사 6명 맞추기
@@ -143,24 +142,10 @@ const SuccessNew = ({ data, tel }: ISuccessNewPageTypes) => {
143
142
  }
144
143
  }, [lawyerData, groupTopTenLawyerList]);
145
144
 
146
- useEffect(() => {
147
- if (template) {
148
- // 초기화
149
- setIsFaqActive(false);
150
-
151
- for (const data of template) {
152
- // console.log("faq 활성화: ", data['active_faq']);
153
- if (data['active_faq']) {
154
- setIsFaqActive(true);
155
- }
156
- }
157
- }
158
- }, [template]);
159
-
160
145
  return (
161
146
  <div
162
- itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents as number)}
163
- itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents as number)}
147
+ itemScope={handleFaqItemScope()}
148
+ itemType={handleFaqItemType()}
164
149
  ref={printRef}
165
150
  >
166
151
  <div className="relative m-auto mb-[100px] w-[90%] max-w-screen-2xl max-md2:mb-[40px] max-xs:mb-[30px]">