New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stackbit/schema

Package Overview
Dependencies
Maintainers
11
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackbit/schema

Stackbit schema tools

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by5.26%
Maintainers
11
Weekly downloads
 
Created
Source

Stackbit Schema

Stackbit schema tools

Install

npm install @stackbit/schema

Utility Functions

loadModels(models)

Takes raw models map as defined by stackbit.yaml format and returns an array of sanitized models.

# part of stackbit.yaml

models:
  post:
    type: page
    layout: post
    folder: blog
    fields:
      - type: string
        name: title
        label: Title
        required: true
      # ...fields
  person:
    type: data
    label: Person
    folder: authors
    fields:
      # ...fields
const stackbitYaml = await parseFile('path/to/stackbit.yaml');
const models = loadModels(stackbitYaml.models);

The returned models is a sanitized array of models:

[
  {
    "name": "post",
    "type": "page",
    "label": "Post",
    "fieldLabel": "title",
    "layout": "post",
    "folder": "blog",
    "fields": [ /* fields */ ]
  },
  {
    "name": "person",
    "type": "data",
    "label": "Person",
    "folder": "authors",
    "fields": [ /* fields */ ]
  }
]

getModelByQuery(query, models)

Takes a query object representing a loaded content file and models array returned by loadModels() and returns a model matching the query.

const model = getModelByQuery({ filePath: 'authors/john-doe.json' }, models);
// model => model for "person" type

Keywords

FAQs

Package last updated on 18 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc