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

https://github.com/ioncakephper/sidebar-navigation-model

A modular and extensible JSON Schema for defining hierarchical sidebar navigation structures in content platforms, documentation tools, and UI frameworks.
https://github.com/ioncakephper/sidebar-navigation-model

configuration data-model documentation-tool front-end json json-sch metadata navigation nested-navigation reusable sidebar web-development

Last synced: 5 months ago
JSON representation

A modular and extensible JSON Schema for defining hierarchical sidebar navigation structures in content platforms, documentation tools, and UI frameworks.

Awesome Lists containing this project

README

          

# Sidebar Navigation Model

A modular and extensible JSON Schema for defining hierarchical sidebar navigation structures in content platforms, documentation tools, and UI frameworks.

> Ideal for static site generators, developer portals, CMS integrations, or schema-driven UIs.

## πŸ“˜ Overview

This repository contains a versioned specification for sidebar layout models. Built with composability and clarity in mind, the schema supports:

- πŸ”Ή Flat and nested sidebar items
- πŸ”Έ Categories and topics with structured children
- 🧭 Headings and hierarchical depth
- πŸ”— Link items with URI validation
- βœ… Rich validation through JSON Schema

Whether you’re building a static site generator, documentation renderer, or a dynamic navigation engineβ€”this model is adaptable to your workflow.

---

## πŸ“ Repository Structure

```
.
β”œβ”€β”€ README.md
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ package.json
β”œβ”€β”€ docs/
β”‚ β”œβ”€β”€ definitions.md
β”‚ β”œβ”€β”€ integrations-guide.md
β”‚ └── overview.md
β”œβ”€β”€ schema/
β”‚ β”œβ”€β”€ v1.0.0/
β”‚ β”‚ β”œβ”€β”€ sidebar.schema.json
β”‚ β”‚ └── samples/
β”‚ β”‚ └── example.yaml
β”‚ └── latest/
β”‚ β”œβ”€β”€ sidebar.schema.json
β”‚ └── samples/
β”‚ └── example.yaml
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ yamlToMarkdown.js
β”‚ └── markdownToYaml.js
```

- `latest/` is a pointer to the most recent version of the schema for easy integration. Update it manually on each release, or use a script/symlink strategy.

---

## πŸ“˜ Features

- Recursive sidebar modeling
- Component inheritance via `$defs` and `allOf`
- Regex-validated metadata: `id` (filename-like), `slug`, and flexible `path`
- Deeply nested headings and categories
- Ready for version tracking and changelog support

---

## πŸ› οΈ Conversion Scripts

### `yamlToMarkdown.js`

**Description:**
Converts sidebar YAML files (matching the schema) into readable, structured Markdown navigation lists.
Supports preservation of YAML comments (before each sidebar entry) as Markdown paragraphs, and includes metadata such as the YAML filename and timestamp as Markdown comments.

**Features:**

- Converts all sidebar structure, including nested items, headings, and tags, into Markdown.
- Scalar properties (string, number, boolean) are rendered as `_property_: value`.
- Tags arrays are rendered as Markdown sub-lists.
- YAML comments before each sidebar entry are rendered as Markdown paragraphs after the heading.
- Prepends Markdown comments for the YAML filename and timestamp.

**Usage Example:**

```js
const fs = require('fs');
const { parseYamlWithSidebarComments, convertDataToMarkdown } = require('./scripts/yamlToMarkdown');

const yamlContent = fs.readFileSync('sidebars.yaml', 'utf8');
const data = parseYamlWithSidebarComments(yamlContent);

convertDataToMarkdown(data, { yamlFilePath: 'sidebars.yaml' }).then(markdown => {
fs.writeFileSync('sidebars.md', markdown);
});
```

---

### `markdownToYaml.js`

**Description:**
Converts Markdown navigation lists (as generated by `yamlToMarkdown.js`) back into YAML, reconstructing the sidebar structure and restoring comments as YAML comments.

**Features:**

- Parses Markdown headings, paragraphs, and lists to reconstruct the sidebar data structure.
- Converts Markdown paragraphs between headings and the first list item into YAML comments.
- Scalar properties and tags are faithfully restored.
- Prepends YAML comments for the Markdown filename and timestamp.

**Usage Example:**

```js
const fs = require('fs');
const { convertMarkdownToYaml } = require('./scripts/markdownToYaml');

const markdownContent = fs.readFileSync('sidebars.md', 'utf8');
const yaml = convertMarkdownToYaml(markdownContent, { markdownFilePath: 'sidebars.md' });
fs.writeFileSync('sidebars.generated.yaml', yaml);
```

---

### 🧩 Dependencies

Both scripts require the following libraries (see `package.json`):

- [`js-yaml`](https://www.npmjs.com/package/js-yaml)
- [`yaml`](https://www.npmjs.com/package/yaml)
- [`prettier`](https://www.npmjs.com/package/prettier) (with plugins: `prettier/plugins/estree`, `prettier/plugins/yaml`, `prettier/plugins/markdown`)

Install all dependencies with:

```bash
npm install
```

---

## πŸš€ Usage

Clone the repo:

```bash
git clone https://github.com/your-username/sidebar-navigation-model.git
```

---

## πŸ“š Documentation

Explore:

- [`overview.md`](./docs/overview.md): High-level schema purpose and structure
- [`definitions.md`](./docs/definitions.md): Breakdown of reusable components
- [`integrations-guide.md`](./docs/integrations-guide.md): How to integrate with static site generators or client apps

---

## πŸ“Œ Versioning

We follow [Semantic Versioning](https://semver.org/) for schema releases. Refer to the [CHANGELOG.md](CHANGELOG.md) for a history of changes.

---

## 🀝 Contributing

Contributions are welcome! See our [contributing guide](CONTRIBUTING.md) to get started.

---

## πŸ“¬ Questions or Feedback?

Have a question or feedback? Please use one of the following channels:

- **[GitHub Issues](https://github.com/ioncakephper/sidebar-navigation-model/issues):** For bug reports and feature requests.
- **[GitHub Discussions](https://github.com/ioncakephper/sidebar-navigation-model/discussions):** For questions, ideas, and general feedback.

---

## πŸ“„ License

Released under the [MIT License](LICENSE). Use it freely in commercial and open-source projects.

---