Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding ability to supply links for the head #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Your `html` function will be called with a context object that contains the foll
- `{metaViewport: boolean|object}` set to false if you don't want the default viewport tag. Set to an object with `userScalable` true if you don't want to block user-zoom on mobile
- `{publicPath: 'http://mycdn.com/'}` (default `/`) pass in path that will prefix the generated css/js files in the template. Note, there is `output.publicPath` provided by webpack, but doesn't easily allow for switching based on envirnoment. In this method we've got access to `context.isDev` and can easily switch based on that.
- `{metaTags: {}}` lets you easily add `<meta>` tags to the document head. Takes an object where the key is the `name` and the value is the `content`.
- `{links: {}}` lets you easily add `<link>` tags to the document head. Takes an object where the key is the `rel` and the value is the `href`.
- `{lang: 'en-US'}` sets the `lang` attribute on the `<html>` tag.
4. `context.isDev`: boolean specifying whether or not we're in dev mode.
5. `context.package`: the parsed `package.json` file as an object.
Expand Down
5 changes: 5 additions & 0 deletions lib/html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function defaultHtml (incomingData) {
add('<meta name="' + key + '" content="' + data.metaTags[key] + '"/>')
}
}
if (data.links) {
for (var key in data.links) {
add('<link rel="' + key + '" href="' + data.links[key] + '"/>')
}
}
if (data.title) {
add('<title>' + data.title + '</title>')
}
Expand Down