saberland / saber

()==[:::::::::::::> Build static sites in Vue.js, without the hassle
https://saber.egoist.dev
MIT License
2.15k stars 113 forks source link

Feature: import code snippet with a Vue component #83

Open egoist opened 5 years ago

egoist commented 5 years ago

Issuehunt badges

Feature request

What problem does this feature solve?

Import code snippet in Vue template, which means it works in Markdown page, Vue page or even HTML page and Pug page, it just works everywhere

What does the proposed API look like?

Simply use the Vue component:

<import-snippet path="./sample-code.js" highlightLines="[1,3]" />

How should this be implemented in your opinion?

Use a custom vue-template-compiler module to transform:

<import-snippet path="./sample-code.js" highlightLines="[1,3]" />

to:

<import-snippet 
  :content="require('!import-snippet-loader?{highlightLines:[1,3]}!./sample-code.js')" 
/>

import-snippet-loader is webpack loader which uses saber-markdown to transform the code into <pre><code></code></pre> and returns it.

Are you willing to work on this yourself?

Yes

There is a $60.00 open bounty on this issue. Add more on Issuehunt.

IssueHuntBot commented 5 years ago

@issuehunt has funded $60.00 to this issue.