slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
32.82k stars 1.33k forks source link

request image on public, always returns html #1859

Closed zillionare closed 3 weeks ago

zillionare commented 3 weeks ago

Describe the bug

I placed an image at public folder, then request it from *.md:

![](/sample.jpg)

Got nothing. check teh network pane, found it returns a html file. Request the url directly by input in at address bar, got:

图片

this is the screen which *.md should read.

Minimal reproduction

Totally no idea how to reproduce, please give me some tips to reproduce.

this is how I start slidev:

my slides (*.md) is at /tmp/pages, slidev is installed at /tmp/slidev, and I have multiple local themes there:

图片

图片

this is how I launch slidev:

npx slidev /tmp/pages/01.md -t /tmp/slidev/themes/landscape-jade --remote

I don't know why, but the vite.config.ts used is the one under /tmp/slidev/themes/landscape-jade, rather than the one under /tmp/slidev. And this is how vite.config.ts looks like:

import MdItAdmon from 'markdown-it-admon';
import { full as emoji } from 'markdown-it-emoji';
import { resolve } from 'path';
import { defineConfig } from 'vite';

console.log(`public dir is ${resolve(__dirname, '../../public')}`)
export default defineConfig({
    server: {
        fs: {
            strict: false
        }
    },
    public: resolve(__dirname, '../public'),
    slidev: {
        vue: {
            /* vue options */
            template: {
                compilerOptions: {
                    whitespace: 'preserve'
                }
            }
        },
        markdown: {
            /* markdown-it options */
            markdownItSetup(md) {
                /* custom markdown-it plugins */
                // md.use(require('markdown-it-admon'));
                // md.use(require('markdown-it-container'), 'takeaway');
                md.use(emoji);
                md.use(MdItAdmon);
            },
        },
    }
})

Since I have print out the public dir, I'm pretty sure that I have placed the right image under public dir.

You can use https://sli.dev/new to create a new project to reproduce the issue.

Environment

zillionare commented 3 weeks ago

wrong key: 'public', should be 'publicDir'