Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
feat(components): ✨ embed external code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Jun 4, 2020
1 parent d0cb66f commit ade24dd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions content/syntax/custom_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ Lines with `-` highlighted in red shade indicating a deletion.
+ const data = [1,2];
```

## Embed external code snippets

`embed:hello-js.js#L1`

`embed:hello.java`

## Live Editing

**Syntax**
Expand Down
6 changes: 6 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ const plugins = [
{
resolve: 'gatsby-remark-sectionize',
},
{
resolve: `gatsby-remark-embed-snippet`,
options: {
directory: `${__dirname}/snippets/`,
},
},
],
extensions: ['.mdx', '.md'],
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"gatsby-plugin-sharp": "2.6.9",
"gatsby-plugin-sitemap": "2.4.3",
"gatsby-remark-copy-linked-files": "2.3.3",
"gatsby-remark-embed-snippet": "4.3.3",
"gatsby-remark-images": "3.3.8",
"gatsby-remark-jargon": "2.6.0",
"gatsby-remark-sectionize": "1.0.0",
Expand Down
2 changes: 2 additions & 0 deletions snippets/hello-js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const hello = () => console.log("Hello World");
hello();
3 changes: 3 additions & 0 deletions snippets/hello.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public static void main(String[] args) {
System.out.println("Hello World");
}
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.10.2":
version "7.10.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.2.tgz#d103f21f2602497d38348a32e008637d506db839"
integrity sha512-6sF3uQw2ivImfVIl62RZ7MXhO2tap69WeWK57vAaimT6AZbE4FbqjdEJIN1UqoD6wI6B+1n9UiagafH1sxjOtg==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/standalone@^7.9.6":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.10.1.tgz#36057177f8d42628e97744e76ba4851fc7369045"
Expand Down Expand Up @@ -7433,6 +7440,16 @@ gatsby-remark-copy-linked-files@2.3.3:
probe-image-size "^4.1.1"
unist-util-visit "^1.4.1"

gatsby-remark-embed-snippet@4.3.3:
version "4.3.3"
resolved "https://registry.yarnpkg.com/gatsby-remark-embed-snippet/-/gatsby-remark-embed-snippet-4.3.3.tgz#f07430c8ef45f34155ae245c987fe7057573eb33"
integrity sha512-jgtaxl3ByDbTnfGqQ8XAdzzusMXw+lC9MeuKEUTQkZsNxzvV+zMxqCNje/EyBqRjwfQxg4pBbPjxK/SIXSORlA==
dependencies:
"@babel/runtime" "^7.10.2"
normalize-path "^2.1.1"
parse-numeric-range "^0.0.2"
unist-util-map "^1.0.5"

gatsby-remark-images@3.3.8:
version "3.3.8"
resolved "https://registry.yarnpkg.com/gatsby-remark-images/-/gatsby-remark-images-3.3.8.tgz#d5c6c0a1de8b6d843ac6bcbc6863a420644ff301"
Expand Down Expand Up @@ -11972,6 +11989,11 @@ parse-latin@^4.0.0:
unist-util-modify-children "^1.0.0"
unist-util-visit-children "^1.0.0"

parse-numeric-range@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/parse-numeric-range/-/parse-numeric-range-0.0.2.tgz#b4f09d413c7adbcd987f6e9233c7b4b210c938e4"
integrity sha1-tPCdQTx6282Yf26SM8e0shDJOOQ=

parse-passwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6"
Expand Down

0 comments on commit ade24dd

Please sign in to comment.