Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including link-to-import with all npm packages installed. Try it out:

var linkToImport = require("link-to-import")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

link-to-import v0.1.2

Change link of have relationship with external stylesheet into @import CSS at-rule

link-to-import Build Status

Change link of have relationship with external stylesheet into @import CSS at-rule

Install

$ npm install --save link-to-import

Usage

// > '<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Inconsolata:400,700">'

var linkToImport = require('link-to-import');
var tack = linkToImport(html, function(href, attr) {
  // return updated url value if you want to
  return href + '/changeurl';
});

console.log(tack.html, tack.link);
// > '<style>@import url("//fonts.googleapis.com/css?family=Inconsolata:400,700")</style>

API

linkToImport(html, evaluate)

html

HTML string that includes links

evaluate

To evaluate a link which could be updated or not

Return

Return updated html with link information

{
  html: String
  link: []
}

License

MIT © Jimmy Moon

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free