makestatic-page-id
v2.0.0
Published
Utility to generate a page identifier
Downloads
5
Readme
Page Identifier
Generate a page identifier
Generates a page identifier to expose to template locals for CSS scoping.
Install
yarn add makestatic-page-id
API
identifier
identifier(ctx)
Generates an identifier for a file.
Useful when exposing template locals so that the identifier can be assigned to an element to allow easier CSS scoping.
The generated identifier is equal to the file name with the file extension removed unless the page is an index page.
If the page is an index page and is not at the context root the name of the parent directory is used, if the index page is at the root then the file name is used.
identifier({resourcePath: '/index.html'}) // index
identifier({resourcePath: '/features.html'}) // features
identifier({resourcePath: '/api/index.html'}) // api
Returns a page identifier.
ctx
Object the webpack loader context.
License
MIT
Created by mkdoc on March 12, 2017