@daeryun/dr_components 1.3.26 → 1.3.28

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.
@@ -0,0 +1,454 @@
1
+ 'use client';
2
+
3
+ import ContentList from '../SuccessNew/components/ContentList';
4
+ import { Fragment, useEffect, useRef, useState } from 'react';
5
+ import useBrowser from '../../hook/useBrowser';
6
+ import { ILawyerTypes, ISeoTemplateTypes } from '../SuccessNew/SuccessNewType';
7
+ import { htmlUrlDecode } from '../../../lib';
8
+ import H2Contents from '../SuccessNew/components/H2Contents';
9
+ import H3Contents from '../SuccessNew/components/H3Contents';
10
+ import SeoAdditionalLink from '../SuccessNew/components/SeoAdditionalLink';
11
+ import PdfPrintCopyLink from '../../PdfPrintCopyLink/PdfPrintCopyLink';
12
+ import SeoYoutube from '../../Seo/SeoYoutube';
13
+ import SeoStrength from '../../Seo/SeoStrength';
14
+ import SeoConsulting from '../../Seo/SeoConsulting';
15
+ import LawInfoContentList from '../SuccessNew/components/LawInfoContentList';
16
+ import { SuccessCase } from '../SuccessNew/components/SuccessCase';
17
+ import { FieldCase } from '../SuccessNew/components/FieldCase';
18
+ import { IBlogPageTypes } from './BlogTypes';
19
+ import Link from 'next/link';
20
+ import Image from 'next/image';
21
+ import Arrow from '../../../asset/images/success_new/left.webp';
22
+ import RightArrow from '../../../asset/images/success_new/right.webp';
23
+
24
+ const Blog = ({ data, tel }: IBlogPageTypes) => {
25
+ const {
26
+ template,
27
+ contentsList,
28
+ h2List,
29
+ fieldData,
30
+ successData,
31
+ referenceLinkList,
32
+ newsLinkList,
33
+ shortsLinkList,
34
+ youtubeLinkList,
35
+ initialData,
36
+ nextPost,
37
+ prevPost,
38
+ faqElementMaxCountInContents
39
+ } = data;
40
+ const { width } = useBrowser(true);
41
+ const [isFaqActive, setIsFaqActive] = useState<boolean>(false);
42
+ const printRef = useRef<HTMLDivElement>(null);
43
+
44
+ const h1Title: string = template
45
+ .map(temp => temp.tag === 'h1' && temp.tag_title)
46
+ .filter(temp => temp !== false)
47
+ .toString();
48
+ const h1Description: string = template
49
+ .map(temp => temp.tag === 'h1' && temp.description)
50
+ .filter(temp => temp !== false)
51
+ .toString();
52
+
53
+ const handleScrollToElement = (idx: number) => {
54
+ if (typeof window != 'undefined') {
55
+ const element = document.getElementById(idx.toString());
56
+ if (element) {
57
+ const topOffset = element.getBoundingClientRect().top;
58
+ window.scrollTo({
59
+ top: window.scrollY + topOffset - 150,
60
+ behavior: 'smooth'
61
+ });
62
+ }
63
+ }
64
+ };
65
+
66
+ const handleFaqItemType = (isFaqActive: boolean, faqElementMaxCountInContents?: number): string | undefined => {
67
+ if (isFaqActive && faqElementMaxCountInContents === 0) {
68
+ return 'https://schema.org/FAQPage';
69
+ }
70
+
71
+ if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
72
+ return undefined;
73
+ }
74
+
75
+ return 'https://schema.org/FAQPage';
76
+ };
77
+
78
+ const handleFaqItemScope = (isFaqActive: boolean, faqElementMaxCountInContents?: number): true | undefined => {
79
+ if (isFaqActive && faqElementMaxCountInContents === 0) {
80
+ return true;
81
+ }
82
+
83
+ if (isFaqActive && (faqElementMaxCountInContents as number) >= 2) {
84
+ return undefined;
85
+ }
86
+
87
+ return true;
88
+ };
89
+
90
+ const convertFaqItemType = (template: ISeoTemplateTypes): ISeoTemplateTypes => {
91
+ if ((faqElementMaxCountInContents as number) >= 2) {
92
+ // faqElementMaxCountInContents가 두 개 이상일 경우, template 내부에 FAQPage itemtype을 지운다. FAQPage 중복 이슈로 인한 코드임
93
+ template.description = template.description.replaceAll(
94
+ '&lt;div itemscope="" itemtype="https://schema.org/FAQPage"&gt;',
95
+ '&lt;div&gt;'
96
+ );
97
+
98
+ return template;
99
+ }
100
+
101
+ return template;
102
+ };
103
+
104
+ useEffect(() => {
105
+ if (template) {
106
+ // 초기화
107
+ setIsFaqActive(false);
108
+
109
+ for (const data of template) {
110
+ // console.log("faq 활성화: ", data['active_faq']);
111
+ if (data['active_faq']) {
112
+ setIsFaqActive(true);
113
+ }
114
+ }
115
+ }
116
+ }, [template]);
117
+
118
+ return (
119
+ <div
120
+ itemScope={handleFaqItemScope(isFaqActive, faqElementMaxCountInContents as number)}
121
+ itemType={handleFaqItemType(isFaqActive, faqElementMaxCountInContents as number)}
122
+ ref={printRef}
123
+ >
124
+ <div id={'sub_contents'}>
125
+ <div className="relative m-auto mb-[60px] w-[90%] max-w-screen-2xl max-xs:mb-[30px]">
126
+ <div
127
+ className={
128
+ 'm-auto mt-[100px] flex gap-[120px] lg:mt-[5em] ' +
129
+ //1700px
130
+ 'max-5xl:gap-[80px] ' +
131
+ //1500px
132
+ 'max-3xl:gap-10 ' +
133
+ //1280px
134
+ 'max-xl:mt-0 max-xl:flex-col max-xl:gap-0 ' +
135
+ //600px
136
+ 'max-sm:mt-[10px] '
137
+ }
138
+ >
139
+ <div>
140
+ {template && width < 1280 ? (
141
+ <PdfPrintCopyLink
142
+ fileName={template.filter(t => t.tag === 'h1')[0].tag_title}
143
+ printRef={printRef}
144
+ />
145
+ ) : null}
146
+ <div className={'max-xl:mt-[25px] max-xs:mt-[15px]'}>
147
+ {/* h1 제목 */}
148
+ <h1
149
+ className={
150
+ 'text-[52.5px] font-[800] tracking-[-2.1px] text-[#285FA7] max-3xl:text-5xl max-md:text-4xl max-xs:text-[28px]'
151
+ }
152
+ >
153
+ {h1Title}
154
+ </h1>
155
+
156
+ {/* h1 설명글 */}
157
+ <div
158
+ className={
159
+ 'mb-[54px] mt-[16px] whitespace-break-spaces text-[16px] font-normal tracking-[-0.96px] xs:text-[18px] sm:mb-[62px] sm:mt-[26px] sm:text-[20px] lg:mb-[75px] lg:mt-[37.5px] lg:text-[24px]'
160
+ }
161
+ >
162
+ <div
163
+ id={'ck-content'}
164
+ dangerouslySetInnerHTML={{
165
+ __html: htmlUrlDecode(
166
+ h1Description.replace('../../UploadFile', '/SE2/upload') as string
167
+ )
168
+ }}
169
+ />
170
+ </div>
171
+ </div>
172
+
173
+ <article>
174
+ {/*목차*/}
175
+ <ContentList
176
+ template={template}
177
+ h2List={h2List ? h2List : []}
178
+ onScrollToElement={handleScrollToElement}
179
+ />
180
+
181
+ {/*h2*/}
182
+ {h2List &&
183
+ h2List.map((h2Template, index) => {
184
+ return (
185
+ <section
186
+ className={'mt-[52px] sm:mt-[62px] lg:mt-[75px]'}
187
+ key={'h2영역' + h2Template.idx}
188
+ >
189
+ <H2Contents
190
+ h2Template={convertFaqItemType(h2Template)}
191
+ index={index}
192
+ faqCount={h2Template?.faqCount}
193
+ />
194
+
195
+ {/*h3*/}
196
+ {template
197
+ .filter(t => t.parent === h2Template.idx)
198
+ .map((h3Template, h3Index) => {
199
+ const refer_is_use = h3Template.reference_is_use;
200
+ const refer_length = referenceLinkList.length;
201
+ const refer_content_length = referenceLinkList.filter(
202
+ i => i.tag_idx === h3Template.idx
203
+ ).length;
204
+
205
+ const news_is_use = h3Template.news_is_use;
206
+ const news_length = newsLinkList.length;
207
+ const news_content_length = newsLinkList.filter(
208
+ i => i.tag_idx === h3Template.idx
209
+ ).length;
210
+
211
+ return (
212
+ <Fragment key={'h3Contents_section_' + h3Template.idx}>
213
+ <H3Contents
214
+ h3Template={convertFaqItemType(h3Template)}
215
+ faqCount={h3Template?.faqCount}
216
+ />
217
+ {(refer_is_use &&
218
+ refer_length > 0 &&
219
+ refer_content_length > 0) ||
220
+ (news_is_use &&
221
+ news_length > 0 &&
222
+ news_content_length > 0) ? (
223
+ <span
224
+ className={
225
+ 'mb-[44px] flex w-full flex-col gap-[26px] px-[10px] sm:mx-[33px] sm:mb-[50px] sm:px-[18px] lg:mb-[78px] ' +
226
+ //520px
227
+ 'max-2sm:gap-[16px]'
228
+ }
229
+ >
230
+ {refer_is_use && refer_length > 0 && (
231
+ <SeoAdditionalLink
232
+ type={'더보기'}
233
+ linkList={referenceLinkList.filter(
234
+ i => i.tag_idx === h3Template.idx
235
+ )}
236
+ />
237
+ )}
238
+ {news_is_use && news_length > 0 && (
239
+ <SeoAdditionalLink
240
+ type={'관련기사'}
241
+ linkList={newsLinkList.filter(
242
+ i => i.tag_idx === h3Template.idx
243
+ )}
244
+ />
245
+ )}
246
+ </span>
247
+ ) : (
248
+ <></>
249
+ )}
250
+ </Fragment>
251
+ );
252
+ })}
253
+ <span
254
+ className={
255
+ 'flex flex-col gap-[26px] ' +
256
+ //520px
257
+ 'max-2sm:gap-[16px]'
258
+ }
259
+ >
260
+ {h2Template.reference_is_use && referenceLinkList.length > 0 && (
261
+ <SeoAdditionalLink
262
+ type={'더보기'}
263
+ linkList={referenceLinkList.filter(
264
+ i => i.tag_idx === h2Template.idx
265
+ )}
266
+ />
267
+ )}
268
+ {h2Template.news_is_use && newsLinkList.length > 0 && (
269
+ <SeoAdditionalLink
270
+ type={'관련기사'}
271
+ linkList={newsLinkList.filter(
272
+ i => i.tag_idx === h2Template.idx
273
+ )}
274
+ />
275
+ )}
276
+ {h2Template.youtube_is_use && (
277
+ <>
278
+ {shortsLinkList.length > 0 && (
279
+ <SeoYoutube
280
+ type={'shorts'}
281
+ linkList={shortsLinkList.filter(
282
+ i => i.tag_idx === h2Template.idx
283
+ )}
284
+ />
285
+ )}
286
+ {youtubeLinkList.length > 0 && (
287
+ <SeoYoutube
288
+ type={'youtube'}
289
+ linkList={youtubeLinkList.filter(
290
+ i => i.tag_idx === h2Template.idx
291
+ )}
292
+ />
293
+ )}
294
+ </>
295
+ )}
296
+ </span>
297
+ </section>
298
+ );
299
+ })}
300
+ </article>
301
+ {width >= 1280 ? (
302
+ <div className={'flex flex-col gap-[60px] lg:mt-[60px]'}>
303
+ <LawInfoContentList
304
+ contentsList={contentsList}
305
+ template={template}
306
+ className={''}
307
+ />
308
+ <div className={'relative w-full '}>
309
+ <SeoStrength initialData={initialData} />
310
+ </div>
311
+ <SeoConsulting tel={tel} />
312
+ </div>
313
+ ) : (
314
+ <></>
315
+ )}
316
+ </div>
317
+
318
+ {(fieldData.length > 0 || successData.length > 0) && (
319
+ <span
320
+ className={
321
+ 'relative mb-[30px] mt-[30px] w-[340px] shrink-0 ' +
322
+ //1500px
323
+ 'max-3xl:mt-[10px] max-3xl:w-[300px] ' +
324
+ //1280px
325
+ 'max-xl:mt-[50px] max-xl:w-full max-xl:pt-0'
326
+ }
327
+ >
328
+ <span
329
+ id={'fixSideBar'}
330
+ className={
331
+ 'top-[140px] flex w-[340px] flex-col gap-[50px] xl:sticky ' +
332
+ 'max-3xl:w-[300px] max-xl:w-full'
333
+ }
334
+ >
335
+ {template && width >= 1280 ? (
336
+ <PdfPrintCopyLink
337
+ fileName={template.filter(t => t.tag === 'h1')[0].tag_title}
338
+ printRef={printRef}
339
+ />
340
+ ) : null}
341
+ {successData.length > 0 && <SuccessCase successData={successData} />}
342
+ {fieldData.length > 0 && <FieldCase fieldData={fieldData} />}
343
+ </span>
344
+ </span>
345
+ )}
346
+ </div>
347
+ </div>
348
+ <div className="m-auto mt-[0em] max-w-screen-2xl max-md2:mt-[0] max-xs:mb-[30px] lg:mt-[5em] ">
349
+ <div className="m-auto max-4xl:w-[90%]">
350
+ {width < 1280 ? (
351
+ <>
352
+ <div className="m-auto flex flex-col gap-[60px] max-4xl:w-[90%]">
353
+ <LawInfoContentList contentsList={contentsList} template={template} />
354
+ <div className={'relative w-full lg:mb-20'}>
355
+ <SeoStrength initialData={initialData} />
356
+ </div>
357
+ <SeoConsulting tel={tel} />
358
+ </div>
359
+ </>
360
+ ) : (
361
+ <></>
362
+ )}
363
+ {/* 이전글 다음글 */}
364
+ <div className="m-auto mt-[60px] max-md:mb-[30px]">
365
+ <div className={'flex flex-col items-start justify-between lg:flex-row lg:items-center'}>
366
+ <div
367
+ className={
368
+ 'mb-6 flex w-full flex-col gap-[8px] lg:mb-0 lg:w-auto lg:flex-row lg:items-center lg:gap-[20px] lg2:gap-[28px]'
369
+ }
370
+ >
371
+ <Image
372
+ src={Arrow}
373
+ alt={'화살표'}
374
+ title={'화살표'}
375
+ width={15}
376
+ height={15}
377
+ className={'m-auto hidden lg:block'}
378
+ />
379
+ <p className={'text-[18px] text-[#285FA7]'}>이전글</p>
380
+ {prevPost ? (
381
+ <Link href={prevPost ? prevPost.pathname + String(prevPost.idx) : '#'}>
382
+ <p
383
+ className={
384
+ 'w-full truncate text-[16px] xs:text-[18px] lg:w-[14em] lg2:w-[18em] xxl:w-[18em] xxl:text-[20px] 5xl:w-[20em] '
385
+ }
386
+ >
387
+ {prevPost.title}
388
+ </p>
389
+ </Link>
390
+ ) : (
391
+ <p
392
+ className={
393
+ 'truncate text-[16px] xs:text-[18px] lg:w-[14em] lg2:w-[18em] xxl:w-[18em] xxl:text-[20px] 5xl:w-[20em] '
394
+ }
395
+ >
396
+ 이전글이 없습니다.
397
+ </p>
398
+ )}
399
+ </div>
400
+
401
+ <Link href={'/info'} className={'hidden lg:block'}>
402
+ <button
403
+ className={
404
+ 'rounded-[30px] border-[1px] border-solid border-[#b0b0b0] bg-[#41464C] px-[40px] py-[10px] text-[#fff] xxl:px-[70px] xxl:py-[15px]'
405
+ }
406
+ >
407
+ 목록보기
408
+ </button>
409
+ </Link>
410
+
411
+ <div
412
+ className={
413
+ 'flex w-full flex-col justify-end gap-[8px] lg:w-auto lg:flex-row lg:items-center lg:gap-[20px] lg2:gap-[28px]'
414
+ }
415
+ >
416
+ <p className={'text-[18px] text-[#285FA7]'}>다음글</p>
417
+ {nextPost ? (
418
+ <Link href={nextPost ? nextPost.pathname + String(nextPost.idx) : '#'}>
419
+ <p
420
+ className={
421
+ 'w-full truncate text-[16px] xs:text-[18px] lg:w-[14em] lg2:w-[18em] xxl:w-[18em] xxl:text-[20px] 5xl:w-[20em] '
422
+ }
423
+ >
424
+ {nextPost.title}
425
+ </p>
426
+ </Link>
427
+ ) : (
428
+ <p
429
+ className={
430
+ 'truncate text-[16px] xs:text-[18px] lg:w-[14em] lg2:w-[18em] xxl:w-[18em] xxl:text-[20px] 5xl:w-[20em]'
431
+ }
432
+ >
433
+ 다음글이 없습니다.
434
+ </p>
435
+ )}
436
+ <Image
437
+ src={RightArrow}
438
+ alt={'화살표'}
439
+ title={'화살표'}
440
+ width={15}
441
+ height={15}
442
+ className={'m-auto hidden lg:block'}
443
+ />
444
+ </div>
445
+ </div>
446
+ </div>
447
+ </div>
448
+ </div>
449
+ </div>
450
+ </div>
451
+ );
452
+ };
453
+
454
+ export default Blog;
@@ -0,0 +1,29 @@
1
+ import { IInitialDataTypes } from '../../common';
2
+ import { ISeoTemplateTypes, IContentsListTypes, IFieldTypes, IAddLinkTypes, ISuccessTypes } from '../SuccessNew/SuccessNewType';
3
+ export interface IBlogPageTypes {
4
+ data: IBlogTypes;
5
+ tel: string;
6
+ }
7
+ export interface IBlogTypes {
8
+ template: ISeoTemplateTypes[];
9
+ h2List: ISeoTemplateTypes[] | null;
10
+ contentsList: IContentsListTypes[] | null;
11
+ prevPost: {
12
+ idx: number;
13
+ title: string;
14
+ pathname: string;
15
+ } | null;
16
+ nextPost: {
17
+ idx: number;
18
+ title: string;
19
+ pathname: string;
20
+ } | null;
21
+ fieldData: IFieldTypes[];
22
+ successData: ISuccessTypes[];
23
+ referenceLinkList: IAddLinkTypes[];
24
+ newsLinkList: IAddLinkTypes[];
25
+ shortsLinkList: IAddLinkTypes[];
26
+ youtubeLinkList: IAddLinkTypes[];
27
+ initialData: IInitialDataTypes;
28
+ faqElementMaxCountInContents?: number;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import { IInitialDataTypes } from '../../common';
2
+ import {
3
+ ISeoTemplateTypes,
4
+ IContentsListTypes,
5
+ ILawyerTypes,
6
+ IFieldTypes,
7
+ IAddLinkTypes,
8
+ ISuccessTypes
9
+ } from '../SuccessNew/SuccessNewType';
10
+
11
+ export interface IBlogPageTypes {
12
+ data: IBlogTypes;
13
+ tel: string;
14
+ }
15
+ export interface IBlogTypes {
16
+ template: ISeoTemplateTypes[];
17
+ h2List: ISeoTemplateTypes[] | null;
18
+ contentsList: IContentsListTypes[] | null;
19
+ prevPost: { idx: number; title: string; pathname: string } | null;
20
+ nextPost: { idx: number; title: string; pathname: string } | null;
21
+ fieldData: IFieldTypes[];
22
+ successData: ISuccessTypes[];
23
+ referenceLinkList: IAddLinkTypes[];
24
+ newsLinkList: IAddLinkTypes[];
25
+ shortsLinkList: IAddLinkTypes[];
26
+ youtubeLinkList: IAddLinkTypes[];
27
+ initialData: IInitialDataTypes;
28
+ faqElementMaxCountInContents?: number;
29
+ }
@@ -0,0 +1,3 @@
1
+ import { IBlogPageTypes } from './BlogTypes';
2
+ declare const BlogView: ({ data, tel }: IBlogPageTypes) => import("react").JSX.Element;
3
+ export default BlogView;