@@ -9,7 +9,7 @@ import { formatDate, formatDateShort } from './utils.js';
99import { trackEvent } from './analytics.js' ;
1010
1111async function init ( ) {
12- const params = new URLSearchParams ( window . location . search ) ;
12+ const params = new URLSearchParams ( window . location . search ) ;
1313 const postPath = params . get ( 'post' ) ;
1414
1515 if ( postPath ) {
@@ -36,11 +36,6 @@ async function initListingView() {
3636 try {
3737 const manifest = await fetchCached ( config . blog_manifest ) ;
3838 renderListing ( manifest . posts || [ ] , document . getElementById ( 'posts-list' ) ) ;
39- // Track post clicks from listing
40- document . getElementById ( 'posts-list' ) ?. addEventListener ( 'click' , e => {
41- const row = e . target . closest ( '[data-track]' ) ;
42- if ( row ) trackEvent ( 'post_read' , row . dataset . track ) ;
43- } ) ;
4439 } catch ( err ) {
4540 console . error ( err ) ;
4641 document . getElementById ( 'posts-list' ) . innerHTML =
@@ -72,8 +67,7 @@ function renderListing(posts, container) {
7267 <div class="group-label">— ${ cat } —</div>
7368 <div class="project-group-items">
7469 ${ items . map ( p => `
75- <a class="blog-row" href="/writing?post=${ encodeURIComponent ( p . path ) } "
76- data-track="${ p . title } ">
70+ <a class="blog-row" href="/writing?post=${ encodeURIComponent ( p . path ) } ">
7771 <span class="blog-title">${ p . title } </span>
7872 <span class="blog-meta">
7973 <span class="blog-cat">[ ${ cat } ]</span>
@@ -101,11 +95,11 @@ async function initPostView(postPath) {
10195 fetchTextCached ( config . blog_base_url + postPath )
10296 ] ) ;
10397
104- const posts = manifest . posts || [ ] ;
105- const meta = posts . find ( p => p . path === postPath ) ;
106- const idx = posts . findIndex ( p => p . path === postPath ) ;
107- const prevPost = idx < posts . length - 1 ? posts [ idx + 1 ] : null ;
108- const nextPost = idx > 0 ? posts [ idx - 1 ] : null ;
98+ const posts = manifest . posts || [ ] ;
99+ const meta = posts . find ( p => p . path === postPath ) ;
100+ const idx = posts . findIndex ( p => p . path === postPath ) ;
101+ const prevPost = idx < posts . length - 1 ? posts [ idx + 1 ] : null ;
102+ const nextPost = idx > 0 ? posts [ idx - 1 ] : null ;
109103
110104 document . title = meta ? `jebin2 — ${ meta . title } ` : 'jebin2 — writing' ;
111105 if ( meta ?. title ) trackEvent ( 'post_read' , meta . title ) ;
@@ -118,7 +112,7 @@ async function initPostView(postPath) {
118112}
119113
120114function renderPost ( mdText , meta , prevPost , nextPost , container ) {
121- const cat = meta ? getCategory ( meta . path ) : '' ;
115+ const cat = meta ? getCategory ( meta . path ) : '' ;
122116 // Rewrite relative links/images to absolute raw GitHub URLs
123117 const baseUrl = meta
124118 ? `https://raw.githubusercontent.com/jebin2/blog/main/${ getPostDir ( meta . path ) } /`
@@ -144,13 +138,13 @@ function renderPost(mdText, meta, prevPost, nextPost, container) {
144138 <nav class="post-nav">
145139 <div>
146140 ${ prevPost
147- ? `<a href="?post=${ encodeURIComponent ( prevPost . path ) } ">← ${ prevPost . title } </a>`
148- : '' }
141+ ? `<a href="?post=${ encodeURIComponent ( prevPost . path ) } ">← ${ prevPost . title } </a>`
142+ : '' }
149143 </div>
150144 <div>
151145 ${ nextPost
152- ? `<a href="?post=${ encodeURIComponent ( nextPost . path ) } ">${ nextPost . title } →</a>`
153- : '' }
146+ ? `<a href="?post=${ encodeURIComponent ( nextPost . path ) } ">${ nextPost . title } →</a>`
147+ : '' }
154148 </div>
155149 </nav>
156150 ` ;
0 commit comments