Mapache icon indicating copy to clipboard operation
Mapache copied to clipboard

Load Prism from CDN

Open tstoco opened this issue 3 years ago • 2 comments

Is it possible to load prism from a CDN?

I have used the code injection and it seems that at least the style gets overwritten. However when I start to add plugins the things start to break.

image

The example above is when I try to load the plugin match braces.

Also, line numbers do not work.

Thanks for the amazing job with the theme.

tstoco avatar Apr 16 '21 14:04 tstoco

Hi @tstoco

To use Prismjs from a CDN.

Replace this line of code with this.

var sitePrismJscomponents = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/components/';

https://github.com/godofredoninja/Mapache/blob/495ce6a29f7cbe6cb0adf84443913a4920089566/default.hbs#L74

godofredoninja avatar Apr 19 '21 18:04 godofredoninja

hi @godofredoninja,

Thanks for the update.

However, I decided to completely remove the lines below from default.hbs:

var sitePrismJs = '{{asset "scripts/prismjs.js"}}';
var sitePrismJscomponents = '/assets/scripts/components/';

And use the code injection functionally from ghost to get it to work.


Let's say that I want to load just a few modules :

  • Auto Loader ;
  • Toolbar ;
  • Line Numbers ;
  • Show Language ;
  • Copy to Clipboard ;

How would I achieve that?

Declaring multiple sitePrismJscomponents like :

var sitePrismJs = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/components/prism-core.min.js' ;
var sitePrismJscomponents = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/plugins/prism-autoloader.min.js' ;
...

Also, we should account that we need to load stylesheets for certain modules like line-numbers, toolbar ...

tstoco avatar May 18 '21 20:05 tstoco