Skip to content

Commit

Permalink
PR #42 improvements (#46)
Browse files Browse the repository at this point in the history
* ✅ Added test for #42 solution.

* ✨ Added support for whitespace after 'oembed:' prefix

* 📝 Updated docs
  • Loading branch information
raae committed Apr 9, 2019
1 parent ef831c6 commit 5917269
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 183 deletions.
22 changes: 21 additions & 1 deletion README.md
Expand Up @@ -40,6 +40,7 @@ plugins: [
{
resolve: `@raae/gatsby-remark-oembed`,
options: {
// defaults to false
usePrefix: true,
providers: {
// Important to exclude providers
Expand Down Expand Up @@ -85,7 +86,9 @@ For example, for Instagram see [Instagram – Embedding for Developers](https://

### Content

```
#### With setting `usePrefix: true`

```md
// In your markdown file

Check it out! I can use oembed links in my markdown.
Expand All @@ -99,10 +102,27 @@ Its pretty cool :D

Links must be surrounded by empty lines.

#### With setting `usePrefix: false`

```md
// In your markdown file

Check it out! I can use oembed links in my markdown.

https://twitter.com/raae/status/1045394833001652225

Its pretty cool :D

https://www.instagram.com/p/Bof9WhgBmY2/
```

Links must be surrounded by empty lines.

## Options

| Name | Type | Description |
| -------------------- | --------------------------- | ----------------------------------------------------------- |
| `usePrefix` | Boolean | See above section on content |
| `providers.include` | Array of provider keys | Only links from providers on this list will be transformed. |
| `providers.exclude` | Array of provider keys | Links from providers on this list will not be transformed. |
| `providers.settings` | Object of provider settings | Optional configuration unique to each provider. |
Expand Down
243 changes: 105 additions & 138 deletions helper.test.data.js
@@ -1,181 +1,148 @@
exports.MARKDOWN_AST = {
type: "root",
children: [
{
position: {
end: {
column: 4,
line: 4,
offset: 62
},
indent: [1, 1, 1],
start: {
column: 1,
line: 1,
offset: 0
type: "paragraph",
children: [
{
type: "text",
value: "Take a look at a day in my life as a web developer.",
position: {
start: { line: 2, column: 1, offset: 1 },
end: { line: 2, column: 52, offset: 52 },
indent: []
}
}
},
type: "yaml",
value: 'title: New Beginnings\ndate: "2015-05-28T22:40:32.169Z"'
],
position: {
start: { line: 2, column: 1, offset: 1 },
end: { line: 2, column: 52, offset: 52 },
indent: []
}
},
{
type: "paragraph",
children: [
{
type: "link",
title: null,
url: "https://www.instagram.com/p/Bof9WhgBmY2",
children: [
{
position: {
end: {
column: 44,
line: 6,
offset: 107
},
indent: [],
start: {
column: 1,
line: 6,
offset: 64
}
},
type: "text",
value: "https://www.youtube.com/watch?v=b2H7fWhQcdE"
value: "https://www.instagram.com/p/Bof9WhgBmY2",
position: {
start: { line: 4, column: 1, offset: 54 },
end: { line: 4, column: 40, offset: 93 },
indent: []
}
}
],
position: {
end: {
column: 44,
line: 6,
offset: 107
},
indent: [],
start: {
column: 1,
line: 6,
offset: 64
}
},
title: null,
type: "link",
url: "https://www.youtube.com/watch?v=b2H7fWhQcdE"
start: { line: 4, column: 1, offset: 54 },
end: { line: 4, column: 40, offset: 93 },
indent: []
}
}
],
position: {
end: {
column: 44,
line: 6,
offset: 107
},
indent: [],
start: {
column: 1,
line: 6,
offset: 64
}
},
type: "paragraph"
start: { line: 4, column: 1, offset: 54 },
end: { line: 4, column: 40, offset: 93 },
indent: []
}
},
{
type: "paragraph",
children: [
{
position: {
end: {
column: 29,
line: 9,
offset: 213
},
indent: [1],
start: {
column: 1,
line: 8,
offset: 109
}
},
type: "text",
value:
"Far far away, behind the word mountains, far from the countries Vokalia and\nConsonantia, there live the "
value: "Follow me for more code fun at ",
position: {
start: { line: 6, column: 1, offset: 95 },
end: { line: 6, column: 32, offset: 126 },
indent: []
}
},
{
type: "link",
title: null,
url: "https://raae.codes",
children: [
{
position: {
end: {
column: 41,
line: 9,
offset: 225
},
indent: [],
start: {
column: 30,
line: 9,
offset: 214
}
},
type: "text",
value: "blind texts"
value: "raae.codes",
position: {
start: { line: 6, column: 33, offset: 127 },
end: { line: 6, column: 43, offset: 137 },
indent: []
}
}
],
position: {
end: {
column: 62,
line: 9,
offset: 246
},
indent: [],
start: {
column: 29,
line: 9,
offset: 213
}
},
title: null,
type: "link",
url: "http://example.com"
start: { line: 6, column: 32, offset: 126 },
end: { line: 6, column: 64, offset: 158 },
indent: []
}
},
{
position: {
end: {
column: 102,
line: 9,
offset: 286
},
indent: [],
start: {
column: 62,
line: 9,
offset: 246
}
},
type: "text",
value: ". Separated they live in Bookmarksgrove."
value: ".",
position: {
start: { line: 6, column: 64, offset: 158 },
end: { line: 6, column: 65, offset: 159 },
indent: []
}
}
],
position: {
end: {
column: 102,
line: 9,
offset: 286
},
indent: [1],
start: {
column: 1,
line: 8,
offset: 109
start: { line: 6, column: 1, offset: 95 },
end: { line: 6, column: 65, offset: 159 },
indent: []
}
},
{
type: "paragraph",
children: [
{
type: "inlineCode",
value: "oembed: https://twitter.com/raae/status/1045394833001652225",
position: {
start: { line: 8, column: 1, offset: 161 },
end: { line: 8, column: 62, offset: 222 },
indent: []
}
}
},
type: "paragraph"
],
position: {
start: { line: 8, column: 1, offset: 161 },
end: { line: 8, column: 62, offset: 222 },
indent: []
}
},
{
type: "paragraph",
children: [
{
type: "inlineCode",
value: "oembed:https://www.instagram.com/p/Bof9WhgBmY2",
position: {
start: { line: 10, column: 1, offset: 224 },
end: { line: 10, column: 49, offset: 272 },
indent: []
}
}
],
position: {
start: { line: 10, column: 1, offset: 224 },
end: { line: 10, column: 49, offset: 272 },
indent: []
}
}
],
position: {
end: {
column: 1,
line: 10,
offset: 287
},
start: {
column: 1,
line: 1,
offset: 0
}
},
type: "root"
start: { line: 1, column: 1, offset: 0 },
end: { line: 11, column: 1, offset: 273 }
}
};

exports.PROVIDERS = [
Expand Down

0 comments on commit 5917269

Please sign in to comment.