Skip to content

Commit

Permalink
Code Quality
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy committed Dec 13, 2024
1 parent 885fc0f commit 4de6995
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 6 additions & 5 deletions scripts/post-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function checkBrokenLinks() {
console.error(`\n[ERROR] In file: ${file}`);
loggedFile = true;
}

hasIssue = true;
console.error(`[ERROR] ${issue}`);
}
Expand All @@ -73,7 +73,6 @@ async function checkBrokenLinks() {
}

if (href.startsWith('/')) {

href = href.split('#')[0];

let exists = false;
Expand Down Expand Up @@ -126,9 +125,11 @@ async function checkBrokenLinks() {

if (broken.length > 0) {
console.error('\n=============================================');
console.error("\n[ERROR] Broken links found.");
console.error("[ERROR] Possible issues include dead links, redirected links, or external links that should be local.");
console.error("[ERROR] Check the above logs for more in-depth details");
console.error('\n[ERROR] Broken links found.');
console.error(
'[ERROR] Possible issues include dead links, redirected links, or external links that should be local.'
);
console.error('[ERROR] Check the above logs for more in-depth details');
console.error("[ERROR] Here's the list: \n");
for (const link of broken) {
console.error(`[ERROR] Broken link: ${link}`);
Expand Down
10 changes: 8 additions & 2 deletions src/components/RenderDoc.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { getEntry } from 'astro:content';
import type { CollectionKey } from 'astro:content';
import { PageHeadings } from '@components/PageHeadings.tsx';
import Sidebar from '@components/Sidebar/index.astro';
import { findNextPage, findPreviousPage, generateBreadcrumb, generateSidebar } from '@src/util/doc';
import {
findNextPage,
findPreviousPage,
generateBreadcrumb,
generateSidebar,
} from '@src/util/doc';
import { Icon } from 'astro-icon/components';
import BaseLayout from './layout/BaseLayout.astro';
import MarkdownContainer from './shared/MarkdownContainer.astro';
Expand Down Expand Up @@ -32,7 +37,8 @@ const { Content, headings } = await entry.render();
const sidebarItems = await generateSidebar(collection);
const sidebarIndex = sidebarItems.flat.findIndex((item) => item.slug === slug);
const prev = findPreviousPage(sidebarItems.flat, sidebarIndex);
const next = findNextPage(sidebarItems.flat, sidebarIndex) ?? sidebarItems.flat[0];
const next =
findNextPage(sidebarItems.flat, sidebarIndex) ?? sidebarItems.flat[0];
function filteredHeadings() {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/util/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@ export function findNextPage(items: Item[], index: number): Item | undefined {
return item;
}
}
}
}

0 comments on commit 4de6995

Please sign in to comment.