# `sable`

`sable` is a obsidian renderer that powers my website.

## Feature Support

  - Markdown
    - [ ] Escaping
    - [X] Frontmatter
      - [X] YAML
      - [X] TOML
      - [X] JSON
    - [X] Syntax Highlighting
    - [ ] Github Flavored Markdown
      - [X] Autolinks
      - [X] Tables
      - [X] Task List Items
      - [X] Strikethrough
    - [ ] Obsidian Flavored Markdown
      - [X] Callouts
      - [ ] File Includes
      - [X] Tags
      - [X] Wikilinks

  - Obsidian Vault
    - [ ] Base
    - [ ] Canvas
    - [ ] Graph
    - [X] Note

  - Sable
    - [ ] Build time assets (eg: running Tailwind)
    - [ ] Custom data loading
    - [ ] Dev Server
    - [ ] Support HTML notes

## Configuration

`sable` is somewhat configurable with its config file and command line arguments.

Config is stored is in the `sable.toml` file, and only some settings can be
overwritten by command line arguments.

```typescript
interface Config {
  // CLI: --dist
  dist: string = `${CWD}/dist`;
  // CLI: --static
  static: string = `${CWD}/static`;
  // CLI: --templates
  templates: string = `${CWD}/templates`;
  // CLI: --src
  vault: string = `${CWD}/content`;

  // The port the dev server will run on
  // CLI: [serve] --port
  port: number = 3000;

  // The default template a Note will be rendered with if not provided a layout
  // Defaults to a 'hidden' internal template
  default_template: string;

  // Custom data that will be available to a template
  data: ConfigData;
}

interface ConfigData {
  [key: string]: any;
}
```

## Templates

`sable` uses [Tera](https://keats.github.io/tera/) for templating, see its documentation for more information.

Which template is used to render a note can be changed by setting the
`template` frontmatter variable, otherwise it uses an included 'default'
template.

```typescript
const meta: Meta;

// `meta` is meta information about `sable` itself
interface Meta {
  package_name: string;
  package_version: string;

  git_dirty: boolean;
  git_hash: string;
}

const data: Data;

// `data` is any data passed in from the config (if it exists)
interface Data {
  [key: string]: any;
}

const note: Note;

// An Obsidian note
interface Note {
  path: NotePath;

  name: string;
  title: string;

  metadata: NoteMetadata;
  properties: NoteProperties;

  toc: NoteHeading[];

  contents: string;
}

interface NotePath {
  vault: VaultPath;

  full: string;
  relative: string;

  slug: string;
}

type VaultPath = string;

// Contains a Note's file system metadata
interface NoteMetadata {
  created: string;
  modified: string;

  git_created: string | null;
  git_modified: string | null;
}

// This is actually the note's frontmatter
// Its called properties as `sable` supports YAML, TOML, and JSON frontmatter
interface NoteProperties {
  [key: string]: any;
}

interface NoteHeading {
  level: number;
  id: string;
  title: string;
  children: NoteHeading[];
}

// Renders a string to Markdown
function markdown(in: string): string;
```
