-
when I run |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hmmm, I don't know how to get this data. How about importing |
Beta Was this translation helpful? Give feedback.
-
ok thanks! I assume it is not a major feature that most users need so I won't clog things up with an open issue, but I'll see if I can hack something together and make a PR. |
Beta Was this translation helpful? Give feedback.
-
thanks to a comment by @JoeyGrajciar I figured this out. In import { definePreparserSetup } from '@slidev/types'
export default definePreparserSetup(({ filepath, headmatter, mode }) => {
return [
{
transformRawLines(lines) {
// if front matter exists then insert at the top
// assumes you correctly ended the front matter with '---'
if (lines[0] === '---') {
lines.splice(1, 0, `filename: ${filepath}`)
} else {
// otherwise add frontmatter to first slide containing the file path
lines.unshift(`---`)
lines.unshift(`filename: ${filepath}`)
lines.unshift(`---`)
}
},
},
]
}) Then in your slide or vue component you can access via |
Beta Was this translation helpful? Give feedback.
Here is an updated solution. The above works but when you open the slide editor in the browser and edit something it writes the entire content of the transformed lines back out to the file. The previous code was re-inserting the file name multiple times so instead this checks if the filename property exists first before adding it, or otherwise updates it.
The net effect is you could define
filename:
yourself in the front matter but it will be overwritten at launch time with the path to the file