@@ -8,19 +8,18 @@ import { roadmaps, type RoadmapProps } from '@libs/datum';
88const issues = await roadmaps ();
99---
1010
11- <div class =" roadmap-container" >
12- {
13- issues &&
14- Array .prototype .map .call (issues , (issue : RoadmapProps ) => () => (
15- <div class = " roadmap-card" >
16- <div class = " roadmap-card--content" >
17- <div class = " roadmap-card--vote-section" />
18-
19- <div class = " roadmap-card--info-section" >
20- <div class = " roadmap-card--text-content" >
21- <h3 class = " roadmap-card--title" >{ issue .title } </h3 >
22- <div
23- class = " roadmap-card--description"
11+ {
12+ issues &&
13+ Array .prototype .map .call (issues , (issue : RoadmapProps ) => () => (
14+ <div class = " roadmap-card" >
15+ <div class = " roadmap-card--content" >
16+ <div class = " roadmap-card--vote-section" />
17+
18+ <div class = " roadmap-card--info-section" >
19+ <div class = " roadmap-card--text-content" >
20+ <h3 class = " roadmap-card--title" >{ issue .title } </h3 >
21+ <div class = " roadmap-card--description" >
22+ <p
2423 set :html = { stripTags (removeHeaderTags (marked .parse (issue .body ))).then ((text ) =>
2524 truncate (text , 200 )
2625 )}
@@ -42,61 +41,61 @@ const issues = await roadmaps();
4241 </div >
4342 </div >
4443 </div >
45- ))
46- }
47-
48- < script >
49- import { actions } from 'astro:actions';
50- import { getCookie, setCookie } from '@libs/cookie ';
51-
52- const voteItems = document.querySelectorAll('.roadmap-card--content');
53- let userId = getCookie('userId') as string ;
54-
55- voteItems.forEach((item) => {
56- const btnVote = item.querySelector('.roadmap-card--vote-button');
57-
58- btnVote?.addEventListener('click', async function (this: HTMLButtonElement) {
59- if (! this.dataset.issueid ) {
60- throw new Error('ProjectID is missing');
61- }
62-
63- if (!userId) {
64- actions.loginWithDatum().then((result: { data?: object }) => {
65- if (!result.data) {
66- return;
67- }
68-
69- const data = result.data as { authUrl: string; codeVerifier: string; nonce: string };
70- const authUrl = new URL(data. authUrl) ;
71- const codeVerifier = data.codeVerifier ;
72- const nonce = data.nonce ;
73-
74- if (!authUrl) {
75- window.location.href = '/resources/roadmap';
76- } else {
77- setCookie('codeVerifier', codeVerifier ?? '', 60 * 24);
78- setCookie('nonce ', nonce ?? '', 60 * 24);
79- setCookie('auth_redirect ', window.location.href , 60 * 24);
80-
81- window.location.href = authUrl.toString();
82- }
83- });
84- }
85-
86- const issueId = this.dataset.issueid;
87- const issueHasVoted = this.dataset.hasVoted === 'true' ;
88- let isSuccess ;
89-
90- if (issueHasVoted) {
91- isSuccess = await actions.unvote({ userId, issueId });
92- } else {
93- isSuccess = await actions.vote({ userId, issueId });
94- }
95-
96- if (isSuccess) {
97- window.location.reload();
98- }
99- });
44+ </ div >
45+ ))
46+ }
47+
48+ < script >
49+ import { actions } from 'astro:actions ';
50+ import { getCookie, setCookie } from '@libs/cookie';
51+
52+ const voteItems = document.querySelectorAll('.roadmap-card--content') ;
53+ let userId = getCookie('userId') as string;
54+
55+ voteItems.forEach((item) => {
56+ const btnVote = item.querySelector('.roadmap-card--vote-button');
57+
58+ btnVote?.addEventListener('click', async function ( this: HTMLButtonElement ) {
59+ if (!this.dataset.issueid) {
60+ throw new Error('ProjectID is missing');
61+ }
62+
63+ if (!userId) {
64+ actions.loginWithDatum().then((result: { data?: object }) => {
65+ if (!result.data) {
66+ return;
67+ }
68+
69+ const data = result.data as { authUrl: string; codeVerifier: string; nonce: string } ;
70+ const authUrl = new URL( data.authUrl) ;
71+ const codeVerifier = data.codeVerifier ;
72+ const nonce = data.nonce;
73+
74+ if (!authUrl) {
75+ window.location.href = '/resources/roadmap';
76+ } else {
77+ setCookie('codeVerifier ', codeVerifier ?? '', 60 * 24);
78+ setCookie('nonce ', nonce ?? '' , 60 * 24);
79+ setCookie('auth_redirect', window.location.href, 60 * 24);
80+
81+ window.location.href = authUrl.toString();
82+ }
83+ });
84+ }
85+
86+ const issueId = this.dataset.issueid ;
87+ const issueHasVoted = this.dataset.hasVoted === 'true' ;
88+ let isSuccess;
89+
90+ if (issueHasVoted) {
91+ isSuccess = await actions.unvote({ userId, issueId });
92+ } else {
93+ isSuccess = await actions.vote({ userId, issueId });
94+ }
95+
96+ if (isSuccess) {
97+ window.location.reload();
98+ }
10099 });
101- </ script >
102- </div >
100+ });
101+ </script >
0 commit comments