Skip to content

Commit 0e37fab

Browse files
committed
fix(docs): use relative paths for CSS and JS assets in generated HTML
- Calculate correct relative paths based on file depth - Fix styling issues on sub-pages by using proper asset paths - Ensure CSS and JavaScript load correctly on all documentation pages - Support nested directory structures with appropriate path calculations
1 parent f9306df commit 0e37fab

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

docs/scripts/build-docs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ function convertMarkdownToHtml(markdownPath, outputPath) {
2121
mkdirSync(outputDir, { recursive: true });
2222
}
2323

24+
// Calculate relative path to build root for assets
25+
const relativePath = relative(outputDir, join(process.cwd(), 'build'));
26+
const assetPrefix = relativePath === '' ? '.' : relativePath;
27+
2428
// Create HTML page with proper structure
2529
const fullHtml = `<!DOCTYPE html>
2630
<html lang="en">
2731
<head>
2832
<meta charset="utf-8">
2933
<meta name="viewport" content="width=device-width, initial-scale=1">
3034
<title>Rhema Documentation</title>
31-
<link rel="stylesheet" href="/_app/immutable/assets/0.CUkH5Dtm.css">
32-
<script type="module" data-sveltekit-hydrate="1" src="/_app/immutable/entry/start.Dh5_5E8I.js"></script>
35+
<link rel="stylesheet" href="${assetPrefix}/_app/immutable/assets/0.CUkH5Dtm.css">
36+
<script type="module" data-sveltekit-hydrate="1" src="${assetPrefix}/_app/immutable/entry/start.Dh5_5E8I.js"></script>
3337
</head>
3438
<body data-sveltekit-preload-data="hover">
3539
<div style="display: contents">

0 commit comments

Comments
 (0)