npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ah-content-exporter

v0.5.3

Published

Export a folder with web content

Downloads

6

Readme

Anthill Content Exporter

Export a folder of web content, resolving assets external to the folder.

It will generate a new folder where all external assets have been copied into the folder with all references updated in source files.

Will currently look for following when resolving resources:

  • href
  • src
  • url()

All HTML and CSS files will be inspected.

Not Yet Supported

  • CSS imports (not using 'url()')
  • srcset property

NOTE: Templates, markdown, and other files that need compiling should be compiled before exporting.

NOTE 2: Although absolute paths are supported they can create very long paths.

API

run(src, config, next)

Export a folder

param src

Source to the folder to export.

Alternatively a specific file can be included in the path. Then only assets directly or indirectly linked from that file will be included. Note that this means that no PDFs or other supporting files will be included in the export, unless linked (e.g. with href property).

The path given will be resolved from where the script is running.

config.dest

Where to put the resulting folder. Defaults to '../_exports'

config.output

What to call the resulting folder. Defaults to original folder name

config.include

Array of filepaths that should be included even though they are not referenced, i.e. force them to be included.

config.offline

If remote assets should be downloaded. Defaults to false

Currently following file formats will be downloaded png, jpg, gif, css, js

Examples

// Copy everything in the folder and assets linked from html, css and js files
exporter.run("slides/safety", {}, function(err, dest) { console.log("Exported to", dest) });
// Copy index.html file and any assets directly, or indirectly linked to that file
exporter.run("slides/safety/index.html", {}, function(err, dest) { console.log("Exported to", dest) });
// Copy index.html file and any assets directly, or indirectly linked to that file. Also include default files
// and download any external referencs
var config = {
  offline: true,
  include: ['_vendor/jquery.min.js']
}
exporter.run("slides/safety/index.html", config, function(err, dest) { console.log("Exported to", dest) });

See tests for more examples of how to use the API.

resolve(src, defaultRefs, next)

Resolve all assets referenced in a folder without exporting.

Will return an object like:

{
  local: ["img/bg.png", ...],
  external: ["../_shared/css/styles.css", ...],
  remote: ["https://cdn.jquery.com", ...]
}