Skip to content

Commit

Permalink
update the init template
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Mar 12, 2021
1 parent 0a95506 commit a0bd2d5
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 192 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Create a Blog Post
---

This page will help you on how to create blog posts in Docusaurus.

## Create a Blog Post

Create a file at `blog/2021-02-28-greetings.md`:

```md title="blog/2021-02-28-greetings.md"
---
title: Greetings!
author: Steven Hansel
author_title: Docusaurus Contributor
author_url: https://github.com/ShinteiMai
author_image_url: https://github.com/ShinteiMai.png
---

Congratulations, you have made your first post!

Feel free to play around and edit this post as much you like.
```

A new blog post is now available at `http://localhost:3000/blog/greetings`.
57 changes: 0 additions & 57 deletions packages/docusaurus-init/templates/classic/docs/create-a-doc.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Create a Document
---

Documents are pages with a **sidebar**, a **previous/next navigation** and many other useful features.

## Create a Document

Create a markdown file at `docs/my-doc.md`:

```mdx title="docs/hello.md"
---
title: Hello, World!
---

## Hello, World!

This is your first document in **Docusaurus**, Congratulations!
```

A new document is now available at `http://localhost:3000/docs/hello`.

## Add your document to the sidebar

Add `hello` to the `sidebars.js` file:

```diff title="sidebars.js"
module.exports = {
docs: [
{
type: 'category',
label: 'Docusaurus Tutorial',
- items: ['getting-started', 'create-a-doc', ...],
+ items: ['getting-started', 'create-a-doc', 'hello', ...],
},
],
};
```
53 changes: 23 additions & 30 deletions packages/docusaurus-init/templates/classic/docs/create-a-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,44 @@
title: Create a Page
---

This page will help you to create standalone pages in Docusaurus, either with React or Markdown.
Any React or Markdown file created under `src/pages` directory is converted into a website page:

## Creating a React Page
- `src/pages/index.js` -> `localhost:3000/`
- `src/pages/foo.md` -> `localhost:3000/foo`
- `src/pages/foo/bar.js` -> `localhost:3000/foo/bar`

Create a file: `./src/pages/react.js`
## Create a React Page

```jsx title="/src/pages/react.js"
import React from "react";
Create a file at `src/pages/my-react-page.js`:

```jsx title="src/pages/my-react-page.js"
import React from 'react';
import Layout from '@theme/Layout';

function HelloWorld() {
return (
<Layout title="Hello!">
<div>
<h1>Hello, World!</h1>
</div>
</Layout>
)
return (
<Layout>
<h1>My React page</h1>
<p>This is a React page</p>
</Layout>
);
}
```

Save the file, and the development server will automatically reload the changes. Open `http://localhost:3000/react`, to see the page that you just created with React.
A new page is now available at `http://localhost:3000/my-react-page`.

## Creating a Markdown Page
## Create a Markdown Page

Create a file: `/src/pages/markdown.md`
Create a file at `src/pages/my-markdown-page.md`:

```mdx title="/src/pages/markdown.md"
```mdx title="src/pages/my-markdown-page.md"
---
title: Hello, World!
description: This is a page created with Markdown
title: My Markdown page
---

# Hello, World!
# My Markdown page

This is a Markdown page
```

Save the file, and the development server will automatically reload the changes. Open `http://localhost:3000/markdown`, to see the page that you just created with Markdown.

## Routing

Any JavaScript (React) or Markdown files that you create under `/src/pages` directory will be automatically converted into a website page.

Here are some examples:

- `/src/pages/index.js` -> `localhost:3000/`
- `/src/pages/foo.js` -> `localhost:3000/foo`
- `/src/pages/foo/bar.js` -> `localhost:3000/foo/bar`
A new page is now available at `http://localhost:3000/my-markdown-page`.
31 changes: 0 additions & 31 deletions packages/docusaurus-init/templates/classic/docs/create-a-post.md

This file was deleted.

20 changes: 9 additions & 11 deletions packages/docusaurus-init/templates/classic/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
---
title: Getting Started
title: Getting Started
slug: /
---

## Setting up the development environment

### Step 1: Generate a Docusaurus site
## Step 1: Generate a new Docusaurus site

If you haven't already, generate a new Docusaurus site using the classic template:

```shell
npx @docusaurus/init@latest init my-documentation classic
npx @docusaurus/init@latest init my-website classic
```

### Step 2: Start your Docusaurus site
## Step 2: Start your Docusaurus site

Run the development server:
Run the development server in the newly created `my-website` folder:

```shell
cd my-website

npx docusaurus start
```

Open `docs/getting-started.md` and edit some lines. The site should reload automatically and display your changes.
Open `docs/getting-started.md` and edit some lines. The site reloads automatically and display your changes.

### That's it!
## That's it!

Congratulations! You've successfully run and modified your Docusaurus project.


27 changes: 0 additions & 27 deletions packages/docusaurus-init/templates/classic/docs/interactiveDoc.mdx

This file was deleted.

Loading

0 comments on commit a0bd2d5

Please sign in to comment.