vuepress-plugin-live icon indicating copy to clipboard operation
vuepress-plugin-live copied to clipboard

Missing code and/or documentation when using custom layout

Open AustinGil opened this issue 2 years ago • 2 comments

Something in a recent version changed and broke how the custom layouts work. I've found the problem and wanted to document the solution here:

First, one of the critical steps for prismjs to work is to have a .language- class present on the page. In the default layout, there is .language.vue. When providing a custom layout, I think the editor slot should have that, but it does not. So the solution I found is to wrap the editor slot with a div with the class language-vue. This allows prismjs styles to be applied.

Secondly, it looks like the inclusion of critical assets has been changed. The prism theme and prism editor CSS are no longer included by default when you provide a custom layout. I looked at the default layout Vue file to find my solution which was to include those assets in my custom layout

<script>
import "prismjs/themes/prism-okaidia.css";
import "vue-prism-editor/dist/prismeditor.min.css";
</script>

If I get the chance, I'll see about opening a PR for this. In the meantime, I wanted to document these issues here in case others run into them and need a solution.

For the fix, does it make more sense to fix the issue in the code, or was this a deliberate design? If so, then I can just add more documentation around it.

AustinGil avatar Jan 16 '22 16:01 AustinGil

Thank you Austin for the report.

Did you check what version made that change?

PS: I am happy to see you are still using vue-live. I have left it alone for way too long. Working on fixing that.

elevatebart avatar Jan 16 '22 17:01 elevatebart

Yeah, well it's gotten me this far :)

I hope you dont feel any pressure for my sake to work on this. I just worked through it and thought it'd be good to document it.

I'm sorry, but I'm not sure what version broke. It was a long time since I had upgraded.

AustinGil avatar Jan 18 '22 00:01 AustinGil