@kompasid/lit-web-components 0.6.8 → 0.7.0
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-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 +45 -0
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- 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 +42 -0
- package/tailwind/tailwind.ts +45 -0
package/demo/index.html
CHANGED
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
|
|
46
46
|
<script type="module">
|
|
47
47
|
import { html, render } from 'lit'
|
|
48
|
+
import '../dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js'
|
|
49
|
+
import '../dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js'
|
|
48
50
|
import '../dist/src/components/kompasid-footer/KompasFooter.js'
|
|
49
51
|
import '../dist/src/components/kompasid-paywall/KompasPaywall.js'
|
|
50
52
|
import '../dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js'
|
|
@@ -108,6 +110,22 @@
|
|
|
108
110
|
updateMembership: 'Perbarui Langganan',
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
const widgetRelatedPost = {
|
|
114
|
+
navigation: {
|
|
115
|
+
name: 'Artikel Terkait',
|
|
116
|
+
permalink: undefined
|
|
117
|
+
},
|
|
118
|
+
permalinkArticle: 'https://www.kompas.id/baca/opini/2024/05/02/pesan-bung-karno-jaga-persatuan-dan-keutuhan?open_from=Section_Artikel_Lainnya',
|
|
119
|
+
slugs: 'persatuan,bung-karno, surat pembaca, eduard lukman, bharoto, wira hardiprakoso, vision'
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const widgetOtherPost = {
|
|
123
|
+
navigation: {
|
|
124
|
+
name: 'Lainnya Dalam Opini',
|
|
125
|
+
permalink: '/kategori/opini'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
111
129
|
render(
|
|
112
130
|
html`
|
|
113
131
|
<kompasid-header-account
|
|
@@ -122,6 +140,22 @@
|
|
|
122
140
|
.read_later_url=${readLaterUrl}
|
|
123
141
|
.total_grace_period=${totalGracePeriod}
|
|
124
142
|
></kompasid-header-account>
|
|
143
|
+
|
|
144
|
+
<kompasid-widget-recirculations-default
|
|
145
|
+
.navigation=${widgetRelatedPost.navigation}
|
|
146
|
+
.permalinkArticle=${widgetRelatedPost.permalinkArticle}
|
|
147
|
+
.slugs=${widgetRelatedPost.slugs}
|
|
148
|
+
></kompasid-widget-recirculations-default>
|
|
149
|
+
|
|
150
|
+
<kompasid-widget-recirculations-default
|
|
151
|
+
.navigation=${widgetOtherPost.navigation}
|
|
152
|
+
type='otherArticle'
|
|
153
|
+
mainCategory='opini'
|
|
154
|
+
></kompasid-widget-recirculations-default>
|
|
155
|
+
|
|
156
|
+
<kompasid-widget-recirculations-list widgetTitle="Terpopuler" apiSlug="popular-article">
|
|
157
|
+
</kompasid-widget-recirculations-list>
|
|
158
|
+
|
|
125
159
|
<kompasid-paywall
|
|
126
160
|
.type=${type}
|
|
127
161
|
.theme=${theme}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Post, Navigation } from './types.js';
|
|
3
|
+
export declare class KompasWidgetRecirculationsDefault extends LitElement {
|
|
4
|
+
static styles: import("lit").CSSResult[];
|
|
5
|
+
/**
|
|
6
|
+
* Props
|
|
7
|
+
*/
|
|
8
|
+
posts: Post[][];
|
|
9
|
+
navigation: Navigation | undefined;
|
|
10
|
+
accessToken: string;
|
|
11
|
+
permalinkArticle: string;
|
|
12
|
+
userGuid: string;
|
|
13
|
+
slugs: string;
|
|
14
|
+
type: 'relatedArticle' | 'otherArticle';
|
|
15
|
+
mainCategory: string;
|
|
16
|
+
/**
|
|
17
|
+
* Getters
|
|
18
|
+
*/
|
|
19
|
+
get navigationPermalink(): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Fetch Data
|
|
22
|
+
*/
|
|
23
|
+
connectedCallback(): Promise<void>;
|
|
24
|
+
fetchAccessToken(): Promise<void>;
|
|
25
|
+
relatedArticles(): Promise<void>;
|
|
26
|
+
otherArticles(): Promise<void>;
|
|
27
|
+
handleFetchError(error: unknown): void;
|
|
28
|
+
/**
|
|
29
|
+
* Function to format date
|
|
30
|
+
*/
|
|
31
|
+
formatDate(date: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Render widget components
|
|
34
|
+
*/
|
|
35
|
+
private WidgetTitle;
|
|
36
|
+
renderChips(post: Post): import("lit").TemplateResult<1>[];
|
|
37
|
+
renderImage(post: Post): import("lit").TemplateResult<1> | "";
|
|
38
|
+
render(): import("lit").TemplateResult<1>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { format } from 'date-fns';
|
|
5
|
+
import { id } from 'date-fns/locale/id';
|
|
6
|
+
import { TWStyles } from '../../../tailwind/tailwind.js';
|
|
7
|
+
let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault extends LitElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/**
|
|
11
|
+
* Props
|
|
12
|
+
*/
|
|
13
|
+
this.posts = [];
|
|
14
|
+
this.navigation = undefined;
|
|
15
|
+
this.accessToken = '';
|
|
16
|
+
this.permalinkArticle = '';
|
|
17
|
+
this.userGuid = '0';
|
|
18
|
+
this.slugs = '';
|
|
19
|
+
this.type = 'relatedArticle';
|
|
20
|
+
this.mainCategory = '';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Getters
|
|
24
|
+
*/
|
|
25
|
+
get navigationPermalink() {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = this.navigation) === null || _a === void 0 ? void 0 : _a.permalink;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Fetch Data
|
|
31
|
+
*/
|
|
32
|
+
async connectedCallback() {
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
try {
|
|
35
|
+
await this.fetchAccessToken();
|
|
36
|
+
if (this.type === 'relatedArticle') {
|
|
37
|
+
await this.relatedArticles();
|
|
38
|
+
}
|
|
39
|
+
else if (this.type === 'otherArticle') {
|
|
40
|
+
await this.otherArticles();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.handleFetchError(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async fetchAccessToken() {
|
|
48
|
+
var _a;
|
|
49
|
+
const response = await fetch('https://api.kompas.id/account/api/v1/login/guest', {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
},
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
email: 'anonynous.user@kompas.id',
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
const result = await response.json();
|
|
59
|
+
if ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.accessToken) {
|
|
60
|
+
this.accessToken = result.data.accessToken;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error('Token akses tidak tersedia dalam respons');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async relatedArticles() {
|
|
67
|
+
if (!this.accessToken) {
|
|
68
|
+
throw new Error('Token akses tidak tersedia');
|
|
69
|
+
}
|
|
70
|
+
const kompasApiAi = 'https://ai.kompas.id/api/v1';
|
|
71
|
+
// Constructing parameters
|
|
72
|
+
const params = new URLSearchParams();
|
|
73
|
+
params.append('page_url', this.permalinkArticle);
|
|
74
|
+
params.append('page_type', 'read');
|
|
75
|
+
params.append('item_type', 'articles');
|
|
76
|
+
params.append('guid', this.userGuid);
|
|
77
|
+
params.append('slugs', this.slugs);
|
|
78
|
+
// Constructing the URL with parameters
|
|
79
|
+
const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`;
|
|
80
|
+
const response = await fetch(endpoint, {
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const result = await response.json();
|
|
87
|
+
if (result === null || result === void 0 ? void 0 : result.result) {
|
|
88
|
+
const items = result.result;
|
|
89
|
+
const firstChunk = items.slice(0, 5);
|
|
90
|
+
const secondChunk = items.slice(5, 7);
|
|
91
|
+
this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
|
|
92
|
+
console.log('related article:', this.posts);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error('Data artikel terkait tidak ditemukan');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async otherArticles() {
|
|
99
|
+
if (!this.accessToken) {
|
|
100
|
+
throw new Error('Token akses tidak tersedia');
|
|
101
|
+
}
|
|
102
|
+
const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1';
|
|
103
|
+
// Constructing the URL with parameters
|
|
104
|
+
const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`;
|
|
105
|
+
const response = await fetch(endpoint, {
|
|
106
|
+
headers: {
|
|
107
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
const result = await response.json();
|
|
112
|
+
if (result === null || result === void 0 ? void 0 : result.result) {
|
|
113
|
+
const items = result.result;
|
|
114
|
+
const firstChunk = items.slice(0, 5);
|
|
115
|
+
const secondChunk = items.slice(5, 7);
|
|
116
|
+
this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
|
|
117
|
+
console.log('other article:', this.posts);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new Error('Data artikel lainnya tidak ditemukan');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
handleFetchError(error) {
|
|
124
|
+
const errorMessage = error instanceof Error ? error.message : 'Kesalahan tidak diketahui';
|
|
125
|
+
alert(`Terjadi kesalahan: ${errorMessage}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Function to format date
|
|
129
|
+
*/
|
|
130
|
+
formatDate(date) {
|
|
131
|
+
return format(new Date(date), 'dd MMMM yyyy', { locale: id });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Render widget components
|
|
135
|
+
*/
|
|
136
|
+
WidgetTitle() {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
if (this.navigationPermalink) {
|
|
139
|
+
return html `
|
|
140
|
+
<a
|
|
141
|
+
href="${this.navigationPermalink}"
|
|
142
|
+
class="flex font-sans uppercase items-start mb-6 mt-8"
|
|
143
|
+
>
|
|
144
|
+
<h5
|
|
145
|
+
class="${[
|
|
146
|
+
'capitalize font-bold font-sans',
|
|
147
|
+
this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
|
|
148
|
+
].join(' ')}"
|
|
149
|
+
>
|
|
150
|
+
${(_a = this.navigation) === null || _a === void 0 ? void 0 : _a.name}
|
|
151
|
+
</h5>
|
|
152
|
+
</a>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
return html `
|
|
156
|
+
<div class="flex font-sans uppercase items-start mb-6 mt-8">
|
|
157
|
+
<div>
|
|
158
|
+
<h5
|
|
159
|
+
class="${[
|
|
160
|
+
'capitalize font-bold font-sans',
|
|
161
|
+
this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
|
|
162
|
+
].join(' ')}"
|
|
163
|
+
>
|
|
164
|
+
${(_b = this.navigation) === null || _b === void 0 ? void 0 : _b.name}
|
|
165
|
+
</h5>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
renderChips(post) {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
const chips = [];
|
|
173
|
+
const isAnalisis = (_a = post.postTag) === null || _a === void 0 ? void 0 : _a.some(tag => tag.slug === 'analisis');
|
|
174
|
+
const isEksklusif = (_b = post.postTag) === null || _b === void 0 ? void 0 : _b.some(tag => tag.slug === 'eksklusif');
|
|
175
|
+
const isFreemium = post.isFreemium === true;
|
|
176
|
+
if (isEksklusif) {
|
|
177
|
+
chips.push(html `
|
|
178
|
+
<div class="flex">
|
|
179
|
+
<div class="chip bg-grey-600 text-white">
|
|
180
|
+
<img
|
|
181
|
+
src="https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg"
|
|
182
|
+
alt="Kompas Icon"
|
|
183
|
+
style="width: 16px; height: 16px; margin-right: 4px;"
|
|
184
|
+
/>
|
|
185
|
+
Eksklusif
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
`);
|
|
189
|
+
}
|
|
190
|
+
else if (isFreemium) {
|
|
191
|
+
chips.push(html `
|
|
192
|
+
<div class="flex">
|
|
193
|
+
<div class="chip bg-blue-100 text-brand-1">Bebas Akses</div>
|
|
194
|
+
</div>
|
|
195
|
+
`);
|
|
196
|
+
}
|
|
197
|
+
else if (isAnalisis) {
|
|
198
|
+
chips.push(html `
|
|
199
|
+
<div class="flex">
|
|
200
|
+
<div class="chip bg-orange-100 text-orange-500">Analisis</div>
|
|
201
|
+
</div>
|
|
202
|
+
`);
|
|
203
|
+
}
|
|
204
|
+
return chips;
|
|
205
|
+
}
|
|
206
|
+
renderImage(post) {
|
|
207
|
+
var _a;
|
|
208
|
+
const { thumbnailMedium } = ((_a = post.thumbnails) === null || _a === void 0 ? void 0 : _a.sizes) || {};
|
|
209
|
+
if (!thumbnailMedium)
|
|
210
|
+
return '';
|
|
211
|
+
const { permalink, width, height } = thumbnailMedium;
|
|
212
|
+
return html `
|
|
213
|
+
<img
|
|
214
|
+
src="${permalink}"
|
|
215
|
+
width="${width}"
|
|
216
|
+
height="${height}"
|
|
217
|
+
alt="${post.title}"
|
|
218
|
+
class="aspect-video object-cover w-full"
|
|
219
|
+
/>
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
render() {
|
|
223
|
+
return html `
|
|
224
|
+
<div class="w-full">
|
|
225
|
+
<!-- start: widget title -->
|
|
226
|
+
${this.WidgetTitle()}
|
|
227
|
+
<!-- end: widget title -->
|
|
228
|
+
|
|
229
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
|
|
230
|
+
<!-- start: left-post-loop -->
|
|
231
|
+
<div class="grid grid-cols-1 gap-6">
|
|
232
|
+
${this.posts[0]
|
|
233
|
+
? this.posts[0].map(post => html `
|
|
234
|
+
<div class="w-full">
|
|
235
|
+
<div class="flex">
|
|
236
|
+
<div class="w-1/2">${this.renderImage(post)}</div>
|
|
237
|
+
<div class="flex-grow pl-4 w-1/2">
|
|
238
|
+
<a href="${post.permalink}">
|
|
239
|
+
${this.renderChips(post)}
|
|
240
|
+
<h5
|
|
241
|
+
class="hover:underline font-bold font-sans leading-tight text-grey-600"
|
|
242
|
+
>
|
|
243
|
+
${post.title}
|
|
244
|
+
</h5>
|
|
245
|
+
<p class="text-grey-600 pt-2">
|
|
246
|
+
${this.formatDate(post.publishedDate)}
|
|
247
|
+
</p>
|
|
248
|
+
</a>
|
|
249
|
+
</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
`)
|
|
253
|
+
: 'Belum ada artikel'}
|
|
254
|
+
</div>
|
|
255
|
+
<!-- end: left-post-loop -->
|
|
256
|
+
|
|
257
|
+
<!-- start: right-post-loop -->
|
|
258
|
+
<div class="flex flex-col w-full">
|
|
259
|
+
${this.posts[1]
|
|
260
|
+
? this.posts[1].map(post => html `
|
|
261
|
+
<div class="mb-6">
|
|
262
|
+
<div class="flex">
|
|
263
|
+
<div class="w-1/2">${this.renderImage(post)}</div>
|
|
264
|
+
<div class="flex-grow pl-4 w-1/2">
|
|
265
|
+
<a href="${post.permalink}">
|
|
266
|
+
${this.renderChips(post)}
|
|
267
|
+
<h5
|
|
268
|
+
class="hover:underline font-bold font-sans leading-tight text-grey-600"
|
|
269
|
+
>
|
|
270
|
+
${post.title}
|
|
271
|
+
</h5>
|
|
272
|
+
<p class="text-grey-600 pt-2">
|
|
273
|
+
${this.formatDate(post.publishedDate)}
|
|
274
|
+
</p>
|
|
275
|
+
</a>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
`)
|
|
280
|
+
: ''}
|
|
281
|
+
<!-- start: ads -->
|
|
282
|
+
<slot></slot>
|
|
283
|
+
<!-- end: ads -->
|
|
284
|
+
</div>
|
|
285
|
+
<!-- end: right-post-loop -->
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
KompasWidgetRecirculationsDefault.styles = [
|
|
292
|
+
css `
|
|
293
|
+
:host {
|
|
294
|
+
font-family: 'PT Sans', sans-serif;
|
|
295
|
+
}
|
|
296
|
+
.chip {
|
|
297
|
+
align-items: center;
|
|
298
|
+
border-radius: 0.25rem;
|
|
299
|
+
display: flex;
|
|
300
|
+
font-family: 'PT Sans', sans-serif;
|
|
301
|
+
font-size: 0.75rem;
|
|
302
|
+
font-weight: bold;
|
|
303
|
+
height: 1.5rem;
|
|
304
|
+
justify-content: center;
|
|
305
|
+
line-height: 1rem;
|
|
306
|
+
margin-bottom: 0.25rem;
|
|
307
|
+
padding: 0.375rem 0.5rem;
|
|
308
|
+
}
|
|
309
|
+
`,
|
|
310
|
+
TWStyles,
|
|
311
|
+
];
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Array })
|
|
314
|
+
], KompasWidgetRecirculationsDefault.prototype, "posts", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: Object })
|
|
317
|
+
], KompasWidgetRecirculationsDefault.prototype, "navigation", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: String })
|
|
320
|
+
], KompasWidgetRecirculationsDefault.prototype, "accessToken", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property({ type: String })
|
|
323
|
+
], KompasWidgetRecirculationsDefault.prototype, "permalinkArticle", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ type: String })
|
|
326
|
+
], KompasWidgetRecirculationsDefault.prototype, "userGuid", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property({ type: String })
|
|
329
|
+
], KompasWidgetRecirculationsDefault.prototype, "slugs", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
property({ type: String })
|
|
332
|
+
], KompasWidgetRecirculationsDefault.prototype, "type", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
property({ type: String })
|
|
335
|
+
], KompasWidgetRecirculationsDefault.prototype, "mainCategory", void 0);
|
|
336
|
+
KompasWidgetRecirculationsDefault = __decorate([
|
|
337
|
+
customElement('kompasid-widget-recirculations-default')
|
|
338
|
+
], KompasWidgetRecirculationsDefault);
|
|
339
|
+
export { KompasWidgetRecirculationsDefault };
|
|
340
|
+
//# sourceMappingURL=KompasWidgetRecirculationsDefault.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KompasWidgetRecirculationsDefault.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAIjD,IAAM,iCAAiC,GAAvC,MAAM,iCAAkC,SAAQ,UAAU;IAA1D;;QAuBL;;WAEG;QACwB,UAAK,GAAa,EAAE,CAAA;QACnB,eAAU,GAA2B,SAAS,CAAA;QAC9C,gBAAW,GAAG,EAAE,CAAA;QAChB,qBAAgB,GAAG,EAAE,CAAA;QACrB,aAAQ,GAAG,GAAG,CAAA;QACd,UAAK,GAAG,EAAE,CAAA;QACV,SAAI,GAC9B,gBAAgB,CAAA;QACU,iBAAY,GAAG,EAAE,CAAA;IA2S/C,CAAC;IAzSC;;OAEG;IACH,IAAI,mBAAmB;;QACrB,OAAO,MAAA,IAAI,CAAC,UAAU,0CAAE,SAAS,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,KAAK,CAAC,iBAAiB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AAU,CAAC,IAAI,CAAC,aAAa,CAAC;;;;;;mBAMhD,CACF;YACH,CAAC,CAAC,EAAE;;;;;;;;KAQb,CAAA;IACH,CAAC;;AA3UM,wCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;IACD,QAAQ;CACT,CAAA;AAK0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gEAAqB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAA+C;AAC9C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2EAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DACT;AACU;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAkB;AAlClC,iCAAiC;IAD7C,aAAa,CAAC,wCAAwC,CAAC;GAC3C,iCAAiC,CA6U7C;SA7UY,iCAAiC","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { format } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { Post, Navigation } from './types.js'\n\n@customElement('kompasid-widget-recirculations-default')\nexport class KompasWidgetRecirculationsDefault extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .chip {\n align-items: center;\n border-radius: 0.25rem;\n display: flex;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.75rem;\n font-weight: bold;\n height: 1.5rem;\n justify-content: center;\n line-height: 1rem;\n margin-bottom: 0.25rem;\n padding: 0.375rem 0.5rem;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n @property({ type: Array }) posts: Post[][] = []\n @property({ type: Object }) navigation: Navigation | undefined = undefined\n @property({ type: String }) accessToken = ''\n @property({ type: String }) permalinkArticle = ''\n @property({ type: String }) userGuid = '0'\n @property({ type: String }) slugs = ''\n @property({ type: String }) type: 'relatedArticle' | 'otherArticle' =\n 'relatedArticle'\n @property({ type: String }) mainCategory = ''\n\n /**\n * Getters\n */\n get navigationPermalink(): string | undefined {\n return this.navigation?.permalink\n }\n\n /**\n * Fetch Data\n */\n async connectedCallback() {\n super.connectedCallback()\n try {\n await this.fetchAccessToken()\n if (this.type === 'relatedArticle') {\n await this.relatedArticles()\n } else if (this.type === 'otherArticle') {\n await this.otherArticles()\n }\n } catch (error) {\n this.handleFetchError(error)\n }\n }\n\n async fetchAccessToken() {\n const response = await fetch(\n 'https://api.kompas.id/account/api/v1/login/guest',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n email: 'anonynous.user@kompas.id',\n }),\n }\n )\n\n const result = await response.json()\n\n if (result?.data?.accessToken) {\n this.accessToken = result.data.accessToken\n } else {\n throw new Error('Token akses tidak tersedia dalam respons')\n }\n }\n\n async relatedArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const kompasApiAi = 'https://ai.kompas.id/api/v1'\n\n // Constructing parameters\n const params = new URLSearchParams()\n params.append('page_url', this.permalinkArticle)\n params.append('page_type', 'read')\n params.append('item_type', 'articles')\n params.append('guid', this.userGuid)\n params.append('slugs', this.slugs)\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n console.log('related article:', this.posts)\n } else {\n throw new Error('Data artikel terkait tidak ditemukan')\n }\n }\n\n async otherArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1'\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n console.log('other article:', this.posts)\n } else {\n throw new Error('Data artikel lainnya tidak ditemukan')\n }\n }\n\n handleFetchError(error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : 'Kesalahan tidak diketahui'\n alert(`Terjadi kesalahan: ${errorMessage}`)\n }\n\n /**\n * Function to format date\n */\n formatDate(date: string) {\n return format(new Date(date), 'dd MMMM yyyy', { locale: id })\n }\n\n /**\n * Render widget components\n */\n\n private WidgetTitle() {\n if (this.navigationPermalink) {\n return html`\n <a\n href=\"${this.navigationPermalink}\"\n class=\"flex font-sans uppercase items-start mb-6 mt-8\"\n >\n <h5\n class=\"${[\n 'capitalize font-bold font-sans',\n this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',\n ].join(' ')}\"\n >\n ${this.navigation?.name}\n </h5>\n </a>\n `\n }\n\n return html`\n <div class=\"flex font-sans uppercase items-start mb-6 mt-8\">\n <div>\n <h5\n class=\"${[\n 'capitalize font-bold font-sans',\n this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',\n ].join(' ')}\"\n >\n ${this.navigation?.name}\n </h5>\n </div>\n </div>\n `\n }\n\n renderChips(post: Post) {\n const chips = []\n const isAnalisis = post.postTag?.some(tag => tag.slug === 'analisis')\n const isEksklusif = post.postTag?.some(tag => tag.slug === 'eksklusif')\n const isFreemium = post.isFreemium === true\n\n if (isEksklusif) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-grey-600 text-white\">\n <img\n src=\"https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg\"\n alt=\"Kompas Icon\"\n style=\"width: 16px; height: 16px; margin-right: 4px;\"\n />\n Eksklusif\n </div>\n </div>\n `\n )\n } else if (isFreemium) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-blue-100 text-brand-1\">Bebas Akses</div>\n </div>\n `\n )\n } else if (isAnalisis) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-orange-100 text-orange-500\">Analisis</div>\n </div>\n `\n )\n }\n\n return chips\n }\n\n renderImage(post: Post) {\n const { thumbnailMedium } = post.thumbnails?.sizes || {}\n if (!thumbnailMedium) return ''\n\n const { permalink, width, height } = thumbnailMedium\n return html`\n <img\n src=\"${permalink}\"\n width=\"${width}\"\n height=\"${height}\"\n alt=\"${post.title}\"\n class=\"aspect-video object-cover w-full\"\n />\n `\n }\n\n render() {\n return html`\n <div class=\"w-full\">\n <!-- start: widget title -->\n ${this.WidgetTitle()}\n <!-- end: widget title -->\n\n <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8\">\n <!-- start: left-post-loop -->\n <div class=\"grid grid-cols-1 gap-6\">\n ${this.posts[0]\n ? this.posts[0].map(\n post => html`\n <div class=\"w-full\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-grey-600\"\n >\n ${post.title}\n </h5>\n <p class=\"text-grey-600 pt-2\">\n ${this.formatDate(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : 'Belum ada artikel'}\n </div>\n <!-- end: left-post-loop -->\n\n <!-- start: right-post-loop -->\n <div class=\"flex flex-col w-full\">\n ${this.posts[1]\n ? this.posts[1].map(\n post => html`\n <div class=\"mb-6\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-grey-600\"\n >\n ${post.title}\n </h5>\n <p class=\"text-grey-600 pt-2\">\n ${this.formatDate(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : ''}\n <!-- start: ads -->\n <slot></slot>\n <!-- end: ads -->\n </div>\n <!-- end: right-post-loop -->\n </div>\n </div>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface PostTag {
|
|
2
|
+
slug: string;
|
|
3
|
+
}
|
|
4
|
+
export interface Post {
|
|
5
|
+
title: string;
|
|
6
|
+
isAnalisis?: boolean;
|
|
7
|
+
isEksklusif?: boolean;
|
|
8
|
+
isFreemium?: boolean;
|
|
9
|
+
featuredImageThumbnailMedium: string;
|
|
10
|
+
permalink: string;
|
|
11
|
+
publishedDate: string;
|
|
12
|
+
postTag?: PostTag[];
|
|
13
|
+
thumbnails: {
|
|
14
|
+
sizes: {
|
|
15
|
+
thumbnailMedium: {
|
|
16
|
+
permalink: string;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface Navigation {
|
|
24
|
+
name: string;
|
|
25
|
+
permalink: string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-default/types.ts"],"names":[],"mappings":"","sourcesContent":["interface PostTag {\n slug: string\n}\n\nexport interface Post {\n title: string\n isAnalisis?: boolean\n isEksklusif?: boolean\n isFreemium?: boolean\n featuredImageThumbnailMedium: string\n permalink: string\n publishedDate: string\n postTag?: PostTag[]\n thumbnails: {\n sizes: {\n thumbnailMedium: {\n permalink: string\n width: number\n height: number\n }\n }\n }\n}\n\nexport interface Navigation {\n name: string\n permalink: string\n}\n"]}
|
package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
interface PostTag {
|
|
3
|
+
slug: string;
|
|
4
|
+
}
|
|
5
|
+
interface ListItem {
|
|
6
|
+
title: string;
|
|
7
|
+
isAnalisis?: boolean;
|
|
8
|
+
isEksklusif?: boolean;
|
|
9
|
+
isFreemium?: boolean;
|
|
10
|
+
permalink: string;
|
|
11
|
+
publishedDate?: string;
|
|
12
|
+
postTag?: PostTag[];
|
|
13
|
+
}
|
|
14
|
+
export declare class KompasWidgetRecirculationsList extends LitElement {
|
|
15
|
+
widgetTitle: string;
|
|
16
|
+
articleList: ListItem[];
|
|
17
|
+
accessToken: string;
|
|
18
|
+
apiSlug: string;
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
connectedCallback(): Promise<void>;
|
|
21
|
+
fetchAccessToken(): Promise<void>;
|
|
22
|
+
fetchArticles(): Promise<void>;
|
|
23
|
+
formatDate(date: string): string;
|
|
24
|
+
handleFetchError(error: unknown): void;
|
|
25
|
+
renderChips(item: ListItem): import("lit").TemplateResult<1>[];
|
|
26
|
+
render(): import("lit").TemplateResult<1>;
|
|
27
|
+
}
|
|
28
|
+
export {};
|