File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1909,8 +1909,16 @@ export let processWithStringPreview = async (s: Script, infoBlock: string) => {
19091909 processedPreview = `<div/>`
19101910 } else {
19111911 try {
1912- let content = await readFile ( path . resolve ( path . dirname ( s . filePath ) , s ?. preview as string ) , 'utf-8' )
1913- processedPreview = infoBlock ? md ( infoBlock ) : `` + md ( content )
1912+ const val = String ( s ?. preview || '' ) . trim ( )
1913+ // If the preview looks like inline HTML, return it directly
1914+ if ( val . startsWith ( '<' ) ) {
1915+ processedPreview = ( infoBlock ? md ( infoBlock ) : `` ) + val
1916+ } else {
1917+ // Treat string as a relative doc path next to the script
1918+ const docPath = path . resolve ( path . dirname ( s . filePath ) , val )
1919+ const content = await readFile ( docPath , 'utf-8' )
1920+ processedPreview = ( infoBlock ? md ( infoBlock ) : `` ) + md ( content )
1921+ }
19141922 } catch ( error ) {
19151923 processedPreview = `Error: ${ error . message } `
19161924 }
You can’t perform that action at this time.
0 commit comments