Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/giuseppeg/xm

₪ extensible HTML
https://github.com/giuseppeg/xm

html markdown markdown-to-html posthtml

Last synced: 3 days ago
JSON representation

₪ extensible HTML

Awesome Lists containing this project

README

        

# ₪ xm - extensible HTML

xm is a tiny compiler for HTML that adds

- `` tag to inline external HTML files
- `` and `` tags to define slots and fill them with content
- `` tag to portal into Markdown


screenshot of an html template with slots



screenshot of an html page that imports the previous example and fills the slots

xm CLI comes with a **dev mode** that compiles and serves built HTML.

Furthermore xm is built on top of [posthtml-cli](https://posthtml.org/#/cli) and therefore it is [extensible](https://posthtml.org/#/cli?id=options).

Are you using xm? Share your site's URL [here](https://github.com/giuseppeg/xm/issues/2).

## Install

```
npm i -g xm
```

### Usage

```
Usage: xm [options]

Commands:

dev Compiles HTML files on change and serves the root folder
build Compiles the HTML files once
help Displays help

Options:

--root Folder to compile (default ./)
--output Output (destination) folder. This is necessary only when using xm build
--htmlOnly Compile and copy only the built HTML files
```

#### `` element

Allows to inline (import) HTML files into the current one.

```html

```

Paths are relative.

```html

```

You can prefix paths with `/` to make them absolute i.e. relative to the `--root` value.

```
$ xm build --root ./src
#
# -> ./src/file.html
```

#### Importing markdown files

xm supports importing `.md` (markdown) files too. When importing such files the front matter declarations are converted to `fill` elements.

```html

/* theme */

```

💡 This feature can be used to generate styled docs sites for your open source project!

If you create a reusable theme for README-like files we encourage you to use the following naming convention:

```
xm-theme-
```

Share your site or theme URL [here](https://github.com/giuseppeg/xm/issues/2).

#### `` and `` elements

HTML files can define `slot` elements with an attribute `name`. slots can be filled when importing HTML files using the `fill` tag.

```html

About

About


welcome


Unique to this page

About

About


welcome

Unique to this page
```

You can also define a special unnamed `slot` that will be filled with the `import` children that are not `fill` tags:

```html

good bye
hello

friend

hello

friend


good bye
```

#### Credits

- [Ivan Demidov](https://github.com/scrum) for helping me out with PRs and PostHTML
- [askucher](https://github.com/askucher) for transferring ownership of the `xm` package