Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to allow setting base when starting a slide deck with slidev #2005

Open
branaway opened this issue Jan 11, 2025 · 2 comments
Open

to allow setting base when starting a slide deck with slidev #2005

branaway opened this issue Jan 11, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@branaway
Copy link

Is your feature request related to a problem? Please describe.

slidev slides.html does not take a base parameter, like the build does. Sometimes I need an extra path segment for easier routing behind a proxy.

Describe the solution you'd like
A clear and concise description of what you want to happen.

take a base parameter like the build command does.

@branaway branaway added the enhancement New feature or request label Jan 11, 2025
@jmuchovej
Copy link

so, poking around the @slidev/client – it seems that the issue is that base isn't getting prepended to the __ENTRY__ value in @slidev/client/index.html. i'm not entirely sure how to modify the code in @slidev/cli/setups/indexHtml.ts to get this to work though.

export default function setupIndexHtml({ mode, entry, clientRoot, userRoot, roots, data }: Omit<ResolvedSlidevOptions, 'utils'>): string {
let main = readFileSync(join(clientRoot, 'index.html'), 'utf-8')
let head = ''
let body = ''
const { info, author, keywords } = data.headmatter
head += [
`<meta name="slidev:version" content="${version}">`,
mode === 'dev' && `<meta charset="slidev:entry" content="${slash(entry)}">`,
`<link rel="icon" href="${data.config.favicon}">`,
`<title>${getSlideTitle(data)}</title>`,
info && `<meta name="description" content=${toAttrValue(info)}>`,
author && `<meta name="author" content=${toAttrValue(author)}>`,
keywords && `<meta name="keywords" content=${toAttrValue(Array.isArray(keywords) ? keywords.join(', ') : keywords)}>`,
].filter(Boolean).join('\n')
for (const root of roots) {
const path = join(root, 'index.html')
if (!existsSync(path))
continue
const index = readFileSync(path, 'utf-8')
if (root === userRoot && index.includes('<!DOCTYPE')) {
console.error(yellow(`[Slidev] Ignored provided index.html with doctype declaration. (${white(path)})`))
console.error(yellow('This file may be generated by Slidev, please remove it from your project.'))
continue
}
head += `\n${(index.match(/<head>([\s\S]*?)<\/head>/i)?.[1] || '').trim()}`
body += `\n${(index.match(/<body>([\s\S]*?)<\/body>/i)?.[1] || '').trim()}`
}
if (data.features.tweet)
body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>'
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== 'none')
head += `\n<link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`
if (data.headmatter.lang)
main = main.replace('<html lang="en">', `<html lang="${data.headmatter.lang}">`)
main = main
.replace('__ENTRY__', toAtFS(join(clientRoot, 'main.ts')))
.replace('<!-- head -->', head)
.replace('<!-- body -->', body)
return main
}

@branaway
Copy link
Author

There are lots of places in the code that assumes the whole app runs on root instead of one a url path. It requires reworking in multiple places including external plugins, as far as I can see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants