Skip to content

Commit

Permalink
(feat) - gatsby plugin (#10)
Browse files Browse the repository at this point in the history
* prepare publishing of gatsby-plugin-hooked-head

* adjust readme

* make 0.1.0 the first version

* Update packages/gatsby-plugin-hooked-head/gatsby-ssr.js

Co-Authored-By: Gustav Pursche <[email protected]>

* fix syntax issue

Co-authored-by: Gustav Pursche <[email protected]>
  • Loading branch information
JoviDeCroock and Gustav Pursche committed Apr 17, 2020
1 parent d97ec11 commit 2f16169
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ example
yarn.lock
.rpt2_cache
coverage
packages
typings.d.ts
Dockerfile
mangle.json
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ client-side alterations it's important to support a fallback model for our `<hea
library will always make a queue of how we should fallback, ... This way we'll always have some information to give to a
visiting crawler.

```sh
npm i --save hooked-head
## OR
yarn add hooked-head
```

```jsx
import {
useMeta,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"meta",
"link",
"html",
"language"
"language",
"seo"
],
"main": "./dist/hooked-head.js",
"browser": "./dist/hooked-head.umd.js",
Expand Down
7 changes: 7 additions & 0 deletions packages/gatsby-plugin-hooked-head/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 0.1.1

Fix syntax error

# 0.1.0

Initial release
22 changes: 22 additions & 0 deletions packages/gatsby-plugin-hooked-head/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# gatsby-plugin-hooked-head

A [Gatsby](https://github.com/gatsbyjs/gatsby) plugin for
[Hooked-head](https://github.com/JoviDeCroock/hooked-head) with ssr-support.

## Install

```sh
npm i --save hooked-head gatsby-plugin-hooked-head
## OR
yarn add hooked-head gatsby-plugin-hooked-head
```

## How to use

Edit `gatsby-config.js`

```js
module.exports = {
plugins: [`gatsby-plugin-hooked-head`],
};
```
18 changes: 18 additions & 0 deletions packages/gatsby-plugin-hooked-head/gatsby-ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createElement } from 'react';
import { toStatic } from 'hooked-head';

export const onRenderBody = ({ setHeadComponents, setHtmlAttributes }) => {
const { title, metas, lang, links } = toStatic();

if (lang) {
setHtmlAttributes({ lang });
}

setHeadComponents(
[
title && createElement('title', null, title),
...metas.map((meta) => createElement('meta', meta, null)),
...links.map((link) => createElement('link', link, null)),
].filter(Boolean)
);
};
1 change: 1 addition & 0 deletions packages/gatsby-plugin-hooked-head/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
33 changes: 33 additions & 0 deletions packages/gatsby-plugin-hooked-head/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "gatsby-plugin-hooked-head",
"version": "0.1.1",
"description": "Gatsby plugin to add support for hooked-head",
"author": "jdecroock <[email protected]> (https://twitter.com/JoviDeC)",
"license": "MIT",
"main": "index.js",
"scripts": {},
"keywords": [
"hooked-head",
"gatsby",
"gatsby-plugin",
"head",
"seo"
],
"files": [
"gatsby-ssr.js",
"index.js",
"package.json",
"README.md"
],
"dependencies": {},
"devDependencies": {},
"peerDependencies": {
"hooked-head": "^0.4.0",
"gatsby": "^2.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/JoviDeCroock/hooked-head.git",
"directory": "packages/gatsby-plugin-hooked-head"
}
}

0 comments on commit 2f16169

Please sign in to comment.