Skip to content

TheRandonauts/svaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Svaml

A YAML preprocessor integration for Svelte

Use svaml by adding it as a preprocessor to your svelte or svelte-kit project and seamlessly import and use yaml files in your projects.

Configuration

import {svaml} from 'svaml';
/** @type {import('@sveltejs/kit').Config} */
const config = {
    ...,
	extensions: [
		..., '.yml', '.yaml'
	],
	preprocess: [..., svaml()],
}

Usage

In your svelte-kit project you can import your yaml files as a glob import

    const modules = import.meta.glob(`/src/<yaml_dir>/*.{yml,yaml}`);

then you can access the default .yaml field (or whatever you've configured in the plugin) in the resolved component or

    let component = await (modules[0].resolver())
    let your_parsed_yaml = component.yaml
    let your_parsed_file_name = component.file_name

Contributing

Open a PR we'll review it and merge

About

A svelte yaml parsing plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages