shiroa

Get Started

Once you have the shiroashiroa CLI tool installed, you can use it to create and render a book.

Initializing a book

The shiroa initshiroa init command will create a new directory containing an empty book for you to get started. Give it the name of the directory that you want to create:


                                
shiroa init my-first-book

                                
shiroa init my-first-book

                                
shiroa init my-first-book

                                
shiroa init my-first-book

It will emit template files to the my-first-bookmy-first-book. Then, you can change the current directory into the new book:


                                
cd my-first-book

                                
cd my-first-book

                                
cd my-first-book

                                
cd my-first-book

There are several ways to render a book, but one of the easiest methods is to use the serveserve command, which will build your book and start a local webserver:


                                
shiroa serve

                                
shiroa serve

                                
shiroa serve

                                
shiroa serve

Check out the shiroa helpshiroa help for more information about other shiroashiroa commands and CLI options.

Anatomy of a book

A book is built from several files which define the settings and layout of the book.

book.typbook.typ

If you are familiar with mdbookmdbook, the book.typbook.typ file is similar to the book.tomlbook.toml with summary.mdsummary.md file.

The book source file is the main file located at src/book.typsrc/book.typ. This file contains a list of all the chapters in the book. Before a chapter can be viewed, it must be added to this list.

Here's a basic summary file with a few chapters:


                                
#import "@preview/shiroa:0.2.3": *

                                
#show: book

                                


                                
#book-meta( // put metadata of your book like book.toml of mdbook

                                
  title: "shiroa",

                                
  description: "shiroa Documentation",

                                
  repository: "https://github.com/Myriad-Dreamin/shiroa",

                                
  authors: ("Myriad-Dreamin", "7mile"),

                                
  language: "en",

                                
  summary: [ // this field works like summary.md of mdbook

                                
    = Introduction

                                
    - #chapter("guide/installation.typ", section: "1.1")[Installation]

                                
    - #chapter("guide/get-started.typ", section: "1.2")[Get Started]

                                
      - #chapter(none, section: "1.2.1")[Drafting chapter]

                                
  ]

                                
)

                                
#import "@preview/shiroa:0.2.3": *

                                
#show: book

                                


                                
#book-meta( // put metadata of your book like book.toml of mdbook

                                
  title: "shiroa",

                                
  description: "shiroa Documentation",

                                
  repository: "https://github.com/Myriad-Dreamin/shiroa",

                                
  authors: ("Myriad-Dreamin", "7mile"),

                                
  language: "en",

                                
  summary: [ // this field works like summary.md of mdbook

                                
    = Introduction

                                
    - #chapter("guide/installation.typ", section: "1.1")[Installation]

                                
    - #chapter("guide/get-started.typ", section: "1.2")[Get Started]

                                
      - #chapter(none, section: "1.2.1")[Drafting chapter]

                                
  ]

                                
)

                                
#import "@preview/shiroa:0.2.3": *

                                
#show: book

                                


                                
#book-meta( // put metadata of your book like book.toml of mdbook

                                
  title: "shiroa",

                                
  description: "shiroa Documentation",

                                
  repository: "https://github.com/Myriad-Dreamin/shiroa",

                                
  authors: ("Myriad-Dreamin", "7mile"),

                                
  language: "en",

                                
  summary: [ // this field works like summary.md of mdbook

                                
    = Introduction

                                
    - #chapter("guide/installation.typ", section: "1.1")[Installation]

                                
    - #chapter("guide/get-started.typ", section: "1.2")[Get Started]

                                
      - #chapter(none, section: "1.2.1")[Drafting chapter]

                                
  ]

                                
)

                                
#import "@preview/shiroa:0.2.3": *

                                
#show: book

                                


                                
#book-meta( // put metadata of your book like book.toml of mdbook

                                
  title: "shiroa",

                                
  description: "shiroa Documentation",

                                
  repository: "https://github.com/Myriad-Dreamin/shiroa",

                                
  authors: ("Myriad-Dreamin", "7mile"),

                                
  language: "en",

                                
  summary: [ // this field works like summary.md of mdbook

                                
    = Introduction

                                
    - #chapter("guide/installation.typ", section: "1.1")[Installation]

                                
    - #chapter("guide/get-started.typ", section: "1.2")[Get Started]

                                
      - #chapter(none, section: "1.2.1")[Drafting chapter]

                                
  ]

                                
)

Try opening up src/book.typsrc/book.typ in your editor and adding a few chapters.

Source files

The content of your book is all contained in the srcsrc directory. Each chapter is a separate Typst file. Typically, each chapter starts with a level 1 heading with the title of the chapter.


                                
= My First Chapter

                                


                                
Fill out your content here.

                                
= My First Chapter

                                


                                
Fill out your content here.

                                
= My First Chapter

                                


                                
Fill out your content here.

                                
= My First Chapter

                                


                                
Fill out your content here.

The precise layout of the files is up to you. The organization of the files will correspond to the HTML files generated, so keep in mind that the file layout is part of the URL of each chapter.

All other files in the srcsrc directory will be included in the output. So if you have images or other static files, just include them somewhere in the srcsrc directory.

Publishing a book

Once you've written your book, you may want to host it somewhere for others to view. The first step is to build the output of the book. This can be done with the shiroa buildshiroa build command in the same directory where the book.tomlbook.toml file is located:


                                
shiroa build

                                
shiroa build

                                
shiroa build

                                
shiroa build

This will generate a directory named bookbook which contains the HTML content of your book. You can then place this directory on any web server to host it.

(Experimental) Using Typst v0.13.0's HTML Export

You don't have to change the default template, which already handles the HTML export. Simply set the modemode to static-htmlstatic-html to export the book as Static HTML files:


                                
shiroa build --mode static-html

                                
shiroa build --mode static-html

                                
shiroa build --mode static-html

                                
shiroa build --mode static-html

You are viewing the HTML export of the book right now :). See the Paged version of shiroa's documentation to see the result using the old paged export.

There is still some known issues, for example, typst hasn't support labels in the HTML export yet.