@kompasid/lit-web-components 0.6.8 → 0.7.1
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.
- package/demo/index.html +34 -0
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.d.ts +4 -0
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js +54 -16
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js.map +1 -1
- package/dist/src/components/kompasid-metered-wall-register/types.d.ts +2 -0
- package/dist/src/components/kompasid-metered-wall-register/types.js.map +1 -1
- package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.d.ts +39 -0
- package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +340 -0
- package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -0
- package/dist/src/components/kompasid-widget-recirculations-default/types.d.ts +27 -0
- package/dist/src/components/kompasid-widget-recirculations-default/types.js +2 -0
- package/dist/src/components/kompasid-widget-recirculations-default/types.js.map +1 -0
- package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.d.ts +28 -0
- package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js +188 -0
- package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/tailwind/tailwind.js +83 -8
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts +63 -18
- package/src/components/kompasid-metered-wall-register/types.ts +2 -0
- package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +342 -0
- package/src/components/kompasid-widget-recirculations-default/readme.md +57 -0
- package/src/components/kompasid-widget-recirculations-default/types.ts +28 -0
- package/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts +230 -0
- package/src/components/kompasid-widget-recirculations-list/readme.md +27 -0
- package/src/index.ts +2 -0
- package/tailwind/tailwind.css +80 -8
- package/tailwind/tailwind.ts +83 -8
|
@@ -66,6 +66,8 @@ export class KompasMeteredWallRegister extends LitElement {
|
|
|
66
66
|
description: '',
|
|
67
67
|
lastArticle: { title: '', description: '' },
|
|
68
68
|
},
|
|
69
|
+
ctaUrl: '',
|
|
70
|
+
ctaText: '',
|
|
69
71
|
}
|
|
70
72
|
/**
|
|
71
73
|
* Props
|
|
@@ -90,7 +92,6 @@ export class KompasMeteredWallRegister extends LitElement {
|
|
|
90
92
|
* prop tracker_page_domain untuk Page Domain
|
|
91
93
|
* prop next_param untuk page Domain
|
|
92
94
|
*/
|
|
93
|
-
|
|
94
95
|
@property({ type: Number }) countdownArticle = 0
|
|
95
96
|
@property({ type: Boolean }) defaultExpandBanner = false
|
|
96
97
|
@property({ type: Boolean }) isDesktop = false
|
|
@@ -119,19 +120,32 @@ export class KompasMeteredWallRegister extends LitElement {
|
|
|
119
120
|
prop: string,
|
|
120
121
|
mode: keyof meteredRegisterContent = 'default'
|
|
121
122
|
): string {
|
|
122
|
-
|
|
123
|
+
interface LastArticle {
|
|
124
|
+
[key: string]: string
|
|
125
|
+
}
|
|
126
|
+
interface DynamicMode {
|
|
127
|
+
lastArticle?: LastArticle
|
|
128
|
+
[key: string]: string | LastArticle | undefined
|
|
129
|
+
}
|
|
130
|
+
const dynamicMode = this.textTemplate[mode] as DynamicMode | string
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
const dynamicMode = this.textTemplate[mode]
|
|
132
|
+
let template: string = ''
|
|
126
133
|
|
|
127
|
-
if ('
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
if (typeof dynamicMode === 'object' && dynamicMode !== null) {
|
|
135
|
+
// Check if dynamicMode has a lastArticle object and if the prop exists within it
|
|
136
|
+
if (dynamicMode.lastArticle && prop in dynamicMode.lastArticle) {
|
|
137
|
+
const value = dynamicMode.lastArticle[prop]
|
|
138
|
+
if (typeof value === 'string') {
|
|
139
|
+
template = value
|
|
140
|
+
}
|
|
141
|
+
} else if (prop in dynamicMode) {
|
|
142
|
+
const value = dynamicMode[prop]
|
|
143
|
+
if (typeof value === 'string') {
|
|
144
|
+
template = value
|
|
145
|
+
}
|
|
130
146
|
}
|
|
131
|
-
template = lastArticleMode.lastArticle[prop] || ''
|
|
132
|
-
} else {
|
|
133
|
-
template = dynamicMode[prop] || ''
|
|
134
147
|
}
|
|
148
|
+
|
|
135
149
|
return template
|
|
136
150
|
}
|
|
137
151
|
|
|
@@ -216,11 +230,12 @@ export class KompasMeteredWallRegister extends LitElement {
|
|
|
216
230
|
${this.registerButtonTemplate()}
|
|
217
231
|
</div>
|
|
218
232
|
</div>
|
|
219
|
-
<div
|
|
233
|
+
<div
|
|
234
|
+
class="flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto"
|
|
235
|
+
>
|
|
220
236
|
<img
|
|
221
237
|
alt="metered-wall-register"
|
|
222
238
|
src="https://d3w4qaq4xm1ncv.cloudfront.net/paywall-asset/paywall_ilustrasi3-03_1.png"
|
|
223
|
-
class="h-40 w-40 md:w-full md:h-full"
|
|
224
239
|
/>
|
|
225
240
|
</div>
|
|
226
241
|
<button
|
|
@@ -246,15 +261,45 @@ export class KompasMeteredWallRegister extends LitElement {
|
|
|
246
261
|
*/
|
|
247
262
|
private registerButtonTemplate() {
|
|
248
263
|
return html`
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
264
|
+
<div>
|
|
265
|
+
${!this.textTemplate.ctaUrl
|
|
266
|
+
? html`<button
|
|
267
|
+
@click=${this.redirectToRegister}
|
|
268
|
+
class="bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 text-sm md:text-base"
|
|
269
|
+
>
|
|
270
|
+
Daftar Akun
|
|
271
|
+
</button>`
|
|
272
|
+
: html`<button
|
|
273
|
+
@click=${this.redirectToCTAUrl}
|
|
274
|
+
class="bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 px-5 text-sm md:text-base md:w-[165px]"
|
|
275
|
+
>
|
|
276
|
+
${this.textTemplate.ctaText}
|
|
277
|
+
</button>`}
|
|
278
|
+
</div>
|
|
255
279
|
`
|
|
256
280
|
}
|
|
257
281
|
|
|
282
|
+
/**
|
|
283
|
+
* mengarahkan ke page checkout promo
|
|
284
|
+
*/
|
|
285
|
+
private redirectToCTAUrl = (): void => {
|
|
286
|
+
const params = new URLSearchParams(window.location.href)
|
|
287
|
+
const newUrl = new URL(this.textTemplate.ctaUrl)
|
|
288
|
+
const referrer = new URLSearchParams(this.textTemplate.ctaUrl).get(
|
|
289
|
+
'referrer'
|
|
290
|
+
)
|
|
291
|
+
this.pushToDataLayer('mrw_clicked')
|
|
292
|
+
if (!referrer) {
|
|
293
|
+
newUrl.searchParams.append('referrer', params.toString())
|
|
294
|
+
window.location.href = newUrl.toString()
|
|
295
|
+
} else {
|
|
296
|
+
const currentReferrerValue = newUrl.searchParams.get('referrer')
|
|
297
|
+
const updatedReferrerValue = `${params.toString()},${currentReferrerValue}`
|
|
298
|
+
newUrl.searchParams.set('referrer', updatedReferrerValue)
|
|
299
|
+
window.location.href = newUrl.toString()
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
258
303
|
/**
|
|
259
304
|
* mengarahkan ke page register
|
|
260
305
|
*/
|
package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { html, css, LitElement } from 'lit'
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
+
import { format } from 'date-fns'
|
|
4
|
+
import { id } from 'date-fns/locale/id'
|
|
5
|
+
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
6
|
+
import { Post, Navigation } from './types.js'
|
|
7
|
+
|
|
8
|
+
@customElement('kompasid-widget-recirculations-default')
|
|
9
|
+
export class KompasWidgetRecirculationsDefault extends LitElement {
|
|
10
|
+
static styles = [
|
|
11
|
+
css`
|
|
12
|
+
:host {
|
|
13
|
+
font-family: 'PT Sans', sans-serif;
|
|
14
|
+
}
|
|
15
|
+
.chip {
|
|
16
|
+
align-items: center;
|
|
17
|
+
border-radius: 0.25rem;
|
|
18
|
+
display: flex;
|
|
19
|
+
font-family: 'PT Sans', sans-serif;
|
|
20
|
+
font-size: 0.75rem;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
height: 1.5rem;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
line-height: 1rem;
|
|
25
|
+
margin-bottom: 0.25rem;
|
|
26
|
+
padding: 0.375rem 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
TWStyles,
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Props
|
|
34
|
+
*/
|
|
35
|
+
@property({ type: Array }) posts: Post[][] = []
|
|
36
|
+
@property({ type: Object }) navigation: Navigation | undefined = undefined
|
|
37
|
+
@property({ type: String }) accessToken = ''
|
|
38
|
+
@property({ type: String }) permalinkArticle = ''
|
|
39
|
+
@property({ type: String }) userGuid = '0'
|
|
40
|
+
@property({ type: String }) slugs = ''
|
|
41
|
+
@property({ type: String }) type: 'relatedArticle' | 'otherArticle' =
|
|
42
|
+
'relatedArticle'
|
|
43
|
+
@property({ type: String }) mainCategory = ''
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Getters
|
|
47
|
+
*/
|
|
48
|
+
get navigationPermalink(): string | undefined {
|
|
49
|
+
return this.navigation?.permalink
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Fetch Data
|
|
54
|
+
*/
|
|
55
|
+
async connectedCallback() {
|
|
56
|
+
super.connectedCallback()
|
|
57
|
+
try {
|
|
58
|
+
await this.fetchAccessToken()
|
|
59
|
+
if (this.type === 'relatedArticle') {
|
|
60
|
+
await this.relatedArticles()
|
|
61
|
+
} else if (this.type === 'otherArticle') {
|
|
62
|
+
await this.otherArticles()
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
this.handleFetchError(error)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async fetchAccessToken() {
|
|
70
|
+
const response = await fetch(
|
|
71
|
+
'https://api.kompas.id/account/api/v1/login/guest',
|
|
72
|
+
{
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
email: 'anonynous.user@kompas.id',
|
|
79
|
+
}),
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const result = await response.json()
|
|
84
|
+
|
|
85
|
+
if (result?.data?.accessToken) {
|
|
86
|
+
this.accessToken = result.data.accessToken
|
|
87
|
+
} else {
|
|
88
|
+
throw new Error('Token akses tidak tersedia dalam respons')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async relatedArticles() {
|
|
93
|
+
if (!this.accessToken) {
|
|
94
|
+
throw new Error('Token akses tidak tersedia')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const kompasApiAi = 'https://ai.kompas.id/api/v1'
|
|
98
|
+
|
|
99
|
+
// Constructing parameters
|
|
100
|
+
const params = new URLSearchParams()
|
|
101
|
+
params.append('page_url', this.permalinkArticle)
|
|
102
|
+
params.append('page_type', 'read')
|
|
103
|
+
params.append('item_type', 'articles')
|
|
104
|
+
params.append('guid', this.userGuid)
|
|
105
|
+
params.append('slugs', this.slugs)
|
|
106
|
+
|
|
107
|
+
// Constructing the URL with parameters
|
|
108
|
+
const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`
|
|
109
|
+
|
|
110
|
+
const response = await fetch(endpoint, {
|
|
111
|
+
headers: {
|
|
112
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const result = await response.json()
|
|
118
|
+
|
|
119
|
+
if (result?.result) {
|
|
120
|
+
const items = result.result
|
|
121
|
+
const firstChunk = items.slice(0, 5)
|
|
122
|
+
const secondChunk = items.slice(5, 7)
|
|
123
|
+
this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]
|
|
124
|
+
console.log('related article:', this.posts)
|
|
125
|
+
} else {
|
|
126
|
+
throw new Error('Data artikel terkait tidak ditemukan')
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async otherArticles() {
|
|
131
|
+
if (!this.accessToken) {
|
|
132
|
+
throw new Error('Token akses tidak tersedia')
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1'
|
|
136
|
+
|
|
137
|
+
// Constructing the URL with parameters
|
|
138
|
+
const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`
|
|
139
|
+
|
|
140
|
+
const response = await fetch(endpoint, {
|
|
141
|
+
headers: {
|
|
142
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const result = await response.json()
|
|
148
|
+
|
|
149
|
+
if (result?.result) {
|
|
150
|
+
const items = result.result
|
|
151
|
+
const firstChunk = items.slice(0, 5)
|
|
152
|
+
const secondChunk = items.slice(5, 7)
|
|
153
|
+
this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]
|
|
154
|
+
console.log('other article:', this.posts)
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error('Data artikel lainnya tidak ditemukan')
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handleFetchError(error: unknown) {
|
|
161
|
+
const errorMessage =
|
|
162
|
+
error instanceof Error ? error.message : 'Kesalahan tidak diketahui'
|
|
163
|
+
alert(`Terjadi kesalahan: ${errorMessage}`)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Function to format date
|
|
168
|
+
*/
|
|
169
|
+
formatDate(date: string) {
|
|
170
|
+
return format(new Date(date), 'dd MMMM yyyy', { locale: id })
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Render widget components
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
private WidgetTitle() {
|
|
178
|
+
if (this.navigationPermalink) {
|
|
179
|
+
return html`
|
|
180
|
+
<a
|
|
181
|
+
href="${this.navigationPermalink}"
|
|
182
|
+
class="flex font-sans uppercase items-start mb-6 mt-8"
|
|
183
|
+
>
|
|
184
|
+
<h5
|
|
185
|
+
class="${[
|
|
186
|
+
'capitalize font-bold font-sans',
|
|
187
|
+
this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
|
|
188
|
+
].join(' ')}"
|
|
189
|
+
>
|
|
190
|
+
${this.navigation?.name}
|
|
191
|
+
</h5>
|
|
192
|
+
</a>
|
|
193
|
+
`
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return html`
|
|
197
|
+
<div class="flex font-sans uppercase items-start mb-6 mt-8">
|
|
198
|
+
<div>
|
|
199
|
+
<h5
|
|
200
|
+
class="${[
|
|
201
|
+
'capitalize font-bold font-sans',
|
|
202
|
+
this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
|
|
203
|
+
].join(' ')}"
|
|
204
|
+
>
|
|
205
|
+
${this.navigation?.name}
|
|
206
|
+
</h5>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
`
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
renderChips(post: Post) {
|
|
213
|
+
const chips = []
|
|
214
|
+
const isAnalisis = post.postTag?.some(tag => tag.slug === 'analisis')
|
|
215
|
+
const isEksklusif = post.postTag?.some(tag => tag.slug === 'eksklusif')
|
|
216
|
+
const isFreemium = post.isFreemium === true
|
|
217
|
+
|
|
218
|
+
if (isEksklusif) {
|
|
219
|
+
chips.push(
|
|
220
|
+
html`
|
|
221
|
+
<div class="flex">
|
|
222
|
+
<div class="chip bg-grey-600 text-white">
|
|
223
|
+
<img
|
|
224
|
+
src="https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg"
|
|
225
|
+
alt="Kompas Icon"
|
|
226
|
+
style="width: 16px; height: 16px; margin-right: 4px;"
|
|
227
|
+
/>
|
|
228
|
+
Eksklusif
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
`
|
|
232
|
+
)
|
|
233
|
+
} else if (isFreemium) {
|
|
234
|
+
chips.push(
|
|
235
|
+
html`
|
|
236
|
+
<div class="flex">
|
|
237
|
+
<div class="chip bg-blue-100 text-brand-1">Bebas Akses</div>
|
|
238
|
+
</div>
|
|
239
|
+
`
|
|
240
|
+
)
|
|
241
|
+
} else if (isAnalisis) {
|
|
242
|
+
chips.push(
|
|
243
|
+
html`
|
|
244
|
+
<div class="flex">
|
|
245
|
+
<div class="chip bg-orange-100 text-orange-500">Analisis</div>
|
|
246
|
+
</div>
|
|
247
|
+
`
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return chips
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
renderImage(post: Post) {
|
|
255
|
+
const { thumbnailMedium } = post.thumbnails?.sizes || {}
|
|
256
|
+
if (!thumbnailMedium) return ''
|
|
257
|
+
|
|
258
|
+
const { permalink, width, height } = thumbnailMedium
|
|
259
|
+
return html`
|
|
260
|
+
<img
|
|
261
|
+
src="${permalink}"
|
|
262
|
+
width="${width}"
|
|
263
|
+
height="${height}"
|
|
264
|
+
alt="${post.title}"
|
|
265
|
+
class="aspect-video object-cover w-full"
|
|
266
|
+
/>
|
|
267
|
+
`
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
render() {
|
|
271
|
+
return html`
|
|
272
|
+
<div class="w-full">
|
|
273
|
+
<!-- start: widget title -->
|
|
274
|
+
${this.WidgetTitle()}
|
|
275
|
+
<!-- end: widget title -->
|
|
276
|
+
|
|
277
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
|
|
278
|
+
<!-- start: left-post-loop -->
|
|
279
|
+
<div class="grid grid-cols-1 gap-6">
|
|
280
|
+
${this.posts[0]
|
|
281
|
+
? this.posts[0].map(
|
|
282
|
+
post => html`
|
|
283
|
+
<div class="w-full">
|
|
284
|
+
<div class="flex">
|
|
285
|
+
<div class="w-1/2">${this.renderImage(post)}</div>
|
|
286
|
+
<div class="flex-grow pl-4 w-1/2">
|
|
287
|
+
<a href="${post.permalink}">
|
|
288
|
+
${this.renderChips(post)}
|
|
289
|
+
<h5
|
|
290
|
+
class="hover:underline font-bold font-sans leading-tight text-grey-600"
|
|
291
|
+
>
|
|
292
|
+
${post.title}
|
|
293
|
+
</h5>
|
|
294
|
+
<p class="text-grey-600 pt-2">
|
|
295
|
+
${this.formatDate(post.publishedDate)}
|
|
296
|
+
</p>
|
|
297
|
+
</a>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
`
|
|
302
|
+
)
|
|
303
|
+
: 'Belum ada artikel'}
|
|
304
|
+
</div>
|
|
305
|
+
<!-- end: left-post-loop -->
|
|
306
|
+
|
|
307
|
+
<!-- start: right-post-loop -->
|
|
308
|
+
<div class="flex flex-col w-full">
|
|
309
|
+
${this.posts[1]
|
|
310
|
+
? this.posts[1].map(
|
|
311
|
+
post => html`
|
|
312
|
+
<div class="mb-6">
|
|
313
|
+
<div class="flex">
|
|
314
|
+
<div class="w-1/2">${this.renderImage(post)}</div>
|
|
315
|
+
<div class="flex-grow pl-4 w-1/2">
|
|
316
|
+
<a href="${post.permalink}">
|
|
317
|
+
${this.renderChips(post)}
|
|
318
|
+
<h5
|
|
319
|
+
class="hover:underline font-bold font-sans leading-tight text-grey-600"
|
|
320
|
+
>
|
|
321
|
+
${post.title}
|
|
322
|
+
</h5>
|
|
323
|
+
<p class="text-grey-600 pt-2">
|
|
324
|
+
${this.formatDate(post.publishedDate)}
|
|
325
|
+
</p>
|
|
326
|
+
</a>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
`
|
|
331
|
+
)
|
|
332
|
+
: ''}
|
|
333
|
+
<!-- start: ads -->
|
|
334
|
+
<slot></slot>
|
|
335
|
+
<!-- end: ads -->
|
|
336
|
+
</div>
|
|
337
|
+
<!-- end: right-post-loop -->
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
`
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# kompasid-widget-recirculations-list
|
|
2
|
+
|
|
3
|
+
Komponen ini adalah komponen web berbasis LitElement yang digunakan untuk menampilkan daftar aliran artikel dari Kompas.id.
|
|
4
|
+
|
|
5
|
+
### Contoh Implementasi
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
const widgetRelatedPost = {
|
|
9
|
+
navigation: {
|
|
10
|
+
name: 'Artikel Terkait',
|
|
11
|
+
permalink: undefined
|
|
12
|
+
},
|
|
13
|
+
permalinkArticle: 'https://www.kompas.id/baca/opini/2024/05/02/pesan-bung-karno-jaga-persatuan-dan-keutuhan?open_from=Section_Artikel_Lainnya',
|
|
14
|
+
slugs: 'persatuan,bung-karno, surat pembaca, eduard lukman, bharoto, wira hardiprakoso, vision'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const widgetOtherPost = {
|
|
18
|
+
navigation: {
|
|
19
|
+
name: 'Lainnya Dalam Opini',
|
|
20
|
+
permalink: '/kategori/opini'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
<div>
|
|
25
|
+
<kompasid-widget-recirculations-default
|
|
26
|
+
.navigation=${widgetRelatedPost.navigation}
|
|
27
|
+
.permalinkArticle=${widgetRelatedPost.permalinkArticle}
|
|
28
|
+
.slugs=${widgetRelatedPost.slugs}
|
|
29
|
+
></kompasid-widget-recirculations-default>
|
|
30
|
+
|
|
31
|
+
<kompasid-widget-recirculations-default
|
|
32
|
+
.navigation=${widgetOtherPost.navigation}
|
|
33
|
+
type='otherArticle'
|
|
34
|
+
mainCategory='opini'
|
|
35
|
+
></kompasid-widget-recirculations-default>
|
|
36
|
+
</div>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Properti
|
|
40
|
+
|
|
41
|
+
| Property | Attribute | Deskripsi | Tipe | Default | Konten |
|
|
42
|
+
| ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | -------- | --------------- | ------------------------------------------- |
|
|
43
|
+
| `navigation` | `navigation` | Navigasi yang berisi nama dan tautan ke kategori atau halaman terkait. Mengecek value `name` dan `permalink` | `Object` | `undefined` | `Navigation` |
|
|
44
|
+
| `userGuid` | `userGuid` | GUID pengguna yang sedang menggunakan aplikasi untuk fetch data artikel terkait. | `String` | `'0'` | |
|
|
45
|
+
| `slugs` | `slugs` | Daftar slug kategori atau tag yang terkait dengan artikel untuk artikel terkait. | `String` | `''` | |
|
|
46
|
+
| `permalinkArticle` | `permalinkArticle` | Tautan kategori artikel yang sedang ditampilkan atau dibaca untuk rekomendasi artikel terkait. | `String` | `''` | |
|
|
47
|
+
| `type` | `type` | Tipe widget untuk membedakan antara pengambilan data artikel terkait (`relatedArticle`) atau lainnya dalam kategori (`otherArticle`). | `String` | `'relatedArticle'` | `"relatedArticle" \| "otherArticle"` |
|
|
48
|
+
| `mainCategory` | `mainCategory` | Kategori utama artikel yang akan ditampilkan jika menggunakan tipe `otherArticle` untuk lainnya dalam kategori. | `String` | `''` | |
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Digunakan oleh
|
|
52
|
+
|
|
53
|
+
- [kompasid-widget-recirculations-default](../kompasid-widget-recirculations-default)
|
|
54
|
+
|
|
55
|
+
## Kontributor
|
|
56
|
+
|
|
57
|
+
*Dokumentasi ini dibuat oleh tim front-end Kompas.id.*
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface PostTag {
|
|
2
|
+
slug: string
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface Post {
|
|
6
|
+
title: string
|
|
7
|
+
isAnalisis?: boolean
|
|
8
|
+
isEksklusif?: boolean
|
|
9
|
+
isFreemium?: boolean
|
|
10
|
+
featuredImageThumbnailMedium: string
|
|
11
|
+
permalink: string
|
|
12
|
+
publishedDate: string
|
|
13
|
+
postTag?: PostTag[]
|
|
14
|
+
thumbnails: {
|
|
15
|
+
sizes: {
|
|
16
|
+
thumbnailMedium: {
|
|
17
|
+
permalink: string
|
|
18
|
+
width: number
|
|
19
|
+
height: number
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Navigation {
|
|
26
|
+
name: string
|
|
27
|
+
permalink: string
|
|
28
|
+
}
|