@@ -39,44 +39,69 @@ <h1>Recent Commits</h1>
3939 }
4040
4141 commits . forEach ( commit => {
42- const commitUrl = ` https://codeberg.org/${ repo . full_name } /commit/${ commit . Sha1 } ` ;
42+ const commitUrl = " https://codeberg.org/" + repo . full_name + " /commit/" + commit . Sha1 ;
4343 const message = commit . Message || "" ;
4444
45- // Always use the first line as title
46- const [ rawTitle , ... rest ] = message . split ( / \r ? \n + / ) ;
47- const title = rawTitle . trim ( ) ;
48- const body = rest . length > 0 ? rest [ 0 ] . trim ( ) : "" ;
45+ // First line is title, rest is body
46+ const lines = message . split ( / \r ? \n + / ) ;
47+ const title = lines [ 0 ] . trim ( ) ;
48+ const body = lines . length > 1 ? lines [ 1 ] . trim ( ) : "" ;
4949
50+ // Create table and elements manually
5051 const table = document . createElement ( "table" ) ;
5152 table . className = "commit-table" ;
5253
53- table . innerHTML = `
54- <tr>
55- <td>
56- <img src="${ user . avatar_url } " alt="avatar" />
57- <h3>
58- <a href="${ user . html_url } " target="_blank">
59- ${ user . full_name || user . login }
60- </a>
61- </h3>
62- </td>
63- <td>
64- <h2>${ repo . full_name } </h2>
65- <hr />
66- <h4>
67- <a href="${ commitUrl } " class="commit-title" target="_blank">
68- ${ title }
69- </a>
70- </h4>
71- ${ body ? `<p>${ body } </p>` : "" }
72- <div>
73- <a href="${ commitUrl } " class="commit-date-button" target="_blank">
74- ${ new Date ( commit . Timestamp || entry . created ) . toLocaleString ( ) }
75- </a>
76- </div>
77- </td>
78- </tr>
79- ` ;
54+ const tr = document . createElement ( "tr" ) ;
55+
56+ const tdUser = document . createElement ( "td" ) ;
57+ const img = document . createElement ( "img" ) ;
58+ img . src = user . avatar_url ;
59+ img . alt = "avatar" ;
60+ tdUser . appendChild ( img ) ;
61+
62+ const h3 = document . createElement ( "h3" ) ;
63+ const aUser = document . createElement ( "a" ) ;
64+ aUser . href = user . html_url ;
65+ aUser . target = "_blank" ;
66+ aUser . textContent = user . full_name || user . login ;
67+ h3 . appendChild ( aUser ) ;
68+ tdUser . appendChild ( h3 ) ;
69+
70+ const tdRepo = document . createElement ( "td" ) ;
71+ const h2 = document . createElement ( "h2" ) ;
72+ h2 . textContent = repo . full_name ;
73+ tdRepo . appendChild ( h2 ) ;
74+
75+ const hr = document . createElement ( "hr" ) ;
76+ tdRepo . appendChild ( hr ) ;
77+
78+ const h4 = document . createElement ( "h4" ) ;
79+ const aCommit = document . createElement ( "a" ) ;
80+ aCommit . href = commitUrl ;
81+ aCommit . className = "commit-title" ;
82+ aCommit . target = "_blank" ;
83+ aCommit . textContent = title ;
84+ h4 . appendChild ( aCommit ) ;
85+ tdRepo . appendChild ( h4 ) ;
86+
87+ if ( body ) {
88+ const p = document . createElement ( "p" ) ;
89+ p . textContent = body ;
90+ tdRepo . appendChild ( p ) ;
91+ }
92+
93+ const div = document . createElement ( "div" ) ;
94+ const aDate = document . createElement ( "a" ) ;
95+ aDate . href = commitUrl ;
96+ aDate . className = "commit-date-button" ;
97+ aDate . target = "_blank" ;
98+ aDate . textContent = new Date ( commit . Timestamp || entry . created ) . toLocaleString ( ) ;
99+ div . appendChild ( aDate ) ;
100+ tdRepo . appendChild ( div ) ;
101+
102+ tr . appendChild ( tdUser ) ;
103+ tr . appendChild ( tdRepo ) ;
104+ table . appendChild ( tr ) ;
80105 container . appendChild ( table ) ;
81106 } ) ;
82107 } ) ;
0 commit comments