This document is a guide for adding content to the spine.io site.
Table of Contents
- Using URLs in Markdown
- Adding collapsible list for sidebar navigation
- Adding code samples to the site
- Testing broken links
- Adding email links
- Managing the “Prev”/“Next” buttons in the documentation
- Using a language switcher for source code samples
Table of contents generated with markdown-toc
There are thee rules to follow:
Good | Bad |
---|---|
href="{{ site.baseurl }}{{ post.url }}" |
href="{{ site.baseurl }}/{{ post.url }}" |
This removes the double-slash from your site's URLs.
Good | Bad |
---|---|
href="{{ site.baseurl }}{{ post.url }}" |
href="{{ post.url }}" |
This fixes almost all of the in-site links. The next rule covers the remainder.
Exception: Start hyperlinks with {{ site.url }}{{ site.baseurl }}
in feed pages, like atom.xml
.
Good | Bad |
---|---|
href="{{ site.baseurl }}/" title="Home" |
href="{{ site.baseurl }}" title="Home" |
Good | Bad |
---|---|
href="{{ site.baseurl }}/public/favicon.ico" |
href="{{ site.baseurl }}public/favicon.ico" |
Visit Configuring Jekyll for Project GitHub Pages and for User GitHub Pages if you want to know why these rules should be followed.
All these URLs lead to the same page: /docs
, /docs/
, /docs/index
, /docs/index.html
.
But if you use them all throughout the site, it will create problems for search crawlers.
Please stick to these rules for using links on the site.
Good | Bad |
---|---|
{{ site.baseurl }}/docs/introduction/ |
{{ site.baseurl }}/docs/introduction/index |
Good | Bad |
---|---|
{{ site.baseurl }}/docs/introduction/rules |
{{ site.baseurl }}/docs/introduction/rules.html |
For collapsible categories we use the Bootstrap Collapse component.
For instructions on adding or changing sidebar navigation, please see the Navigation Author Guide.
Please see this document for the instructions.
We use the html-proofer tool to test broken links. To start test locally you may be required to install the Gem of the tool first:
bundle install
... and then build the site:
jekyll build
After that, please use the following command:
./_script/proof-links
We only log errors falling within the 4xx status code range. Please note that links to GitHub are ignored by --http-status-ignore "429" command, because GitHub rejects the check coming from htmlproofer. Details of this are described in this issue.
Also, we have a GitHub Action which tests the links when the pull request is created to the master
.
Please see the .github/workflows/proof-links.yml
file for details.
We use the Jekyll Email Protect to protect our
email addresses from spam bots. We store all email variables in the _data/support.yml
file.
<a href="mailto:{{ 'example@example.com' | encode_email }}">{{ 'example@example.com' | html_encode_email }}</a>
Or through a variable:
<a href="mailto:{{ site.data.support.email | encode_email }}">{{ site.data.support.email | html_encode_email }}</a>
The above code will yield:
<a href="%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65.%63%6F%6D">%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65.%63%6F%6D</a>
In markdown files we cannot obfuscate the link text, so it would be safer to use something like Contact us
.
[{{ Contact us }}](mailto:{{ site.data.support.email | encode_email }})
The above code will yield:
<a href="%65%78%61%6D%70%6C%65@%65%78%61%6D%70%6C%65.%63%6F%6D">Contact us</a>
The “Prev”/“Next” buttons are generated automatically for all document pages. The generation is
based on the doc_side_nav.yml
navigation.
To customize the automatically added “Prev”/“Next” buttons, add the appropriate variables to the front matter block of the document page.
prev_btn: false
next_btn: false
prev_btn:
page: Development Process Overview
next_btn:
page: Development Process Overview
prev_btn:
page: Development Process Overview
url: /docs/introduction/
next_btn:
page: Architecture Overview
url: /docs/introduction/architecture.html
Related files:
_includes/doc-next-prev-nav.html
- the navigation template with the automatic button generation;_sass/modules/_doc-next-prev-nav.scss
- navigation styles;_layouts/docs.html
- the documentation layout where thedoc-next-prev-nav
is included.
The switch state will be saved globally so that the user can navigate between pages.
To show language tabs use the structure below.
Add a lang
attribute with Java
, Kotlin
, JavaScript
or any other language value
for div
s with content. If no language is provided, the content will not be displayed.
<div class="code-tabs">
<div class="code-tab-content" lang="Java">
Any Java content here
</div>
<div class="code-tab-content" lang="Kotlin">
Any Kotlin content here
</div>
<div class="code-tab-content" lang="JavaScript">
Any JavaScript content here
</div>
</div>
In markdown, all tags should be left-aligned. This way, the blocks of code will not be broken:
<div class="code-tabs">
<div class="code-tab-content" lang="Java">
Any Java content here
</div>
<div class="code-tab-content" lang="Kotlin">
Any Kotlin content here
</div>
<div class="code-tab-content" lang="JavaScript">
Any JavaScript content here
</div>
</div>
If you don't need to display the tabs, but only need to show a specific paragraph of text or change the title depending on the language, just use this:
<div class="code-tab-content" lang="Java">
# Getting started with Spine in Java
</div>
<div class="code-tab-content" lang="Kotlin">
# Getting started with Spine in Kotlin
</div>
To change only some of the words in a sentence, use the <span>
tag with the .inline
class:
A minimal client-server application in
<span class="code-tab-content inline" lang="Java">Java</span>
<span class="code-tab-content inline" lang="Kotlin">Kotlin</span>
which handles one command to print some text...
Related files
The files are stored in the documentation
repository.
_sass/base/_code-tabs.scss
- styles for the code tabs;tools/code-tabs.js
- code tab implementation.