File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -276,10 +276,28 @@ async function renderProblem() {
276276 ! f . name . includes ( '.shortest.' )
277277 ) ;
278278
279- // Check if has HTML - if so, redirect to GitHub raw content
279+ // Check if has HTML - if so, embed it in an iframe
280280 if ( htmlFiles . length > 0 ) {
281281 const rawUrl = `https://raw.githubusercontent.com/${ getRepoPath ( ) } /main/${ pathStr } /${ htmlFiles [ 0 ] . name } ` ;
282- window . location . href = rawUrl ;
282+ const problemName = state . currentPath [ state . currentPath . length - 1 ] ;
283+ const title = problemName . replace ( / - / g, ' ' ) . replace ( / \b \w / g, c => c . toUpperCase ( ) ) ;
284+ const subtitle = state . currentPath . slice ( 0 , - 1 ) . map ( capitalize ) . join ( ' / ' ) ;
285+ const githubFileUrl = `https://github.com/${ getRepoPath ( ) } /blob/main/${ pathStr } /${ htmlFiles [ 0 ] . name } ` ;
286+
287+ view . innerHTML = `
288+ <div class="problem-header">
289+ <div class="problem-nav">
290+ <button onclick="window.goBack()" class="nav-link nav-button">← Back</button>
291+ <a href="#" class="nav-link">🏠 Home</a>
292+ <a href="${ githubFileUrl } " target="_blank" class="nav-link">📂 GitHub File</a>
293+ </div>
294+ <h1 class="problem-title">${ title } </h1>
295+ <p class="problem-subtitle">${ subtitle } </p>
296+ </div>
297+ <div style="width: 100%; height: calc(100vh - 200px); border: 1px solid #ddd; border-radius: 8px; overflow: hidden;">
298+ <iframe src="${ rawUrl } " style="width: 100%; height: 100%; border: none;" sandbox="allow-scripts allow-same-origin"></iframe>
299+ </div>
300+ ` ;
283301 return ;
284302 }
285303
You can’t perform that action at this time.
0 commit comments