Is there a way to import code from external file into a codeblock?
See original GitHub issueIs there a built in or recommended way to inline code from an external file in a codeblock for a markdown content page? I want to store a code snippet in a source file, but inline it in my markdown. Currently I’m able to load the code with the following:
<template>
<div class="nuxt-content-highlight">
<pre class="line-numbers"><code>{{code}}</code></pre>
</div>
</template>
<script>
import raw from "@/assets/code/my_code_file";
export default {
data {
return { code: raw }
}
}
</script>
which “works” and I could create a component, but it feels like I’m reinventing the wheel. I hardly found anything about external file loading in nuxt, much less for nuxt-content within markdown. Ideally I’d have a markdown file like the following:
# My markdown file ``` { include assets/code/my_code_file } ```
And nuxt-content would do the heavy lifting for me.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Add Existing Source to CodeBlocks Project - YouTube
Typing and running your first program in CodeBlocks · C++ Libraries For Beginners · Solve Any Pattern Question with This Trick! · HTML...
Read more >How to start a CodeBlocks project from external code and ...
Create the project, then: right click on the project name on the "Projects" pane; add files recursively.
Read more >Include External Object File in to Project - Code::Blocks Forums
Well, if it worked with Dev-C++, it can probably be done by going to Build options -> <your target or project> -> Linker...
Read more >Include code into code blocks from external source files ...
Is there a way to do this with a Lua or Python filter instead? Does anyone have a ready-made boxed-up filter for this...
Read more >Clear Coding with Modules and Packages in Python
To use a module in an external Python code block, we need to import that specific module into our code structure. To do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is one such example: https://github.com/nuxt/typescript/blob/master/docs/components/global/InjectCode.vue
Could be nice to add such component to the docs theme!