Skip to content

Commit 57716ad

Browse files
committed
Update code samples/embeds
1 parent 4caec1b commit 57716ad

10 files changed

+1881
-3410
lines changed

gatsby-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ module.exports = {
4343
resolve: "gatsby-transformer-remark",
4444
options: {
4545
plugins: [
46+
{
47+
resolve: "gatsby-remark-prismjs",
48+
options: {
49+
inlineCodeMarker: "±",
50+
},
51+
},
4652
{
4753
resolve: "gatsby-remark-images",
4854
options: {

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"gatsby-plugin-react-next": "^1.0.11",
1313
"gatsby-plugin-styled-jsx": "^2.0.6",
1414
"gatsby-remark-images": "^1.5.60",
15+
"gatsby-remark-prismjs": "^1.2.21",
1516
"gatsby-source-filesystem": "^1.5.27",
1617
"gatsby-transformer-remark": "^1.7.39",
1718
"prettier": "^1.11.1",
@@ -22,8 +23,7 @@
2223
"scripts": {
2324
"build": "gatsby build",
2425
"start": "gatsby develop",
25-
"format":
26-
"prettier './*.{js,json}' '.{babel,prettier}rc' 'src/**/*.{js,json,md}' --write ",
26+
"format": "prettier './*.{js,json}' '.{babel,prettier}rc' 'src/**/*.{js,json,md}' --write ",
2727
"test": "echo \"Error: no test specified\" && exit 1"
2828
},
2929
"devDependencies": {}

src/layouts/index.js

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react"
22
import PropTypes from "prop-types"
33
import Link from "gatsby-link"
44
import Helmet from "react-helmet"
5+
require("prismjs/themes/prism-solarizedlight.css")
56

67
const TemplateWrapper = ({ children }) => (
78
<React.Fragment>
@@ -245,20 +246,20 @@ const TemplateWrapper = ({ children }) => (
245246
line-height: 0;
246247
}
247248
248-
code,
249-
pre {
250-
font-family: var(--monospace);
251-
}
249+
// code,
250+
// pre {
251+
// font-family: var(--monospace);
252+
// }
252253
253-
pre code {
254-
background: var(--base3);
255-
border-radius: 2px;
256-
box-sizing: border-box;
257-
display: block;
258-
overflow: scroll;
259-
padding: 0.25em 0.75em;
260-
width: 100%;
261-
}
254+
// pre code {
255+
// background: var(--base3);
256+
// border-radius: 2px;
257+
// box-sizing: border-box;
258+
// display: block;
259+
// overflow: scroll;
260+
// padding: 0.25em 0.75em;
261+
// width: 100%;
262+
// }
262263
263264
.logo {
264265
align-items: center;
@@ -361,6 +362,54 @@ const TemplateWrapper = ({ children }) => (
361362
header h1 {
362363
margin-bottom: 0em;
363364
}
365+
366+
/**
367+
* Prism things:
368+
*/
369+
.gatsby-highlight-code-line {
370+
background-color: #feb;
371+
display: block;
372+
margin-right: -1em;
373+
margin-left: -1em;
374+
padding-right: 1em;
375+
padding-left: 0.75em;
376+
border-left: 0.25em solid #f99;
377+
}
378+
379+
/**
380+
* Add back the container background-color, border-radius, padding, margin
381+
* and overflow that we removed from <pre>.
382+
*/
383+
.gatsby-highlight {
384+
background-color: #fdf6e3;
385+
border-radius: 0.3em;
386+
margin: 0.5em 0;
387+
padding: 1em;
388+
overflow: auto;
389+
}
390+
391+
/**
392+
* Remove the default PrismJS theme background-color, border-radius, margin,
393+
* padding and overflow.
394+
* 1. Make the element just wide enough to fit its content.
395+
* 2. Always fill the visible space in .gatsby-highlight.
396+
*/
397+
.gatsby-highlight pre[class*="language-"] {
398+
background-color: transparent;
399+
margin: 0;
400+
padding: 0;
401+
overflow: initial;
402+
float: left; /* 1 */
403+
min-width: 100%; /* 2 */
404+
}
405+
406+
:not(pre) > code[class*="language-"] {
407+
// display: inline-block;
408+
}
409+
code[class*="language-"],
410+
pre[class*="language-"] {
411+
font-family: var(--body);
412+
}
364413
`}</style>
365414
</React.Fragment>
366415
)

src/pages/blog/2013-05-17-css-map-pins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ tags: [css]
88

99
I spend a fair amount of time trying to get this shape nailed down in CSS, so I wanted to share and save someone the time. The secret was in setting the second set of radii on the `box-shadow` property. [MDN][mdn] has a helpful visual to help wrap your mind around that lesser-known feature of box-shadow.
1010

11-
<a class="jsbin-embed" href="http://jsbin.com/bepoco/embed?output">JS Bin on jsbin.com</a><script src="http://static.jsbin.com/js/embed.min.js?3.35.9"></script>
11+
<iframe src="https://codesandbox.io/embed/k9162mxoqv?autoresize=1&hidenavigation=1&module=%2Findex.html" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
1212

1313
[mdn]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius

src/pages/blog/2013-08-01-easy-masked-file-inputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ I put together a pretty simple solution for masking yet another native HTML inpu
1010

1111
I'm just kidding. You guys are great!
1212

13-
<a class="jsbin-embed" href="http://jsbin.com/susuda/embed?output">JS Bin on jsbin.com</a><script src="http://static.jsbin.com/js/embed.min.js?3.35.9"></script>
13+
<iframe src="https://codesandbox.io/embed/8k2kjzll32?autoresize=1&hidenavigation=1&moduleview=1" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/pages/blog/2015-10-12-jekyll-and-webpack.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ I was recently setting up a Jekyll site that had the JavaScript and CSS compiled
1010

1111
```javascript
1212
var webpack = require("webpack")
13+
1314
module.exports = {
1415
plugins: [new webpack.BannerPlugin("---\n---\n\n", { raw: true })],
1516
}

src/pages/blog/2016-03-08-github-merge-button-from-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ See `git-merge-pr` below or [grab it from my dotfiles][git-merge-pr]!
1919

2020
## git-merge-pr
2121

22-
```shell
22+
```bash
2323
#!/usr/bin/env bash
2424

2525
# Contributors:

src/pages/blog/2016-03-14-recover-data-from-a-mac-without-target-disk-mode.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ I was recently trying to pull data off of an iMac for a friend, but didn't have
1010

1111
Start up your Mac in single-user mode<sup>[2](#2)</sup>, then run the following commands<sup>[3](#3)</sup>:
1212

13-
```shell
13+
```bash
1414
# Check the filesystem
15-
$ /sbin/fsck -y
15+
/sbin/fsck -y
1616

1717
# Mount the root volume
18-
$ mount -uw /
18+
mount -uw /
1919

2020
# Create mount destination
21-
$ mkdir /Volumes/backup
21+
mkdir /Volumes/backup
2222

2323
# Get a list of available drives
24-
$ df -h
24+
df -h
2525

2626
# Plug in USB backup drive, look for new drive name
27-
$ df -h
27+
df -h
2828

2929
# Mount the drive with the name you got from last step. Probably looks
3030
# something like /dev/rdisk2s2. Note the rdisk / disk name difference.
31-
$ mount -t hfs /dev/disk2s2 /Volumes/backup
31+
mount -t hfs /dev/disk2s2 /Volumes/backup
3232

3333
# rsync data to your backup
34-
$ rsync -ahz /Users/you/ /Volumes/backup/
34+
rsync -ahz /Users/you/ /Volumes/backup/
3535
```
3636

3737
<sup><a name="1">1</a></sup>Share files between two computers with target disk mode: [https://support.apple.com/en-us/HT201462][target disk mode]

src/pages/blog/2017-05-10-send-chrome-tab-to-safari-reading-list.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ tags: [apple, macos, command-line]
1111
* Name it "Add to Safari Reading List" and add a "Run AppleScript" action with the following AppleScript, and don't forget to use "Google Chrome Canary" and or "Safari Technology Preview" instead if you prefer them:
1212

1313
```applescript
14-
tell application "Google Chrome"
15-
set pageUrl to get URL of active tab of first window
16-
end tell
17-
tell application "Safari" to add reading list item pageUrl
14+
tell application "Google Chrome"
15+
set pageUrl to get URL of active tab of first window
16+
end tell
17+
tell application "Safari" to add reading list item pageUrl
1818
```
1919

2020
![](/img/send-chrome-tab-to-safari-reading-list/3.png)

0 commit comments

Comments
 (0)