-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prefix slug with dash * Update test snapshots * Add changeset * Export slugify function * Revert test changes
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
"markdown-to-jsx": patch | ||
--- | ||
|
||
Browsers assign element with `id` to the global scope using the value as the variable name. E.g.: `<h1 id="analytics">` can be referenced via `window.analytics`. | ||
This can be a problem when a name conflict happens. For instance, pages that expect `analytics.push()` to be a function will stop working if the an element with an `id` of `analytics` exists in the page. | ||
|
||
In this change, we export the `slugify` function so that users can easily augment it. | ||
This can be used to avoid variable name conflicts by giving the element a different `id`. | ||
|
||
```js | ||
import { slugify } from 'markdown-to-jsx'; | ||
|
||
options={{ | ||
slugify: str => { | ||
let result = slugify(str) | ||
|
||
return result ? '-' + str : result; | ||
} | ||
}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters