[gatsby-theme-minimal-blog] : How to add a new language to be highlighted in code-blocks?
See original GitHub issueThank you for this great work and excellent theme.
Summary
I would like to use additional language support for syntax highlighting , for example HashiCorp Language (hcl) and Powershell… both of which are supported in prismjs., however I am not sure how could i bring this highlight support into my deployment.
Steps that I performed so far.
- Shadowed the file
code.ts
tomy-site/src/@lekoarts/gatsby-theme-minimal-blog/styles/code.ts
and added the following section
"pre[class~='language-hcl']:before": {
content: `'hcl'`,
background: `#f7df1e`,
color: `black`,
},
},
I could notice the HCL text appear on the codeblock however I see no highlighting/coloring of the syntax
- I also attempted to shadow the file
my-site/src/@lekoarts/gatsby-theme-minimal-blog/types.d.ts
and added the languageshcl
andpowershell
export type Language =
| "markup"
| "bash"
.
.
.
| "yaml"
| "hcl"
| "powershell"
I do not notice any effect from the above when i run gatsby develop
- Attempted to shadow src/@lekoarts/gatsby-theme-minimal-blog/components/code.tsx and copied the content from
node_modules
however I recieve error when gatsby develop as i suspect.tsx
shadow is not well taken by gatsby
Please advise a procedure on how to achieve this, I am not a developer by nature so more information/step-by-step (referral links) would help.
Relevant information
Theme
gatsby-theme-minimal-blog
Environment (if relevant)
System:
OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (1) x64 Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 14.15.3 - ~/.nvm/versions/node/v14.15.3/bin/node
npm: 6.14.9 - ~/.nvm/versions/node/v14.15.3/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
gatsby: ^2.25.3 => 2.29.3
gatsby-plugin-google-analytics: ^2.4.1 => 2.8.0
gatsby-plugin-google-fonts: ^1.0.1 => 1.0.1
gatsby-plugin-manifest: ^2.5.2 => 2.9.1
gatsby-plugin-netlify: ^2.4.0 => 2.8.0
gatsby-plugin-offline: ^3.3.3 => 3.7.1
gatsby-plugin-sitemap: ^2.5.1 => 2.9.0
gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.13 => 1.1.18
npmGlobalPackages:
gatsby-cli: 2.16.2
File contents (no particular changes)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
lekoarts/gatsby-theme-minimal-blog
Typography driven, feature-rich blogging theme with minimal aesthetics. Includes tags/categories support and extensive features for code blocks such as live ...
Read more >Custom Code Blocks with MDX & Gatsby | Anna Rossetti
In this comprehensive tutorial you'll learn how to enhance your MDX & Gatsby blog with custom code snippets.
Read more >5 ways to improve your Gatsby code blocks - Emma Goto
In this post I'll be covering some of the ways you can improve the code blocks on your Gatsby blog. Use syntax highlighting...
Read more >How To Use Themes in Gatsby - DigitalOcean
This plugin bundles multiple features, such as MDX support and code highlighting, into one convenient package. Throughout the tutorial, you will ...
Read more >Code snippets with syntax highlighting in Gatsby blog
Language support Prism.js ... As mentioned before, you can change the syntax highlighting by adding ´´´javascript ... to your code block. See a ......
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
@gitkalz
You can also add the following snippet to gatsby-browser.js
The solution from @hurricanehrndz works for me, but if I try to add another language, suddenly my site doesn’t load anymore. I have no idea why this is, but how could I add more than one language?
This is what I tried