Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Prism from CDN #161

Open
tstoco opened this issue Apr 16, 2021 · 2 comments
Open

Load Prism from CDN #161

tstoco opened this issue Apr 16, 2021 · 2 comments

Comments

@tstoco
Copy link

tstoco commented Apr 16, 2021

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.

@godofredoninja
Copy link
Owner

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/';

var sitePrismJscomponents = '/assets/scripts/components/';

@tstoco
Copy link
Author

tstoco commented May 18, 2021

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 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants