Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gatsbyjs/gatsby into topics/wp-me…
Browse files Browse the repository at this point in the history
…dia-config
  • Loading branch information
TJ Simons committed Mar 29, 2018
2 parents 559fc0f + 41bf10f commit 95fcf46
Show file tree
Hide file tree
Showing 125 changed files with 14,057 additions and 333 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ node_modules/
# IDE specific
.idea/
.vscode/
*.sw*

.serverless/
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ Websites built with Gatsby:
* [greglobinski.com](https://greglobinski.com)
([source](https://github.com/greglobinski/greglobinski-com))
* [Vibert Thio's Portfolio](https://vibertthio.com/portfolio/)([source](https://github.com/vibertthio/portfolio))
* [hunterchang.com](https://hunterchang.com)
([source](https://github.com/ChangoMan/hc-gatsby))
* [YouFoundRon.com](https://youfoundron.com)
([source](https://github.com/rongierlach/yfr-dot-com))
* [heml.io](https://heml.io)
Expand Down Expand Up @@ -183,6 +181,15 @@ Websites built with Gatsby:
* [Watchcards.ru](http://watchcards.ru/)
* [John Meguerian's Portfolio](https://johnmeguerian.com) ([source](https://github.com/jmegs/portfolio))
* [Krashna Musika Association Website](https://www.krashna.nl/) ([source](https://github.com/krashnamusika/krashna-site))
* [Deliveroo.Design](https://www.deliveroo.design/)
* [The Rick and Morty API](http://rickandmortyapi.com/)
* [Adnan Fajlur - Portfolio](https://adnanfajlur.xyz/)
* [Hapticmedia](https://hapticmedia.fr/en/)
* [Smakosh](https://smakosh.com) ([source](https://github.com/smakosh/smakosh.com))
* [Philipp Czernitzki - Blog/Website](http://philippczernitzki.me)
* [CodeBushi](https://codebushi.com/)
* [WebGazer](https://www.webgazer.io)
* [Joe Seifi's Blog](http://seifi.org)

## Docs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Let's fix that. We need to teach Gatsby how to query the file system. Luckily
this is so common it's been done for you. Install the file system source plugin:

```
yarn add gatsby-source-filesystem
npm i --save gatsby-source-filesystem
```

Now modify `gatsby-config.js` to both use the plugin and tell it what directory
Expand Down Expand Up @@ -230,7 +230,7 @@ files this is all you will need. But if you want to render markdown files as
HTML you will need another plugin. Let's add that now:

```
yarn add gatsby-transformer-remark
npm i --save gatsby-transformer-remark
```

As before, add it to the `plugins` field in `gatsby-config.js`:
Expand Down
49 changes: 49 additions & 0 deletions docs/blog/2017-10-17-building-i18n-with-gatsby/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,55 @@ The `handleLanguageChange` function just wraps the `react-i18n` function passed
in as a prop through `translate`. Pretty much everything is handled for us.
Hooray! 🎉

## SSR

To let it render the content into html, you need to load i18n namespaces (using `i18n.loadNamespaces`) before render

### With redux

```js
// gatsby-ssr.js

import React from 'react'
import { Provider } from 'react-redux'
import { renderToString } from 'react-dom/server'
import i18n from './src/i18n'

import createStore from './src/state/createStore'

exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
i18n.loadNamespaces(['common'], () => {
const store = createStore()
const ConnectedBody = () => (
<Provider store={store}>{bodyComponent}</Provider>
)
replaceBodyHTMLString(renderToString(<ConnectedBody />))
})
}
```

### Without redux

> Not yet tested
```js
// gatsby-ssr.js

import React from 'react'
import { renderToString } from 'react-dom/server'
import i18n from './src/i18n'

import createStore from './src/state/createStore'

exports.replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
i18n.loadNamespaces(['common'], () => {
replaceBodyHTMLString(bodyComponent)
})
}
```

> `translate` hoc from react-i18next cause page / component not able to SSR. I make it works by import i18n & use i18n.t
## Finishing up

As you can see, i18n in Gatsby is actually pretty simple when you know how! We
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Next, we analyzed over 10 admirable and/or popular plugin libraries to draw from
* [Apple App store](https://www.apple.com/ios/app-store/)
* [Google Play store](https://play.google.com/store/apps/top)


### The goods 👍

We liked when these libraries let users:
Expand All @@ -55,14 +54,13 @@ We liked when these libraries let users:

### The bads 👎

We *didn't* like these things in some of the above libraries:
We _didn't_ like these things in some of the above libraries:

* poor contrast and poor information heirarchy
* limited filters
* too many filters
* low information density


## Prototypes and their evolutions

Here’s a sampling of screenshots that many community members contributed to and gave feedback about. It’s rewarding to see how much the design has progressed (and will keep progressing).
Expand All @@ -74,17 +72,16 @@ Here’s a sampling of screenshots that many community members contributed to an

## Next steps for the plugin library

The plugin ecosystem is a huge part of what makes Gatsby awesome because plugins and packages make Gatsby extensible. There's a virtuous cycle where people find plugins, use them, contribute to them, and create new ones. We hope to accelerate this cycle, so the Gatsby ecosystem can develop faster and more people can build awesome sites!
The plugin ecosystem is a huge part of what makes Gatsby awesome because plugins and packages make Gatsby extensible. There's a virtuous cycle where people find plugins, use them, contribute to them, and create new ones. We hope to accelerate this cycle, so the Gatsby ecosystem can develop faster and more people can build awesome sites!

Here are some ways you can help make the Gatsby plugin ecoystem great:

* Share feedback on the plugin library on [Github Issue #4394](https://github.com/gatsbyjs/gatsby/issues/4394).
* If you created a plugin and it's not showing up in the library, double check that the package has "gatsby-plugin" in its keywords.
* Create plugins (or publish ones you've already built)! If you're interested, the [Plugin Authoring](/docs/plugin-authoring/) page can help.
* [Contact me](https://twitter.com/shannonb_ux/status/938551014956732418) here if you have feedback that differs from or provides deeper insight into one of the pain points this article mentions.
* [Contact me](https://twitter.com/shannonb_ux/status/938551014956732418) here if you have feedback that differs from or provides deeper insight into one of the pain points this article mentions.
* Follow us on [Twitter](https://twitter.com/gatsbyjs).


## Sneak peak into the next UX project

Our next UX project is designing and building a [Gatsby site showcase](https://github.com/gatsbyjs/gatsby/issues/4394). Please contribute to and subscribe to the issue to help out!
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/2018-2-3-sites-with-headless-cms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A traditional Content Management System (CMS)--like Wordpress, Drupal, or Joomla

You can think of a traditional CMS like an old home built by one person and with custom fittings. Gorgeous, and expensive to maintain, like the home in _The Money Pit_ (1986) with Tom Hanks and Shelley Long.

![Tom Hanks on a staircase that is falling apart](money-pit-2.jpeg)
![Tom Hanks in a house that is falling apart](money-pit-2.jpeg)

Despite the advantages of this scenario, there are also some disadvantages which are listed below.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
11 changes: 5 additions & 6 deletions docs/docs/deploy-gatsby.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ now to create a new repository on GitHub.
### Use the NPM package `gh-pages` for deploying

First add **gh-pages** as a `devDependency` of your site and create an npm
script to **deploy** your project by running `npm install gh-pages --save-dev`
or `yarn add gh-pages --dev` (if you have yarn installed).
script to **deploy** your project by running `npm install gh-pages --save-dev`.

Then add a `deploy` script in your `package.json` file.

Expand All @@ -84,7 +83,7 @@ repo, set up git in your project with `git init`. Then tell Gatsby where to
deploy your site by adding the git remote address with https or ssh. Here is how
to do it with https: `git remote add origin git@github.com:username/project-name.git`.

Now run `yarn deploy` or `npm run deploy`. Preview changes in your GitHub page
Now run `npm run deploy`. Preview changes in your GitHub page
`https://username.github.io/project-name/`. You can also find the link to your
site on GitHub under `Settings` > `GitHub Pages`.

Expand Down Expand Up @@ -167,7 +166,7 @@ cache:
pages:
script:
- yarn install
- npm install
- ./node_modules/.bin/gatsby build --prefix-paths
artifacts:
paths:
Expand All @@ -182,14 +181,14 @@ in between builds, so subsequent builds should be a lot faster as it doesn't hav
to reinstall all the dependancies required. `pages:` is the name of the
CI stage. You can have multiple stages, e.g. 'Test', 'Build', 'Deploy' etc.
`script:` starts the next part of the CI stage, telling it to start running the
below scripts inside the image selected. We have used the `yarn install` and
below scripts inside the image selected. We have used the `npm install` and
`./node_modules/.bin/gatsby build --prefix-paths` which will install all dependancies, and
start the static site build, respectively.

We have used
`./node_modules/.bin/gatsby build --prefix-paths` because we then don't have to install
gatsby-cli to build the image, as it has already been included and installed
with `yarn install`. We have included `--prefix-paths` as when running the command _without_ that flag, Gatsby ignores your pathPrefix. `artifacts:` and `paths:` are used to tell GitLab pages
with `npm install`. We have included `--prefix-paths` as when running the command _without_ that flag, Gatsby ignores your pathPrefix. `artifacts:` and `paths:` are used to tell GitLab pages
where the static files are kept. `only:` and `master` tells the CI to only run
the above instructions when the master branch is deployed.

Expand Down
94 changes: 88 additions & 6 deletions docs/docs/gatsby-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ _Note: There are many sample configs which may be helpful to reference in the di

Options available to set within `gatsby-config.js` include:

1. siteMetadata (object)
2. plugins (array)
3. pathPrefix (string)
4. polyfill (boolean)
5. mapping (object)
6. proxy (object)
1. siteMetadata (object)
2. plugins (array)
3. pathPrefix (string)
4. polyfill (boolean)
5. mapping (object)
6. proxy (object)

## siteMetadata

Expand Down Expand Up @@ -139,6 +139,88 @@ query BlogPost($slug: String!) {
}
```

Mapping can also be used to map an array of ids to any other collection of data. For example, if you have two JSON files
`experience.json` and `tech.json` as follows:

```json
// experience.json
[
{
"id": "companyA",
"company": "Company A",
"position": "Unicorn Developer",
"from": "Dec 2016",
"to": "Present",
"items": [
{
"label": "Responsibility",
"description": "Being an unicorn"
},
{
"label": "Hands on",
"tech": ["REACT", "NODE"]
}
]
}
]
```

```json
// tech.json
[
{
"id": "REACT",
"icon": "facebook",
"color": "teal",
"label": "React"
},
{
"id": "NODE",
"icon": "server",
"color": "green",
"label": "NodeJS"
}
]
```

And then add the following rule to your `gatsby-config.js`:

```javascript
module.exports = {
plugins: [...],
mapping: {
'ExperienceJson.items.tech': `TechJson`
},
}
```

You can query the `tech` object via the referred ids in `experience`:

```graphql
query CV {
experience: allExperienceJson {
edges {
node {
company
position
from
to
items {
label
description
link
tech {
label
color
icon
}
}
}
}
}
}
```

## Proxy

Setting the proxy config option will tell the development server to proxy any unknown requests to your specified server. For example:
Expand Down
69 changes: 69 additions & 0 deletions docs/docs/gatsby-on-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Gatsby on Linux
---
# Linux

TODO

## Windows Subsystem Linux (WSL)

As of October 17th 2017, Windows 10 ships with WSL and Linux distributions are available via the [Windows Store], there are several different distributions to use which can be configured via `wslconfig` if you have more than one distribution installed.

```sh
# set default distribution to Ubuntu
wslconfig /setdefault ubuntu
```

### Using Windows Subsystem Linux: Ubuntu

If you have a fresh install of Ubuntu then update and upgrade:

```sh
sudo apt update
sudo apt -y upgrade
```

>Only use `-y` if you're happy to upgrade to the latest versions of the software.
**Build tools**

To compile and install native addons from npm you may also need to install build tools for `node-gyp`:

```sh
sudo apt install -y build-essential
```

**Install node**

Following the install instructions on nodejs.org leaves a slightly broken install (i.e. permission errors when trying to `npm install`). Instead try installing node versions using [n] which you can install with [n-install]:

```sh
curl -L https://git.io/n-install | bash
```

There are other alternatives for managing your node versions such as [nvm] but this is known to slow down [bash startup] on WSL.

### Using Windows Subsystem Linux: Debian

Debian setup is nearly identical to Ubuntu except for the additional installs of `git` and `libpng-dev`.

```sh
sudo apt update
sudo apt -y upgrade
sudo apt install build-essential
sudo apt install git
sudo apt install libpng-dev
```

Or to install all at the same time and approve (y) all installs:

```sh
sudo apt update && sudo apt -y upgrade && sudo apt install build-essential && sudo apt install git && sudo apt install libpng-dev
```

<!-- links -->
[windows store]: https://www.microsoft.com/en-us/store/p/ubuntu/9nblggh4msv6
[n]: https://github.com/tj/n
[n-install]: https://github.com/mklement0/n-install
[nvm]: https://github.com/creationix/nvm
[bash startup]: https://github.com/Microsoft/WSL/issues/776#issuecomment-266112578
6 changes: 2 additions & 4 deletions docs/docs/gatsby-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ This might be your problem if, after running `npm install` on a Gatsby site, you
see compilation errors such as `node-gyp` or `sharp` or `binding.gyp not found`.

If you suspect this is your problem, download the
[Visual Studio Community 2015 Package](https://www.visualstudio.com/products/visual-studio-community-vs)
[Visual Studio Community 2015 Package](https://www.visualstudio.com/vs/older-downloads/) (also available from this [direct download link](https://go.microsoft.com/fwlink/?LinkId=532606&clcid=0x409))
and install only the part of the package that interests us : `Programming languages > Visual C++ > Common tools for Visual Studio 2015`. Be sure to
download the 2015 version of VS Community, not the 2017 version (see Note 1
below) ; you'll have to use the
[search bar on the VS site](https://www.visualstudio.com/products/visual-studio-community-vs)
to find it. You can uncheck everything else. You don't need to install the full
below). You can uncheck everything else. You don't need to install the full
VS2015 Express on your system and this won't mess up your existing VS201x
installs.

Expand Down
Loading

0 comments on commit 95fcf46

Please sign in to comment.