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

dead-crawl

v0.2.1

Published

SEO+Javascript == Undead

Downloads

8

Readme

Code Climate

DeadCrawl.js

SEO+javascript == Undead (An Express.js middleware)

Renders the page with Zombie.js and saves to file.

Install

npm install dead-crawl

Example

var app = require('express')();
var deadCrawl = require('dead-crawl').deadCrawl;

app.use(deadCrawl());
app.use(routes);
app.use(express.static(...));

You may alter your hashbang delimiter by passing it in as an option.

app.use(deadCrawl({hashbang: "#"}));

Will rebuild the url with that vs. the default #!.
eg. http://example.com?_escaped_fragment_=/js/page => http://example.com/#/js/page

null or '' will omit the hashbang entirely.


To change the destination root of the saved html files, supply a destRoot option.

app.use(deadCrawl({destRoot: __dirname+'/public/crawled'}));

The default is destRoot is .;


To run process before the html gets written to file you can supply a beforeWrite option with an Array of functions.

function waitForMetaDescription(browser, _, next) {
  var i = 0;
  var waiting = setInterval(function() {
    var desc = browser.query('meta[name="description"]')
      .attributes
      .content
      ._nodeValue;

    i++;
    if (!!desc || i > 10) {
      next();
    }
  }, 100);
}

function removeNgApp(browser, next) {
  next(browser.html().replace(/\sng\-app="\w+"/, ''));
}

var opts = {
  destRoot: __dirname+'/public/crawls',
  beforeWriter: [
    waitForMetaDescription,
    removeNgApp
  ]
};

app.use(deadCrawl(opts));

The first function will always be provided with 3 arguments: browser, null, next.

The last function (before the writer) needs to next any processed html (or string) to be written to file. Else browser.html() will be written to file.

Information on using next to pass arguments can be viewed at WalkingDead.js.


Once a page has been crawled, any further requests (?_escaped_fragment_=) will send back the saved html file. If your page is dynamic you will have to ensure you sweep out the cached files when needed.


Notes

http://www.yearofmoo.com/2012/11/angularjs-and-seo.html

License

MIT