Last active
May 18, 2016 13:23
-
-
Save pimterry/860d7cd7b68d1944f600b02481c0db9f to your computer and use it in GitHub Desktop.
A linkifying example Server Component component.
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
var components = require("server-components"); | |
// We have a DOM simulation: quite a few client-side JS libraries will Just Work | |
var linkify = require("linkifyjs/element"); | |
/** | |
* A <linkify-urls> element, which finds plain text URLs within its content, | |
* and automatically rerenders them wrapped in <a> tags. | |
*/ | |
var LinkifyElement = components.newElement(); | |
LinkifyElement.createdCallback = function (document) { | |
linkify(this, { | |
target: () => null, | |
linkClass: "autolinked" | |
}, document); | |
}; | |
components.registerElement("linkify-urls", { prototype: LinkifyElement }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment