2.0.2 • Published 6 years ago

express-seo-breadcrumbs v2.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Express Seo Breadcrumbs

A handy middleware to produce seo-friendly breadcrumbs with zero dependencies and simple interface. Breadcrumbs are accumulated while each new breadcrumb's url includes the url of the previous crumb, thus reflecting users journey in depth of the app. Main page crumb is always stored.

Getting Started

Prerequisites

Node.js and npm(for Linux users) should be installed;

An Express JS should be used on the project.

Installing

run

npm i -S express-seo-breadcrumbs

in your project main file (server.js, app.js or similar) include the following:

const breadcrumbs = require('express-seo-breadcrumbs');
app.use(breadcrumbs.init());

set home location:

app.use(breadcrumbs.setHome({ name: 'Home', url: '/' })); //sample values are defaults

whenever you need to set a breadcrumb use within the route:

app.get('/dashboard', (req, res) => {
    req.breadcrumbs({ name:'Dashboard', url: '/dashboard' });
 //...
});

access breadcrumbs to pass to front by calling req.breadcrumbs();

sample with express-handlebars:

app.get('/dashboard', (req, res) => {
    req.breadcrumbs({ name:'Dashboard', url: '/dashboard' });

    const breadcrumbs = req.breadcrumbs();

    res.render('dashboard', { breadcrumbs });
});
2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago