Git Product home page Git Product logo

doogle's Introduction

Doogle

ย 

Teaching an old dog new tricks...

Google translates any hash-bang URLs (#!) it finds into an actual GET parameter _escaped_fragment_. By listening for this parameter and querying Doogle, we can generate and cache static HTML pages for your JavaScript content.

For a complete reference on Google's AJAX crawling please see getting started.

Install with npm: npm install doogle

Getting Started

Doogle is very simple to get up and running with. First of all you need to let Doogle know which base URL we're going to be using.

var doogle = require('doogle')('http://www.example.com/');

Any time you specify a path to retrieve, it will be appended to the base URL (http://www.example.com/).

You then need to decide where to store your HTML snapshots, and for how long they're valid for in hours.

// Set the HTML snapshot directory.
doogle.setDirectory(__dirname + '/snapshots');

// Set the expiry in hours.
doogle.setExpiry(24);

If you don't want to use cache at all โ€“ which isn't recommended, then you can set setExpiry to false.

You then need to instruct Doogle on which path to fetch.

doogle.fetch('/');

As fetch returns Q.promise you need to define what happens when Doogle resolves the promise.

doogle.fetch('/').then(function(data) {
    response.send(JSON.stringify(data));
});

From there on in you're on your own! Doogle lets you decide how to serve the HTML snapshot to Googlebot.

doogle's People

Contributors

wildhoney avatar electblake avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.