Skip to content

Commit 4e389c6

Browse files
committed
Update docs.
1 parent 206c979 commit 4e389c6

File tree

4 files changed

+127
-17
lines changed

4 files changed

+127
-17
lines changed

homepage/data/docs.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Goffre | Documentation
2+
title: Documentation
33
---
44

5-
## `load(options)`
5+
## `async load(options)`
66

77
Loads data from a folder, returns structured information gathered from `.md` and `.json` files.
88

@@ -59,14 +59,103 @@ Will be parsed as:
5959
}
6060
```
6161

62-
Available options:
62+
### Available options
6363

64-
### `dataPath`
64+
#### `dataPath`
6565

6666
Path where to look for data.
6767

6868
**Default**: `process.cwd() + /data`.
6969

70-
## `render(options)`
70+
## `async render(options)`
7171

7272
Generates the `.html` files.
73+
74+
### Available options
75+
76+
#### `pages`
77+
78+
An array of pages, ideally parsed via the `load()` method.
79+
80+
The only constraint is to contain a unique `slug` key, like:
81+
82+
```js
83+
[
84+
{
85+
title: 'This is a blog post',
86+
slug: "blog/01-this-is-a-blog-post",
87+
content: ...
88+
},
89+
{
90+
title: 'This is another blog post',
91+
slug: "blog/02-this-is-another-blog-post",
92+
content: ...
93+
},
94+
...
95+
]
96+
```
97+
98+
#### `viewsPath`
99+
100+
The folder containing the handlebars views.
101+
102+
**Default**: `path.join(process.cwd(), "src", "views")`.
103+
104+
#### `buildPath`
105+
106+
The folder that will contain the HTML output.
107+
108+
**Default**: `path.join(process.cwd(), "dist")`.
109+
110+
#### `domain`
111+
112+
The website domain, used in the handlebars helpers for generating URLs.
113+
114+
#### `uglyUrls`
115+
116+
If `true`, appends `.html` to generated URLs.
117+
118+
**Default**: `false`.
119+
120+
#### `locals`
121+
122+
An object that will be merged into `apps.locals` and be available to all handlebars templates.
123+
124+
#### `markdown`
125+
126+
Overrides the [default markdown configuration][marked], e.g.:
127+
128+
```js
129+
render({
130+
...
131+
markdown: {
132+
renderer: {
133+
image: (href, title, text) =>
134+
`<img class="lazy" data-src="${href}" alt="${text}"/>`,
135+
},
136+
}
137+
})
138+
```
139+
140+
#### `handlebars`
141+
142+
Contains the handlebars configurations and helpers, e.g.:
143+
144+
```js
145+
render({
146+
...
147+
handlebars: {
148+
helpers: {
149+
formatDate: (date) => date.toLocaleDateString(),
150+
},
151+
}
152+
})
153+
```
154+
155+
#### `sitemap`
156+
157+
Contains the sitemap configuration.
158+
159+
**Default**: `{ generate: false, template: 'sitemap' }`.
160+
161+
[marked]: https://github.com/markedjs/marked

homepage/src/client/css/style.css

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ aside ul li {
5050
margin-bottom: 0.5rem;
5151
}
5252

53+
aside ul li.from-h3 {
54+
margin-left: 1rem;
55+
}
56+
aside ul li.from-h4 {
57+
margin-left: 1.5rem;
58+
}
59+
5360
aside ul li:last-child {
5461
margin-bottom: 0;
5562
}
@@ -126,17 +133,14 @@ body > footer {
126133
margin-bottom: 2rem;
127134
}
128135

129-
.page {
130-
}
131-
132-
.page.text {
133-
/* max-width: 50rem; */
134-
}
135-
136136
.page > header {
137137
margin-bottom: 2rem;
138138
}
139139

140+
.page > header h1 span:last-child {
141+
color: rgba(0, 0, 0, 0.5);
142+
}
143+
140144
.text-body > * {
141145
margin-bottom: 2rem;
142146
}
@@ -255,6 +259,19 @@ body > footer {
255259
text-overflow: ellipsis;
256260
}
257261

262+
.page-docs .page.text h4 {
263+
margin-top: 5rem;
264+
margin-bottom: 1rem;
265+
}
266+
267+
.page-docs .page.text h4 + p {
268+
margin-bottom: 1rem;
269+
}
270+
271+
.page-docs .page.text p + pre {
272+
margin-top: 0rem;
273+
}
274+
258275
@media screen and (max-width: 1024px) {
259276
aside {
260277
display: none;
@@ -275,8 +292,7 @@ body > footer {
275292

276293
@media screen and (max-width: 480px) {
277294
.page-index main > section h1 {
278-
font-size: 2rem;
279-
text-align: center;
295+
font-size: 2.5rem;
280296
}
281297
body {
282298
position: relative;

homepage/src/client/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function initOutline() {
2121
);
2222

2323
$titles.forEach((el) => {
24-
$aside.innerHTML += `<li><a href="#${el.id}">${el.innerText}</a></li>`;
24+
$aside.innerHTML += `<li class="from-${el.tagName.toLowerCase()}"><a href="#${
25+
el.id
26+
}">${el.innerText}</a></li>`;
2527
observer.observe(el);
2628
});
2729

@@ -33,7 +35,6 @@ function initOutline() {
3335
const $target = document.getElementById(
3436
event.target.href.split("#")[1]
3537
);
36-
console.log($target);
3738
if (!$target) {
3839
return;
3940
}
@@ -42,6 +43,7 @@ function initOutline() {
4243
behavior: "smooth",
4344
block: "center",
4445
});
46+
history.replaceState(null, null, event.target.href);
4547
});
4648
}
4749

homepage/src/views/_default.handlebars

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<section class="page text">
22
<header>
3-
<h1>{{title}}</h1>
3+
<h1>
4+
<span>Goffre</span>
5+
<span>{{title}}</span>
6+
</h1>
47
</header>
58
<section class="text-body">
69
{{{content}}}

0 commit comments

Comments
 (0)