Skip to content

Commit 57dbc50

Browse files
committed
Update static site docs
1 parent 931ca00 commit 57dbc50

File tree

2 files changed

+97
-87
lines changed

2 files changed

+97
-87
lines changed

_overviews/scala3-scaladoc/blog.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,17 @@ Blog is treated a little differently than regular static sites. This article wil
1515

1616
## Proper directory setup
1717

18-
All your blogposts must be put under `blog/_posts` directory.
18+
All your blogposts must be put under `_blog/_posts` directory.
1919

2020

2121
```
22-
├── blog
22+
├── _blog
2323
│ ├── _posts
2424
│ │ └── 2016-12-05-implicit-function-types.md
2525
│ └── index.html
2626
```
2727

28-
If you are using yaml [sidebar]({% link _overviews/scala3-scaladoc/static-site.md %}#sidebar) don't forget to place
29-
30-
```
31-
sidebar:
32-
- title: Blog
33-
```
34-
35-
somewhere inside the `yaml` tree representing the sidebar sections. Scaladoc will attach under that section all of your blogposts.
28+
Scaladoc loads blog if the `_blog` directory exists.
3629

3730
## Naming convention
3831

_overviews/scala3-scaladoc/static-site.md

Lines changed: 94 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ and will from here on be referred to as "template files" or "templates".
2020
A simple "hello world" site could look something like this:
2121

2222
```
23-
├── docs
24-
│ └── getting-started.md
25-
└── index.html
23+
.
24+
└── <site-root>/
25+
└── _docs/
26+
├── index.html
27+
└── getting-started.html
2628
```
2729

2830
This will give you a site with the following files in generated documentation:
2931

3032
```
3133
index.html
32-
docs/getting-started.html
34+
getting-started.html
3335
```
3436

3537
Scaladoc can transform both files and directories (to organize your documentation into a tree-like structure). By default, directories have a title based on the file name and have empty content. It is possible to provide index pages for each section by creating `index.html` or `index.md` (not both) in the dedicated directory.
@@ -98,63 +100,65 @@ Layouts must be placed in a `_layouts` directory in the site root:
98100
```
99101
├── _layouts
100102
│ └── main.html
101-
├── docs
102-
│ └── getting-started.md
103-
└── index.html
103+
└── _docs
104+
└── getting-started.md
105+
```
106+
107+
## Assets
108+
109+
In order to render assets along with static site, they need to be placed in the `_assets` directory in the site root:
110+
```
111+
├── _assets
112+
│ └── images
113+
│ └── myimage.png
114+
└── _docs
115+
└── getting-started.md
116+
```
117+
To reference the asset in a page, one need to create link relative to the `_assets` directory
118+
119+
```
120+
Take a look at the following image: [My image](images/myimage.png)
104121
```
105122

106123
## Sidebar
107124

108-
Scaladoc by default uses layout of files in `docs` directory to create table of content. There is also ability to override it by providing a `sidebar.yml` file in the site root:
125+
Scaladoc by default uses layout of files in `_docs` directory to render static site. There is also ability to override it by providing a `sidebar.yml` file in the site root. The YAML configuration file describes the structure of rendered static site and the table of content:
109126

110127
```yaml
111-
sidebar:
112-
- title: Blog
113-
- title: My title
114-
page: my-page1.md
115-
- page: my-page2.md
116-
- page: my-page3/subsection
117-
- title: Reference
118-
subsection:
119-
- page: my-page3.md
120-
- index: my-page4/index.md
121-
subsection:
122-
- page: my-page4/my-page4.md
123-
- title: My subsection
124-
index: my-page5/index.md
125-
subsection:
126-
- page: my-page5/my-page5.md
127-
- index: my-page6/index.md
128-
subsection:
129-
- index: my-page6/my-page6/index.md
130-
subsection:
131-
- page: my-page6/my-page6/my-page6.md
132-
```
133-
134-
The `sidebar` key is mandatory.
135-
On each level, you can have three different types of entries: `page`, `blog` or `subsection`.
136-
137-
`page` is a leaf of the structure and accepts the following attributes:
138-
- `title` (optional) - title of the page
139-
- `page` (mandatory) - path to the file that will represent the page, it can be either html or markdown file to be rendered, there is also the possibility to pass the `directory` path. If so, the scaladoc will render the directory and all its content as if there were no `sidebar.yml` basing on its tree structure and index files.
140-
141-
The `page` property `subsection` accepts nested nodes, these can be either pages or subsections, which allow you to create tree-like navigation. The attributes are:
142-
- `title` (optional) - title of the page
143-
- `index` (optional) - path to the file that will represent the index file of the subsection, it can be either html or markdown file to be rendered
144-
- `subsection` (mandatory) - nested nodes, can be either pages or subsections
145-
146-
In `subsection`s, you can omit `title` or `index`, however not specifying any of these properties prevents you from specifying the title of the section.
147-
148-
`blog` is a special node represented by simple entry `- title: Blog` with no other attributes. All your blog posts will be automatically linked under this section. You can read more about the blog [here]({% link _overviews/scala3-scaladoc/blog.md %}).
149-
150-
```
151-
├── blog
152-
│ ├── _posts
153-
│ │ └── 2016-12-05-implicit-function-types.md
154-
│ └── index.html
155-
├── index.html
156-
└── sidebar.yml
157-
```
128+
rootIndex: index.html
129+
pages:
130+
- title: Usage
131+
index: usage/index.html
132+
directory: usage
133+
subsection:
134+
- title: Dottydoc
135+
page: usage/dottydoc.html
136+
hidden: false
137+
- title: sbt-projects
138+
page: usage/sbt-projects.html
139+
hidden: false
140+
```
141+
The `rootIndex` property defines the root page of a static site: `_docs/index.html`
142+
The `pages` key is mandatory. Its value should be array of `subsection` or `page`.
143+
Nesting subsections will result in a tree-like structure of navigation.
144+
145+
`subsection` properties are:
146+
- `title` - Optional string - A default title of the subsection.
147+
Front-matter titles have higher priorities.
148+
- `index` - Optional string - A path to index page of a subsection.
149+
- `directory` - Optional string - A name of the directory that will contain the subsection.
150+
By default, the directory name is the subsection name converted to kebab case.
151+
- `subsection` - Array of `subsection` or `page`.
152+
153+
Either `index` or `subsection` must be defined. The subsection defined with `index` and without `subsection` will contain pages and directories loaded recursively from directory of the index page.
154+
155+
`page` properties are:
156+
- `title` - Optional string - A default title of the page.
157+
Front-matter titles have higher priorities.
158+
- `page` - String - A path to the page
159+
- `hidden` - Optional boolean - A flag that indicates whether the page should be visible in navigation. By default, it is set to `false`.
160+
161+
**Note**: All paths in YAML configuration file are relative to `<static-root>/_docs`.
158162

159163
## Hierarchy of title
160164

@@ -174,30 +178,43 @@ If the title is specified multiple times, the priority is as follows (from highe
174178

175179
Note that if you skip the `index` file in your tree structure or you don't specify the `title` in the frontmatter, there will be given a generic name `index`. The same applies when using `sidebar.yml` but not specifying `title` nor `index`, just a subsection. Again, a generic `index` name will appear.
176180

181+
## Blog
182+
Blog feature is described in [a separate document]({% link _overviews/scala3-scaladoc/blog.md %})
177183

178-
## Static resources
179-
180-
You can attach static resources (pdf, images) to your documentation by using two dedicated directories:
181-
`resources` and `images`. After placing your assets under any of these directories, you can reference them in markdown
182-
as if they were relatively at the same level.
183-
184-
For example, consider the following situation:
185-
184+
## Advanced configuration
185+
### Full structure of site root
186186
```
187-
├── blog
188-
│ ├── _posts
189-
│ │ └── 2016-12-05-implicit-function-types.md
190-
│ └── index.html
191-
├── index.html
192-
├── resources
193-
│ └── my_file.pdf
194-
├── images
195-
│ └── my_image.png
196-
└── sidebar.yml
197-
187+
.
188+
└── <site-root>/
189+
├── _layouts_/
190+
│ └── ...
191+
├── _docs/
192+
│ └── ...
193+
├── _blog/
194+
│ ├── index.md
195+
│ └── _posts/
196+
│ └── ...
197+
└── _assets/
198+
├── js/
199+
│ └── ...
200+
├── img/
201+
│ └── ...
202+
└── ...
198203
```
204+
It results in static site containing documents as well as blog. It also contains custom layouts and assets. The structure of rendered documentation can be based on file system but it can also be overriden by YAML configuration.
199205
200-
You can refer to the assets from within any of the files using markdown links:
206+
### Mapping directory structure
201207
202-
```
203-
This is my blog post. Here is the image ![](my_image.png) and here is my [pdf](my_file.pdf)```
208+
Using YAML configuration file, we can define how the source directory structure should be transformed in target directory structure.
209+
210+
Take a look at following subsection definition:
211+
```yaml
212+
- title: Some other subsection
213+
index: abc/index.html
214+
directory: custom-directory
215+
subsection:
216+
- page: abc2/page1.md
217+
- page: foo/page2.md
218+
```
219+
This subsection shows the ability of YAML configuration to map the directory structure.
220+
Even though the index page and all defined children are in different directories, they will be rendered in `custom-directory`.

0 commit comments

Comments
 (0)