A JSON schema detailing the Glance config file.
Note
Currently represents version: v0.8.4. Now supports validation of split config files using $include!
The schema is available at: https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json
This schema works with any editor that supports JSON schemas. The examples below use VS Code, but similar configuration can be applied to other editors.
For your main glance.yml configuration file:
- Install the YAML extension for VS Code.
- At the top of your
glance.ymlfile, add this line:# yaml-language-server: $schema=https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json
The schema now supports validating split config files using the $include directive. Here are examples for common use cases:
Widget files should always be arrays, even for a single widget (this is the official Glance recommendation):
# yaml-language-server: $schema=https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json#/definitions/widget
- type: weather
location: New York, United StatesPage files should also be arrays, even for a single page:
# yaml-language-server: $schema=https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json#/definitions/page
- name: Home
columns:
- size: full
widgets:
- type: rss
title: NewsExample glance.yml with includes:
# yaml-language-server: $schema=https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json
server:
port: 8080
pages:
- $include: pages/home.yml
- name: Inline Page
columns:
- size: full
widgets:
- $include: widgets/weather.yml
- $include: widgets/rss.yml
- type: clockTip
You can also use $include with base config sections (branding, theme, document, server, auth) by using array syntax:
document:
- $include: config/document.yml
theme:
- $include: config/theme.ymlFor projects with dedicated folders for widgets and pages, you can configure VS Code to automatically apply the appropriate schema without adding comments to each file.
Add this to your .vscode/settings.json:
{
"yaml.schemas": {
"https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json": ["glance.yml"],
"https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json#/definitions/widget": ["widgets/*.yml"],
"https://raw.githubusercontent.com/not-first/glance-schema/master/schema.json#/definitions/page": ["pages/*.yml"]
}
}This configuration:
- Applies the main schema to
glance.yml - Applies the widget schema (array) to all
.ymlfiles in thewidgets/folder - Applies the page schema (array) to all
.ymlfiles in thepages/folder
Some error messages can be autogenerated by the schema validator and are unhelpful in figuring out what is wrong. These can be customised in the schema once they are located, so please create an issue if you experience one.