Browse Source

bug-fixes

Nostr-Signature: f4a5e0d3e2aa7d0d99803f26008ab68e40551e36362bb6d04acf639c5b78d959 573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc 59da9e59a6fb5648f4c889e0045b571e0d2d66a555100d60dec373455309a640bea89e4bb3a42a0e502aa4d2091e4b698203721e79b346ff30e6b2bcdc5f48b3
main
Silberengel 2 weeks ago
parent
commit
e831e1f5b9
  1. 41
      src/routes/repos/[npub]/[repo]/components/DocsTab.svelte

41
src/routes/repos/[npub]/[repo]/components/DocsTab.svelte

@ -65,6 +65,13 @@ @@ -65,6 +65,13 @@
}
});
// Ensure README is always selected by default if available
$effect(() => {
if (hasReadme && !selectedDoc) {
selectedDoc = 'README.md';
}
});
async function loadDocumentation() {
loading = true;
loadingDocs = true;
@ -78,7 +85,8 @@ @@ -78,7 +85,8 @@
try {
logger.operation('Loading documentation', { npub, repo, branch: currentBranch });
// Load README FIRST and display immediately
// ALWAYS load README FIRST and display immediately if available
// README is standard documentation and should always be shown
try {
const readmeResponse = await fetch(`/api/repos/${npub}/${repo}/readme?ref=${currentBranch || 'HEAD'}`);
if (readmeResponse.ok) {
@ -96,7 +104,7 @@ @@ -96,7 +104,7 @@
logger.debug({ error: readmeErr, npub, repo }, 'No README found');
}
// Now check for docs folder in the background
// Now check for docs folder in the background (but don't replace README)
try {
const response = await fetch(`/api/repos/${npub}/${repo}/files?action=tree&ref=${currentBranch || 'HEAD'}&path=docs`);
if (response.ok) {
@ -121,6 +129,7 @@ @@ -121,6 +129,7 @@
}
// Load Nostr documentation events (kind 30818, 30041, 30817, 30023)
// These are additional docs, but README should still be shown if available
await loadNostrDocumentation();
} catch (err) {
@ -165,6 +174,30 @@ @@ -165,6 +174,30 @@
}
} catch (err) {
logger.warn({ error: err, path }, 'Failed to load doc file');
// If loading a doc file fails and we have a README, fall back to README
if (hasReadme) {
await loadReadme();
}
}
}
// Helper function to reload README
async function loadReadme() {
try {
const readmeResponse = await fetch(`/api/repos/${npub}/${repo}/readme?ref=${currentBranch || 'HEAD'}`);
if (readmeResponse.ok) {
const readmeData = await readmeResponse.json();
if (readmeData.content) {
documentationContent = readmeData.content;
documentationKind = readmeData.type || 'markdown';
selectedDoc = 'README.md';
documentationTitle = null;
indexEvent = null;
logger.debug({ npub, repo }, 'README reloaded');
}
}
} catch (readmeErr) {
logger.debug({ error: readmeErr, npub, repo }, 'Failed to reload README');
}
}
@ -305,7 +338,7 @@ @@ -305,7 +338,7 @@
// Clear any Nostr doc state first
documentationTitle = null;
indexEvent = null;
loadDocumentation();
loadReadme();
}}
>
README.md
@ -342,7 +375,7 @@ @@ -342,7 +375,7 @@
</li>
{/each}
{/if}
{#if !hasReadme && docFiles.length === 0 && nostrDocs.length === 0}
{#if !hasReadme && docFiles.length === 0 && nostrDocs.length === 0 && !indexEvent}
<div class="empty-sidebar">
<p>No documentation files found</p>
</div>

Loading…
Cancel
Save