Skip to content

Commit

Permalink
bugfix abs markdown in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wassfila committed Dec 8, 2024
1 parent 0c062c0 commit 4c1bebb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.astro
dist
.structure/
public/menu.json
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@google/model-viewer": "^3.4.0",
"@svgdotjs/svg.js": "^3.1.2",
"astro": "^4.5.10",
"content-structure": "^1.1.8",
"content-structure": "^1.1.10",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"datatables.net-dt": "^1.13.7",
Expand Down
13 changes: 11 additions & 2 deletions src/pages/assets/[...path].js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createReadStream } from 'fs';
import {resolve,join} from 'path'
import { config } from "@/config";
import {load_json_abs} from '@/libs/utils.js'
import {file_mime} from '@/libs/assets.js'
import {exists, file_mime} from '@/libs/assets.js'
import {remove_base} from '@/libs/assets.js'

export async function GET({params}){
Expand All @@ -14,7 +14,16 @@ export async function GET({params}){
imagePath = resolve(join(config.rootdir,"public",params.path));
}
imagePath = remove_base(imagePath)
console.log(`assets> serving '${imagePath}'`)
//due to a markdown limitation, abs assets are stripped of starting '/' in linux
//workaround : if the file does not exist, then try the public
if(! await exists(imagePath)){
imagePath = resolve(join(config.rootdir,"public",params.path));
}
if(! await exists(imagePath)){
console.log(`\nassets> * NOT FOUND ${params.path}`)
}else{
console.log(`\nassets> serving '${imagePath}'`)
}
try {
const stream = createReadStream(imagePath);
const contentType = file_mime(imagePath)
Expand Down

0 comments on commit 4c1bebb

Please sign in to comment.