Skip to content

Commit

Permalink
fixed the bug for html pages incorrect paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehran7kl committed Aug 30, 2024
1 parent 713515a commit 362ad43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@

function getPath(file)
{
const base = window.location.href.replace("/index.html","/");
return base+file;
}
function putLink(file,title,description){

const con = document.querySelector("#code-links")
con.innerHTML+=`
<article class="code-link">
<h3><a href="./${file}">${title}</a></h3>
<h3><a href="${getPath(file)}">${title}</a></h3>
<h4>${description}</h4>
</article>
`
}

htmlFiles.forEach(file=>{
const doc = document.createElement("html")
fetch(`./${file}`)
fetch(`${getPath(file)}`)
.then(res=>res.text())
.then(text=>{
doc.innerHTML=text;
Expand Down
5 changes: 3 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { defineConfig } from "vite";
import { glob } from "glob";
export default defineConfig(()=>{

const g = glob.sync(__dirname+"/*.html");
let pattern=__dirname+"/*.html";
pattern=pattern.replace("//","/").replace("\\/","/");
const g = glob.sync(pattern);



Expand Down

0 comments on commit 362ad43

Please sign in to comment.