Skip to content

smarterlabs/omni

Repository files navigation

Omni logo

Omni-Directional Documents (.omni, .odd)

Note: All packages in this monorepo should be considered a work-in-progress. APIs may change dramatically.

Think of Omni-Directional Documents as "smart markdown files" that are capable of doing things such as variable interpolation between files, file bundling, using multiple languages in one file, and more. Since the syntax is 90% markdown, you can benefit from linting and code highlighting that you get in markdown file code blocks.

Example .omni file

Current Packages

Directives

Note: More on the way!

config

A code block with a config directive is usually used to give instructions to Omni about how a file should be run or processed.

run

A code block with a run directive will execute the code block every time the file is processed. This can be useful for fetching data from an API to pass to another code block, or logging out debug information about the file that is being processed.

export

A code block with the export directive will export the code block to its own file after it has been processed

Directive aliases

You can create your own directives with directive aliases:

const omni = new Omni({
	input: `example`,
	output: `dist`,
	aliases: {
		script: `export:../dist/js/scripts/*.js`,
		style: `export:../dist/css/styles/*.css`,
	},
})

export default omni

And then use these directives:


```js script
console.log(`I was exported to another directory via alias!`)
```

```css style
body{
	margin: 0;
}
```

The script and style aliases will use the export directives in the config and export to thier respective locations.

Use Cases

  • Using component-style patterns with frameworks that don't support them
  • Keeping documentation with code
  • Keeping tests with code
  • Coordinating events between server and client side code in a decoupled environment
  • Rapid prototyping in your documentation
  • Working with multiple frameworks simultaneously
  • Getting backend devs more familiar with front end or front end devs more familiar with backend
  • Expressing user flow in production code