Skip to content

Commit feff14c

Browse files
authored
Merge pull request #8 from code-hike/with-docusaurus
Docusaurus example
2 parents b764324 + 08de904 commit feff14c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+16545
-0
lines changed

with-docusaurus/.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

with-docusaurus/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
This is an example website using Docusaurus (v3.5.0+) and Code Hike.
2+
3+
- [Code Hike](https://v1.codehike.org) - learn about Code Hike
4+
- [Docusaurus](https://docusaurus.io) - learn about Docusaurus
5+
6+
Clone it with:
7+
8+
```bash
9+
$ npx degit code-hike/examples/with-docusaurus my-docs
10+
$ cd my-docs
11+
```

with-docusaurus/babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

with-docusaurus/docs/intro.mdx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Docusaurus + Code Hike
6+
7+
For more information, check out [Code Hike docs](https://v1.codehike.org/docs).
8+
9+
```js
10+
const lorem = ipsum(dolor, sit)
11+
// !callout[/amet/] This is a callout
12+
const [amet, consectetur] = [0, 0]
13+
lorem.adipiscing((sed, elit) => {
14+
if (sed) {
15+
amet += elit
16+
}
17+
})
18+
```
+198
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
import { Scrollycoding } from "/src/components/scrollycoding"
6+
7+
# Scrollycoding
8+
9+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lectus elit, tincidunt consectetur auctor ac, dignissim eget dolor. Integer magna ante, dictum ut posuere sed, faucibus quis risus.
10+
11+
Phasellus id dolor lacinia, commodo nisl non, condimentum ante. Nam diam augue, tempor quis condimentum eget, luctus vitae felis. Aenean maximus ultrices massa ac viverra. Nullam tellus enim, tincidunt ac ligula eu, placerat vulputate justo. Vivamus non dui malesuada, mattis dolor vitae, aliquam ipsum. Sed dapibus nibh nisi, sit amet consectetur sapien scelerisque at.
12+
13+
<Scrollycoding>
14+
15+
## !!steps A Game of Thrones
16+
17+
A Game of Thrones is the first book in the A Song of Ice and Fire series by George R.R. Martin. Set in a world where seasons last for years, it introduces a complex plot and a wide cast of characters, ranging from noble families vying for the Iron Throne to the supernatural threats in the North.
18+
19+
{/* prettier-ignore */}
20+
```js ! george.js
21+
const houses = [
22+
"Stark",
23+
"Lannister",
24+
"Baratheon",
25+
"Targaryen",
26+
]
27+
28+
const winner =
29+
houses[
30+
Math.floor(
31+
Math.random() * houses.length,
32+
)
33+
]
34+
35+
console.log(`Iron Throne: ${winner}`)
36+
```
37+
38+
## !!steps A Clash of Kings
39+
40+
A Clash of Kings, the second book in the series, continues the epic saga. The Seven Kingdoms are plunged into war, with kings rising and falling. Meanwhile, Daenerys Targaryen seeks to return to Westeros with her growing dragons.
41+
42+
{/* prettier-ignore */}
43+
```js ! george.js
44+
const houses = [
45+
"Stark",
46+
"Lannister",
47+
"Baratheon",
48+
"Targaryen",
49+
]
50+
51+
const clash = () => {
52+
const winner =
53+
houses[
54+
Math.floor(
55+
Math.random() * houses.length,
56+
)
57+
]
58+
return `${winner} wins the battle!`
59+
}
60+
61+
console.log(clash())
62+
```
63+
64+
## !!steps A Storm of Swords
65+
66+
The third book, A Storm of Swords, is known for its intense and shocking developments. Battles rage on, alliances shift, and characters face unexpected challenges and betrayals, making it one of the most thrilling books in the series.
67+
68+
{/* prettier-ignore */}
69+
```js ! george.js
70+
const houses = [
71+
"Stark",
72+
"Lannister",
73+
"Baratheon",
74+
]
75+
76+
const reveal = () => {
77+
const traitor =
78+
houses[
79+
Math.floor(
80+
Math.random() * houses.length,
81+
)
82+
]
83+
return `${traitor} betrays the alliance!`
84+
}
85+
86+
console.log(reveal())
87+
```
88+
89+
## !!steps A Feast for Crows
90+
91+
A Feast for Crows, the fourth book, explores the aftermath of the wars, with a focus on the characters in the southern regions of Westeros. It delves into the politics and power struggles in a kingdom weary of battle.
92+
93+
{/* prettier-ignore */}
94+
```js ! george.js
95+
const houses = [
96+
"Martell",
97+
"Lannister",
98+
"Baratheon",
99+
"Tyrell",
100+
]
101+
102+
const intrigue = () => {
103+
const ally1 =
104+
houses[
105+
Math.floor(
106+
Math.random() * houses.length,
107+
)
108+
]
109+
const ally2 =
110+
houses[
111+
Math.floor(
112+
Math.random() * houses.length,
113+
)
114+
]
115+
return `${ally1} and ${ally2} form an alliance!`
116+
}
117+
118+
console.log(intrigue())
119+
```
120+
121+
## !!steps A Dance with Dragons
122+
123+
A Dance with Dragons, the fifth book, runs concurrently with A Feast for Crows and focuses on the characters in the North and across the Narrow Sea. The story advances with dragons, the Night’s Watch, and the lingering threat of winter.
124+
125+
{/* prettier-ignore */}
126+
```js ! george.js
127+
const houses = [
128+
"Stark",
129+
"Lannister",
130+
"Baratheon",
131+
"Targaryen",
132+
]
133+
134+
const dragons = () => {
135+
const dragon =
136+
houses[
137+
Math.floor(
138+
Math.random() * houses.length,
139+
)
140+
]
141+
return `${dragon} has a dragon!`
142+
}
143+
144+
console.log(dragons())
145+
```
146+
147+
## !!steps The Winds of Winter
148+
149+
The Winds of Winter, the anticipated sixth book, is expected to continue the intricate storylines and bring new twists and turns to the world of Westeros. Fans eagerly await its release.
150+
151+
```js ! george.js
152+
const houses = [
153+
"Stark",
154+
"Lannister",
155+
"Baratheon",
156+
"Targaryen",
157+
"Martell",
158+
"Tyrell",
159+
"Greyjoy",
160+
]
161+
162+
const winterIsComing = () => {
163+
const isComing = Math.random() > 0.99
164+
if (isComing) {
165+
return "Winter is coming!"
166+
} else {
167+
return "Winter is not coming."
168+
}
169+
}
170+
171+
console.log(winterIsComing())
172+
```
173+
174+
## !!steps A Dream of Spring
175+
176+
A Dream of Spring is the proposed final book in the series, anticipated to conclude the epic saga. It remains one of the most awaited books in modern fantasy literature.
177+
178+
```js ! george.js
179+
const houses = [
180+
"Stark",
181+
"Lannister",
182+
"Baratheon",
183+
"Targaryen",
184+
"Martell",
185+
"Tyrell",
186+
"Greyjoy",
187+
]
188+
189+
const keepDreaming = () => {
190+
return "Not gonna happen..."
191+
}
192+
193+
console.log(keepDreaming())
194+
```
195+
196+
</Scrollycoding>
197+
198+
Quisque id pretium neque. Vestibulum metus orci, pretium nec varius convallis, viverra quis urna. Praesent luctus, purus nec tempus placerat, justo lorem auctor ligula, ut condimentum tellus velit ac erat. Fusce ut dictum libero. Vestibulum ipsum mauris, cursus sed tortor at, rhoncus viverra ipsum. Donec odio dolor, varius quis congue posuere, tempor et justo. Praesent at scelerisque metus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed malesuada leo vitae mauris eleifend condimentum. Proin auctor, ex ac aliquam gravida, felis felis lacinia libero, efficitur aliquet nulla neque sed elit. Vestibulum congue aliquam risus, sit amet rutrum magna euismod ac. Integer posuere neque nec ex sollicitudin rhoncus.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Tutorial - Basics",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "5 minutes to learn the most important Docusaurus concepts."
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
sidebar_position: 6
3+
---
4+
5+
# Congratulations!
6+
7+
You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
8+
9+
Docusaurus has **much more to offer**!
10+
11+
Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
12+
13+
Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
14+
15+
## What's next?
16+
17+
- Read the [official documentation](https://docusaurus.io/)
18+
- Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
19+
- Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
20+
- Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
21+
- Add a [search bar](https://docusaurus.io/docs/search)
22+
- Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
23+
- Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# Create a Blog Post
6+
7+
Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
8+
9+
## Create your first Post
10+
11+
Create a file at `blog/2021-02-28-greetings.md`:
12+
13+
```md title="blog/2021-02-28-greetings.md"
14+
---
15+
slug: greetings
16+
title: Greetings!
17+
authors:
18+
- name: Joel Marcey
19+
title: Co-creator of Docusaurus 1
20+
url: https://github.com/JoelMarcey
21+
image_url: https://github.com/JoelMarcey.png
22+
- name: Sébastien Lorber
23+
title: Docusaurus maintainer
24+
url: https://sebastienlorber.com
25+
image_url: https://github.com/slorber.png
26+
tags: [greetings]
27+
---
28+
29+
Congratulations, you have made your first post!
30+
31+
Feel free to play around and edit this post as much as you like.
32+
```
33+
34+
A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Create a Document
6+
7+
Documents are **groups of pages** connected through:
8+
9+
- a **sidebar**
10+
- **previous/next navigation**
11+
- **versioning**
12+
13+
## Create your first Doc
14+
15+
Create a Markdown file at `docs/hello.md`:
16+
17+
```md title="docs/hello.md"
18+
# Hello
19+
20+
This is my **first Docusaurus document**!
21+
```
22+
23+
A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello).
24+
25+
## Configure the Sidebar
26+
27+
Docusaurus automatically **creates a sidebar** from the `docs` folder.
28+
29+
Add metadata to customize the sidebar label and position:
30+
31+
```md title="docs/hello.md" {1-4}
32+
---
33+
sidebar_label: 'Hi!'
34+
sidebar_position: 3
35+
---
36+
37+
# Hello
38+
39+
This is my **first Docusaurus document**!
40+
```
41+
42+
It is also possible to create your sidebar explicitly in `sidebars.js`:
43+
44+
```js title="sidebars.js"
45+
export default {
46+
tutorialSidebar: [
47+
'intro',
48+
// highlight-next-line
49+
'hello',
50+
{
51+
type: 'category',
52+
label: 'Tutorial',
53+
items: ['tutorial-basics/create-a-document'],
54+
},
55+
],
56+
};
57+
```

0 commit comments

Comments
 (0)