Skip to content

Commit c20be03

Browse files
committed
Add syntax highlighting.
1 parent 8055792 commit c20be03

File tree

6 files changed

+100
-21
lines changed

6 files changed

+100
-21
lines changed

gatsby-browser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ import(`@fontsource/source-sans-pro/${theme.fontWeight.light}.css`)
66
import(`@fontsource/source-sans-pro/${theme.fontWeight.regular}.css`)
77
import(`@fontsource/source-sans-pro/${theme.fontWeight.semiBold}.css`)
88
import(`@fontsource/source-sans-pro/${theme.fontWeight.black}.css`)
9+
10+
import(`@fontsource/source-code-pro/${theme.fontWeight.regular}.css`)
11+
import(`@fontsource/source-code-pro/${theme.fontWeight.semiBold}.css`)
12+
13+
import 'prismjs'
14+
15+
import 'prismjs/themes/prism.css'
16+
import 'prismjs/themes/prism-okaidia.css'

gatsby-config.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@ module.exports = {
1717
path: `${__dirname}/src/markdown`
1818
}
1919
},
20-
{ resolve: `gatsby-transformer-remark` },
20+
{
21+
resolve: `gatsby-transformer-remark`,
22+
options: {
23+
plugins: [
24+
{
25+
resolve: `gatsby-remark-prismjs`,
26+
options: {
27+
classPrefix: `language-`,
28+
inlineCodeMarker: null,
29+
aliases: {},
30+
showLineNumbers: false,
31+
noInlineHighlight: false,
32+
languageExtensions: [],
33+
prompt: {
34+
user: `root`,
35+
host: `localhost`,
36+
global: false
37+
},
38+
escapeEntities: {}
39+
}
40+
}
41+
]
42+
}
43+
},
2144
{
2245
resolve: `gatsby-plugin-manifest`,
2346
options: {
@@ -41,7 +64,6 @@ module.exports = {
4164
resolve: `gatsby-plugin-google-gtag`,
4265
options: {
4366
trackingIds: ['G-BVNP5VG5EZ'],
44-
// This object is used for configuration specific to this plugin
4567
pluginConfig: {
4668
head: true,
4769
respectDNT: true

package-lock.json

Lines changed: 49 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@
2424
"new-post": "ts-node ./scripts/new-post.ts"
2525
},
2626
"dependencies": {
27+
"@fontsource/source-code-pro": "^4.5.0",
2728
"@fontsource/source-sans-pro": "^4.5.0",
2829
"date-fns": "^2.23.0",
2930
"gatsby": "^3.12.0",
3031
"gatsby-plugin-google-gtag": "^3.12.0",
3132
"gatsby-plugin-manifest": "^3.12.0",
33+
"gatsby-remark-prismjs": "^5.9.0",
3234
"gatsby-source-filesystem": "^3.12.0",
3335
"gatsby-transformer-remark": "^4.9.0",
3436
"normalize.css": "^8.0.1",
37+
"prismjs": "^1.24.1",
3538
"react": "^17.0.2",
3639
"react-dom": "^17.0.2",
3740
"react-helmet": "^6.1.0",

src/components/Typography.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,25 @@ export const TextBlock = styled.div`
5858
}
5959
6060
pre {
61-
overflow-x: auto;
61+
border-radius: 0.2em;
62+
}
63+
64+
code {
65+
font-family: 'Source Code Pro', Consolas, Monaco, 'Andale Mono',
66+
'Ubuntu Mono', monospace;
67+
font-size: 0.85em;
6268
}
6369
6470
*:not(pre) > code {
65-
background-color: ${$theme.color.copyLight}22;
6671
border-radius: 0.2em;
6772
padding: 0.1em 0.5em;
73+
background-color: #27282288;
74+
}
75+
76+
blockquote {
77+
font-style: italic;
78+
margin: 1em;
79+
padding: 0 1em;
80+
border-left: ${$theme.color.copyLight} solid 2px;
6881
}
6982
`

src/markdown/code/guide-node-cli-package.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The [npm.js docs](https://docs.npmjs.com/files/package.json#bin) and popular Nod
3232

3333
Similar as other shell script, we want to make our JavaScript file executable by the locally installed node program. We do that adding a [shebang character sequence](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) at the very top of our JavaScript file that look as follow:
3434

35-
```
35+
```shell
3636
#!/usr/bin/env node
3737
```
3838

0 commit comments

Comments
 (0)