Skip to content

Commit

Permalink
Merge branch 'canary' into css-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Jan 24, 2021
2 parents 03ca0c2 + 783b9d8 commit 6882f4e
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 365 deletions.
10 changes: 10 additions & 0 deletions .vscode/launch.json
Expand Up @@ -42,6 +42,16 @@
"port": 9229,
"skipFiles": ["<node_internals>/**"],
"outFiles": ["${workspaceFolder}/packages/next/dist/**/*"]
},
{
"name": "Launch this example",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "debug", "dev", "${fileDirname}"],
"skipFiles": ["<node_internals>/**"],
"port": 9229
}
]
}
10 changes: 5 additions & 5 deletions docs/basic-features/data-fetching.md
Expand Up @@ -289,7 +289,7 @@ Since Next.js compiles your code into a separate directory you can't use `__dirn
Instead you can use `process.cwd()` which gives you the directory where Next.js is being executed.

```jsx
import fs from 'fs'
import { promises as fs } from 'fs'
import path from 'path'

// posts will be populated at build time by getStaticProps()
Expand All @@ -311,11 +311,11 @@ function Blog({ posts }) {
// direct database queries. See the "Technical details" section.
export async function getStaticProps() {
const postsDirectory = path.join(process.cwd(), 'posts')
const filenames = fs.readdirSync(postsDirectory)
const filenames = await fs.readdir(postsDirectory)

const posts = filenames.map((filename) => {
const posts = filenames.map(async (filename) => {
const filePath = path.join(postsDirectory, filename)
const fileContents = fs.readFileSync(filePath, 'utf8')
const fileContents = await fs.readFile(filePath, 'utf8')

// Generally you would parse/transform the contents
// For example you can transform markdown to HTML here
Expand All @@ -329,7 +329,7 @@ export async function getStaticProps() {
// will receive `posts` as a prop at build time
return {
props: {
posts,
posts: await Promise.all(posts),
},
}
}
Expand Down
9 changes: 0 additions & 9 deletions examples/with-firebase-authentication/.env.local.example

This file was deleted.

39 changes: 2 additions & 37 deletions examples/with-firebase-authentication/README.md
@@ -1,38 +1,3 @@
# Example: Firebase authentication with a serverless API
# With Firebase Authentication

This example includes Firebase authentication and serverless [API routes](https://nextjs.org/docs/api-routes/introduction).

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example with-firebase-authentication with-firebase-authentication-app
# or
yarn create next-app --example with-firebase-authentication with-firebase-authentication-app
```

## Configuration

Set up Firebase:

- Create a project at the [Firebase console](https://console.firebase.google.com/).
- Copy the contents of `.env.local.example` into a new file called `.env.local`
- Get your account credentials from the Firebase console at _Project settings > Service accounts_, where you can click on _Generate new private key_ and download the credentials as a json file. It will contain keys such as `project_id`, `client_email` and `private_key`. Set them as environment variables in the `.env.local` file at the root of this project.
- Get your authentication credentials from the Firebase console under _Project settings > General> Your apps_ Add a new web app if you don't already have one. Under _Firebase SDK snippet_ choose _Config_ to get the configuration as JSON. It will include keys like `apiKey` and `authDomain`. Set the appropriate environment variables in the `.env.local` file at the root of this project.
- Go to **Develop**, click on **Realtime Database** and create a database if you don't already have one. Under _data_ get `databaseUrl`(e.g. `https://[dbname].firebaseio.com/`). Set the appropriate environment variables in the `.env.local` file at the root of this project.
- Go to **Develop**, click on **Authentication** and in the **Sign-in method** tab enable authentication for the app.

Install it and run:

```bash
npm install
npm run dev
# or
yarn
yarn dev
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).

After deploying, copy the deployment URL and navigate to your Firebase project's Authentication tab. Scroll down in the page to "Authorized domains" and add that URL to the list.
Check out the [next-firebase-auth](https://github.com/gladly-team/next-firebase-auth) package and their [official example](https://github.com/gladly-team/next-firebase-auth/tree/main/example) for a powerful implementation of Firebase authentication.
42 changes: 0 additions & 42 deletions examples/with-firebase-authentication/components/FirebaseAuth.js

This file was deleted.

20 changes: 0 additions & 20 deletions examples/with-firebase-authentication/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions examples/with-firebase-authentication/pages/api/getFood.js

This file was deleted.

14 changes: 0 additions & 14 deletions examples/with-firebase-authentication/pages/auth.js

This file was deleted.

17 changes: 0 additions & 17 deletions examples/with-firebase-authentication/pages/example.js

This file was deleted.

63 changes: 0 additions & 63 deletions examples/with-firebase-authentication/pages/index.js

This file was deleted.

24 changes: 0 additions & 24 deletions examples/with-firebase-authentication/utils/auth/firebaseAdmin.js

This file was deleted.

15 changes: 0 additions & 15 deletions examples/with-firebase-authentication/utils/auth/initFirebase.js

This file was deleted.

This file was deleted.

65 changes: 0 additions & 65 deletions examples/with-firebase-authentication/utils/auth/useUser.js

This file was deleted.

0 comments on commit 6882f4e

Please sign in to comment.