Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b300bb4

Browse files
committed
feat: Update homepage
1 parent df991d4 commit b300bb4

File tree

1 file changed

+67
-45
lines changed

1 file changed

+67
-45
lines changed

docs/README.md

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Files needed to build a docs site with _Docsify_:
2525

2626
Once you have that setup in _docs_ directory and have pushed to Github, you can setup Github Pages serving the _docs_ directory. Note: _Docsify_ also works with _Netlify_ as per their docs, but this project just considers the Github Pages case.
2727

28-
2928
## Get a local copy of this repo
3029

3130
```
@@ -39,6 +38,29 @@ $ git clone https://github.com/MichaelCurrin/docsify-template.git
3938
$ cd docsify-template
4039
```
4140

41+
## Doc links
42+
43+
Instructions for creating valid Docsify links in your markdown files.
44+
45+
The _Docsify_ site is served from the `docs` directory with restrictions on links between files. Therefore you must ensure your markdown files (including the [sidebar](#sidebar)) are valid.
46+
47+
As usual external resource can be linked e.g. `https://example.com`.
48+
49+
## Rules for internal links
50+
51+
Apply these rules to the latter part of markdown URLs such as `[Text](page.md)`.
52+
53+
- Links must always be relative to the `docs` directory and **not** to the file containing the link.
54+
- e.g. `foo.md`, which becomes `/#/foo`.
55+
- e.g. `baz/fizz.md`, which becomes `/#/baz/fizz`.
56+
- Links may contain a leading forward slash. This has no effect so can be ignored.
57+
- e.g. `/foo.md`, which becomes `/#/foo`.
58+
- Links may use an ID.
59+
- e.g. To link to heading on the homepage, use `#my-project`, which gets converted to `/#/?id=my-project`.
60+
- e.g. To link to another page, use `foo.md#my-project`.
61+
- Do not reference the `docs` directory in the path. e.g. `/docs/foo.md`
62+
- Do not refer to content outside of the `docs` directory. e.g. `../README.md`
63+
4264

4365
## Quickstart local server
4466

@@ -98,25 +120,18 @@ Clone this template repo to your machine using the [steps](#get-a-local-copy-of-
98120

99121
### 2. Create base structure
100122

101-
Navigate to your existing project's `docs` directory.
102-
103-
```bash
104-
$ cd <PATH_TO_YOUR_REPO>/docs
105-
```
106-
107-
Create a file for Github Pages to use. This can remain empty - its existence just tells Github Pages to include the underscore files in builds.
108-
109-
```bash
110-
$ touch .nojekyll
111-
```
123+
1. Navigate to your existing project's `docs` directory.
124+
```bash
125+
$ cd <PATH_TO_YOUR_REPO>/docs
126+
```
127+
2. Copy the copy the contents of the template project's _quickstart_ directory to your own project. Note the trailing dot on the first path in order to include hidden files.
128+
```bash
129+
$ cp <PATH_TO_TEMPLATE_REPO>/quickstart/. .
130+
```
112131

113-
Copy the template files from the template project's _quickstart_ directory to your own project.
132+
Note that you do not need a page for `404 - Not found` as Docsify renders one for you.
114133

115-
```bash
116-
$ cp <PATH_TO_TEMPLATE_REPO>/quickstart/* .
117-
```
118-
119-
Start serving your docs folder now even though it is incomplete. Then, as you follow the customization steps below, you can check to see what changes on the frontend.
134+
Your existing markdown files in your `docs` directory can now be served as a doc site. You may run a [serve](#21-serve) command now. Then, as you follow the customization steps below, you can check the frontend for incremental changes for areas like styling and fixing links.
120135

121136

122137
### 3. Configure homepage
@@ -130,49 +145,56 @@ Edit the _docs/README.md_ homepage. Complete the `TODO` items, using the suggest
130145

131146
### 4. Configure menu structure
132147

133-
#### Doc links
148+
If for some reason you do not want a navigation sidebar on the frontend, then delete *_sidebar.md* from your _docs_ directory, set the sidebar option to `false` in _index.html_ and skip to the next section - [Configure Cover Page](#5-configure-cover-page)
134149

135-
If you have put links from one of your doc files to another, you might have to edit your existing doc files to avoid the links breaking when viewed as docs site.
150+
The sidebar is enabled in _index.html_ of the quickstart. A Docsify site is unaware of project structure, unless you provide it.
136151

137-
References should be relative to the _docs_ directory not to the file itself, even if a file is inside a directory within _docs_. This is unlike the expected of markdown.
152+
#### Auto sidebar
138153

139-
Any link references which start as `docs/file.md` or `/docs/file.md` will cause errors, because the server is only aware of directories within _docs_.
154+
You may choose to display the sidebar, but have it populated automatically from headings on the homepage (_docs/README.md_).
140155

141-
#### Sidebar
156+
This solution is great if you are happy to move all your doc content into a **single** markdown file, as it means not having to worry about manually updating a navigation bar when you docs change. Especially if you have a many files to manage or they are likely to change in name or structure.
142157

143-
The sidebar is the menu page on the left of the docs and shows on all pages.
158+
To setup auto sidebar:
144159

145-
If you **do not** want to configure a sidebar, delete *_sidebar.md* from your _docs_ directory, set the sidebar option to `false` in _index.html_ and skip to the next section.
160+
1. Delete *_sidebar.md*.
161+
2. Open _index.html_ to edit it.
162+
3. Set `loadSidebar: false` and save.
146163

147-
If you **do** have files in your _docs_ directory you want to appear in the menu page, then edit the *_sidebar.md* file. The format should be markdown bullet points which can be nested. Include links to you files - note that paths are relative to docs directory.
164+
Warning: If you go for this option without a configured sidebar, do not leave any links in your _docs/README.md_ which refer to other doc files. Although the link may be valid, once you click on the link, the sidebar on that page will reflect the target page rather than the outline of the _docs/README.md_ page, which is inconsistent and jarring behavior.
148165

149-
Here is an example sidebar config:
166+
#### Custom sidebar
150167

151-
```markdown
152-
- [Foo](foo.md)
153-
- [Bar](bar.md)
154-
- Baz
155-
* [Fizz](baz/fizz.md)
156-
* [Foo Bar](baz/foobar.md)
157-
```
168+
You can choose to configure a custom sidebar. This is necessary to link to the multiple doc files.
169+
170+
Guidelines for setting up a sidebar file:
158171

159-
##### Sidebar without config
172+
- The format should be bullet points in markdown format.
173+
- Each menu item should be a markdown link e.g. `[Name](link)`. An item may exist on the menu without a link - this is useful for grouping items together under a menu heading.
174+
- The links must be follow restrictions noted above in [Doc links](#doc-links). If the doc files change (e.g. are renamed or moved), you need to remember to update the sidebar config.
175+
- The bullet points may optionally be nested, using indentation. You may create arbitrary indentation in your sidebar, even if all you files are at the same level in the _docs_ directory.
160176

161-
You could have a sidebar enabled in _index.html_, but without sidebar config set (empty file or no file). Then your index page will use its **own** page outline as the menu. But with no access to subpages, as _Docsify_ is not aware of them_.
162177

163-
You may even **want** your entire site to be a single page based on _README.md_ content and no other doc files. As you will get the benefit of the look of a single page site and any section headings added to your menu will be added to your menu pane automatically (no need to maintain a sidebar file).
178+
To setup a custom sidebar:
164179

165-
##### Link to homepage
180+
1. Edit the *_sidebar.md* file.
181+
2. Add items. Example:
182+
```markdown
183+
- [Home](#docsify-template)
184+
- [Foo](foo.md)
185+
- [Bar](bar.md)
186+
- Baz
187+
* [Fizz](baz/fizz.md)
188+
* [Foo Bar](baz/foobar.md)
189+
```
166190
167-
The button at the top of sidebar is a link to site's root path. This will be the cover page, if you have one.
191+
#### Note on homepage link
168192
169-
If you a menu button which takes you to the homepage rather, add an item which has a reference to the root path plus with the ID of the heading of _docs/README.md_.
193+
The clickable text above the standard sidebar takes you to the cover page. You can scroll down to the homepage (_docs/README.md_), but there are no links on the page to the homepage. Therefore a link to the homepage has been included in the example above.
170194
171-
e.g.
195+
More specifically, the link is a reference to an anchor tag on the root URL, where anchor tag refers the ID of the homepage heading element.
172196
173-
```
174-
- [Home](/#my-project)
175-
```
197+
This ID is created already by _Docsify_. To find it, go to the coverpage, scroll down to the homepage and click on the heading. The URL will be something like `http://localhost:3000/#/?id=docsify-template`. The part we want is the end e.g. `docsify-template`. This is really the text of heading element, which has been made lowercase and hyphenated. Copy this to the sidebar file and prefix it with a hash symbol.
176198
177199
### 5. Configure cover page
178200
@@ -243,7 +265,7 @@ If you want know a summary view of what the defaults are for the app on `index.h
243265
244266
## Setup Github Pages site
245267
246-
If you followed the steps above, you'll have a locally running docs site.
268+
If you followed the steps above, you'll have a locally running docs site.
247269
248270
Now, commit and push the files to Github.
249271

0 commit comments

Comments
 (0)