ladjs/koa-meta

Name: koa-meta

Owner: Lad

Description: SEO and <meta name="description"> middleware for Koa and Lad</p> <p><b>Created:</b> 2017-09-09 19:28:28.0</p> <p><b>Updated:</b> 2018-05-23 03:39:20.0</p> <p><b>Pushed:</b> 2017-12-15 11:39:21.0</p> <p><b>Homepage:</b> <a href="https://lad.js.org">https://lad.js.org</a> </p> <p><b>Size:</b> 158</p> <p><b>Language:</b> JavaScript</p> <p><b>GitHub Committers</b> <table> <tr><th>User</th><th>Most Recent Commit</th><th># Commits</th></tr> </table> <p> <p><b>Other Committers</b> <table> <tr><th>User</th><th>Email</th><th>Most Recent Commit</th><th># Commits</th></tr> </table> <p> <h3>README</h3> <h4>koa-meta</h4> <p><a href="https://travis-ci.org/ladjs/koa-meta"><img src="https://img.shields.io/travis/ladjs/koa-meta.svg" alt="build status" /></a> <a href="https://codecov.io/gh/ladjs/koa-meta"><img src="https://img.shields.io/codecov/c/github/ladjs/koa-meta.svg" alt="code coverage" /></a> <a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a> <a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="styled with prettier" /></a> <a href="https://lass.js.org"><img src="https://img.shields.io/badge/made_with-lass-95CC28.svg" alt="made with lass" /></a> <a href=""><img src="https://img.shields.io/github/license/ladjs/koa-meta.svg" alt="license" /></a></p> <blockquote><p>Meta <code><title></code> and <code><meta name="description"></code> middleware for Koa and Lad</p> </blockquote> <h5>Table of Contents</h5> <ul> <li><a href="#install">Install</a></li> <li><a href="#usage">Usage</a></li> <li><a href="#translation-support">Translation Support</a></li> <li><a href="#child-path-support">Child Path Support</a></li> <li><a href="#error-catching">Error Catching</a></li> <li><a href="#contributors">Contributors</a></li> <li><a href="#license">License</a></li> </ul> <h5>Install</h5> <p><a href="https://www.npmjs.com/">npm</a>:</p> <pre><code>install koa-meta </code></pre> <p><a href="https://yarnpkg.com/">yarn</a>:</p> <pre><code> add koa-meta </code></pre> <h5>Usage</h5> <blockquote><p>Use middleware:</p> </blockquote> <pre><code>t Meta = require('koa-meta'); ... t meta = new Meta({ ': [ 'Home', 'Our home page description' ], contact', [ 'Contact', 'Contact us with questions' ] use(meta.middleware); use((ctx, next) => { since the previous middleware was defined before this the `ctx.state` object has been populated with metadata nsole.log('ctx.state.meta', ctx.state.meta); for a request with `ctx.path` of `/` it will output: { title: 'Home', description: 'Our home page description' } </code></pre> <p>Therefore in your views you can render the meta data easily:</p> <pre><code>ype html ad title= meta.title meta(name="description", content=meta.description) </code></pre> <blockquote><p>Get a meta translation:</p> </blockquote> <pre><code>t Meta = require('koa-meta'); t meta = new Meta({ ': [ 'Home', 'Our home page description' ], posts': [ 'Posts', 'Posts by our team' ] ole.log(meta.getByPath('/posts/123456')); { title: 'Posts', description: 'Posts by our team' }` </code></pre> <h5>Translation Support</h5> <p>This package supports translation out of the box.</p> <p>It checks for a function set on <code>ctx.req.t</code> and utilizes that function to translate based off the request's locale.</p> <h5>Child Path Support</h5> <p>This package supports parent meta data lookup for children of paths.</p> <p>This means if you define in your configuration a path of <code>/posts</code> and a request is made to <code>/posts/123456</code> (with this path not being defined in your configuration), then it will use <code>/posts</code> definition for <code>/posts/123456</code>.</p> <h5>Error Catching</h5> <p>By default this package will throw an error if a child path was found that does not have a parent defined.</p> <p>This is extremely useful for retaining quality control with your configuration.</p> <h5>Contributors</h5> <p>| Name | Website | | ————– | ————————– | | <strong>Nick Baugh</strong> | <a href="http://niftylettuce.com/">http://niftylettuce.com/</a> |</p> <h5>License</h5> <p><a href="LICENSE">MIT</a> © <a href="http://niftylettuce.com/">Nick Baugh</a></p> <h5></h5> </div> <div style="width: 100%; float: left"> <div class="container-fluid pt-5"> <hr/> </div> <div class="d-flex justify-content-center flex-row flex-wrap pb-1"> <ul id="menu-footer-menu" class="foot nav justify-content-center"> <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-985" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-985 nav-item"><a title="NIH" href="https://www.nih.gov/" class="nav-link">NIH</a></li> <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-988" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-988 nav-item"><a title="NCATS" href="https://ncats.nih.gov/" class="nav-link">NCATS</a></li> <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-991" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-991 nav-item"><a title="CTSA" href="https://ctsa.ncats.nih.gov" class="nav-link">CTSA</a></li> <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-994" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-994 nav-item"><a title="CD2H" href="https://ctsa.ncats.nih.gov/cd2h/" class="nav-link">CD2H</a></li> <li itemscope="itemscope" itemtype="https://www.schema.org/SiteNavigationElement" id="menu-item-997" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-997 nav-item"><a title="CD2H Labs" href="http://labs.cd2h.org" class="nav-link">CD2H Labs</a></li> </ul> </div> <div class="container pl-0 pr-0"> <div class="container-fluid mt-4">This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.</div> </div> <div class="row justify-content-center pb-3"> <a href="https://twitter.com/data2health?lang=en"> <i class="fab fa-twitter-square fa-2x pr-1" style="background: -webkit-linear-gradient(#c0deed, #0084b4); -webkit-background-clip: text; -webkit-text-fill-color: transparent;"></i> </a> <a href="https://github.com/data2health"> <i class="fab fa-github-square fa-2x pl-1" style="background: -webkit-linear-gradient(#eee, #333); -webkit-background-clip: text; -webkit-text-fill-color: transparent;"></i> </a> </div> </div> </div> </div> </body> </html>