Skip to content

Commit 4c1bebb

Browse files
committed
bugfix abs markdown in linux
1 parent 0c062c0 commit 4c1bebb

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.astro
12
dist
23
.structure/
34
public/menu.json

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@google/model-viewer": "^3.4.0",
1515
"@svgdotjs/svg.js": "^3.1.2",
1616
"astro": "^4.5.10",
17-
"content-structure": "^1.1.8",
17+
"content-structure": "^1.1.10",
1818
"cookie-parser": "^1.4.6",
1919
"cors": "^2.8.5",
2020
"datatables.net-dt": "^1.13.7",

src/pages/assets/[...path].js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createReadStream } from 'fs';
22
import {resolve,join} from 'path'
33
import { config } from "@/config";
44
import {load_json_abs} from '@/libs/utils.js'
5-
import {file_mime} from '@/libs/assets.js'
5+
import {exists, file_mime} from '@/libs/assets.js'
66
import {remove_base} from '@/libs/assets.js'
77

88
export async function GET({params}){
@@ -14,7 +14,16 @@ export async function GET({params}){
1414
imagePath = resolve(join(config.rootdir,"public",params.path));
1515
}
1616
imagePath = remove_base(imagePath)
17-
console.log(`assets> serving '${imagePath}'`)
17+
//due to a markdown limitation, abs assets are stripped of starting '/' in linux
18+
//workaround : if the file does not exist, then try the public
19+
if(! await exists(imagePath)){
20+
imagePath = resolve(join(config.rootdir,"public",params.path));
21+
}
22+
if(! await exists(imagePath)){
23+
console.log(`\nassets> * NOT FOUND ${params.path}`)
24+
}else{
25+
console.log(`\nassets> serving '${imagePath}'`)
26+
}
1827
try {
1928
const stream = createReadStream(imagePath);
2029
const contentType = file_mime(imagePath)

0 commit comments

Comments
 (0)