Git Product home page Git Product logo

spike-page-id's Introduction

Spike Page ID

npm tests dependencies coverage

Generates a css-friendly page identifier from a webpack loader context

Note: This project is in early development, and versioning is a little different. Read this for more details.

Installation

npm install spike-page-id -S

Note: This project is compatible with node v6+ only

Usage

In your spike config:

const htmlStandards = require('reshape-standard')
const pageId = require('spike-page-id')

module.exports = {
  // other config…
  reshape: (ctx) => {
    return htmlStandards({
      locals: { pageId: pageId(ctx) }
    })
  }
}

Now in your html, let's say it's called index.sgr:

html
  head
    title My page
  body(id='{{ pageId }}')
    p hello world

This will render something like:

<html>
  <head>
    <title>My page</title>
  </head>
  <body id='index'>
    <p>hello world</p>
  </body>
</html>

If you are working with a page that's nested inside other folders, it will include all folders relative to the project root, separated by a hyphen. So for example:

  • views/index.sgr > index
  • views/posts/welcome.sgr > posts-welcome

…and that's about it!

License & Contributing

spike-page-id's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar jescalan avatar synj24 avatar

Watchers

 avatar  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.