Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/Pages/Overview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ const Overview = () => {
if (response.ok) {
markdown = await response.text();
if (/<!doctype\s+html\b|<html(?=[\s>/])/i.test(markdown)) {
console.warn(
`Localized documentation returned HTML instead of markdown: /docs/${currentLanguage}/${fileName}`
);
throw new Error("Got HTML instead of markdown");
}
} else {
throw new Error("Localized file not found");
}
} catch (error) {
console.warn(
`Failed to load localized documentation (/docs/${currentLanguage}/${fileName}); falling back to default documentation.`,
error
);
response = await fetch(`/docs/${fileName}`);
if (!response.ok) {
throw new Error("Documentation file not found");
Expand Down Expand Up @@ -143,7 +150,7 @@ const Overview = () => {
) : (
<ReactMarkdown
components={{
a: ({ node, href, children, ...props }) => {
a: ({ href, children, ...props }) => {
let isGitHubLink = false;
const getNodeText = (value) => {
if (typeof value === "string" || typeof value === "number") {
Expand All @@ -161,10 +168,11 @@ const Overview = () => {

if (href) {
try {
const parsedUrl = new URL(href, window.location.origin);
const parsedUrl = new URL(href, window.location.href);
const host = parsedUrl.hostname.toLowerCase();
isGitHubLink = host === "github.com" || host.endsWith(".github.com");
} catch (error) {
console.warn("Failed to parse markdown link URL in Overview:", href, error);
isGitHubLink = false;
}
}
Expand Down
Loading
Loading