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

[legacy-framework] docs(tutorial): fix a couple typos and change some copy #344

Merged
merged 3 commits into from
Apr 30, 2020
Merged
Changes from 2 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
78 changes: 42 additions & 36 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,58 @@ This should create a `mysite` directory in your current directory.
Let’s look at what `blitz new` created:

```
mysite/
app/
components/
ErrorBoundary.tsx
layouts/
pages/
_app.tsx
_document.tsx
index.tsx
db/
integrations/
jobs/
node_modules/
public/
utils/
.babelrc.js
.env
.eslintrc.js
.gitignore
.npmrc
.prettierignore
blitz.config.js
package.json
README.md
tsconfig.json
mysite
├── app
│   ├── components
│   │   └── ErrorBoundary.tsx
│   ├── layouts
│   └── pages
│   ├── _app.tsx
│   ├── _document.tsx
│   └── index.tsx
├── db
│   ├── migrations
│   ├── index.ts
│   └── schema.prisma
├── integrations
├── jobs
├── node_modules
├── public
│   ├── favicon.ico
│   └── logo.png
├── utils
├── .babelrc.js
├── .env
├── .eslintrc.js
├── .gitignore
├── .npmrc
├── .prettierignore
├── README.md
├── blitz.config.js
├── package.json
├── tsconfig.json
└── yarn.lock
```

These files are:

- The `app/` directory is a container for most of your project. This is where you’ll put any pages or api routes.
- The `app/` directory is a container for most of your project. This is where you’ll put any pages or API routes.

- `db`/ is where your database configuration goes. If you’re writing models or checking migrations, this is where to go.

- `node_modules/` is where your “dependencies” are stored. This is an auto-generated directory, so you don’t have to worry too much about it.
- `node_modules/` is where your “dependencies” are stored. This directory is updated by your package manager, so you don’t have to worry too much about it.

- `public/` is a directory where you will put any static assets. If you have images, files, or videos which you want to use in your app, this is where to put them.

- `utils/` is a good place to put any share util files which you might use across different sections of your app.
- `utils/` is a good place to put any shared utility files which you might use across different sections of your app.

- `dotfiles (.babelrc.js, .env, etc)` are configuration files for various bits of JavaScript tooling.
- `.babelrc.js`, `.env`, etc. ("dotfiles") are configuration files for various bits of JavaScript tooling.

- `blitz.config.js` is for advanced custom configuration of Blitz. It extends [`next.config.js`](https://nextjs.org/docs/api-reference/next.config.js/introduction).

- `package.json` contains information about your dependencies and devDependencies. If you’re using a tool like `npm` or `yarn`, you won’t have to worry about this much.

- `tsconfig.json` - is our recommended setup for TypeScript.
- `tsconfig.json` is our recommended setup for TypeScript.

## The development server

Expand Down Expand Up @@ -201,7 +207,7 @@ Once you’re in the console, explore the Database API:

## Writing more pages

Let’s create some more pages. Blitz provides a handy utility for scaffolding out pages, called `generate`. Let’s run it now with our Question model:
Let’s create some more pages. Blitz provides a handy utility for scaffolding out pages, called `generate`. Let’s run it now with our `Question` model:

```sh
$ blitz generate all question
Expand All @@ -227,7 +233,7 @@ export const QuestionsList = () => {
}
```

This won’t work though! Remember that the Question model we created above doesn’t have any `name` field. To fix this, replace `question.name` with `question.text`:
This won’t work though! Remember that the `Question` model we created above doesn’t have any `name` field. To fix this, replace `question.name` with `question.text`:

```jsx
export const QuestionsList = () => {
Expand Down Expand Up @@ -283,7 +289,7 @@ Great! Now make sure your app is running. If it isn’t, just run `blitz start`

## Writing a minimal form

You’re doing great so far! The next thing we’ll do is give our form some real inputs. At the moment it’s giving every Question the same name! Have a look at `app/questions/pages/questions/new.tsx` in your editor.
You’re doing great so far! The next thing we’ll do is give our form some real inputs. At the moment it’s giving every `Question` the same name! Have a look at `app/questions/pages/questions/new.tsx` in your editor.

Delete the div that says: `<div>Put your form fields here. But for now, just click submit</div>`, and replace it with some inputs:

Expand Down Expand Up @@ -360,7 +366,7 @@ const NewQuestionPage = () => {
export default NewQuestionPage
```

## Listing choices.
## Listing choices

Time for a breather. Go back to `http://localhost:3000/questions` in your browser and look at all the questions you‘ve created. How about we list these questions’ choices here too? First, we need to customise the question queries. In Prisma, you need to manually let the client know that you want to query for nested relations. Change your `getQuestion.ts` and `getQuestions.ts` files to look like this:

Expand Down Expand Up @@ -569,8 +575,8 @@ export default ShowQuestionPage

- Adding styling
- Showing some more statistics about votes
- Deploying live so you can sent it around (we recommend [Vercel](https://vercel.com/))
- Deploying live so you can send it around (we recommend [Vercel](https://vercel.com/))

If you want to share your project with the world wide Blitz community there is no better place to do that than on Slack.

Just visit https://slack.blitzjs.com. Then, post the link to the #show-and-tell channel to share it with everyone!
Just visit https://slack.blitzjs.com. Then, post the link to the **#show-and-tell** channel to share it with everyone!