Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frontity/file-settings

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frontity/file-settings

file settings package

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
174
decreased by-19.44%
Maintainers
5
Weekly downloads
 
Created
Source

File Settings

This is an internal package used by @frontity/core.

Usage

This package is used to import the Frontity settings from a local file.

You can install it with npm:

npm i @frontity/file-settings

Here is a small example of how to use getSettings:

import { getSettings } from "@frontity/file-settings";

const settings = await getSettings({
  name: "example-name",
  url: "https://example.site"
});

API Reference

async getSettings(options) => settings

Used to retrieve the settings from the frontity.settings.js file.

Parameters

options : { name?: string; url: string; }

Used to match the right set of settings when there is more than one.

  • options.name : string (optional)
    The name of the set of settings you want to retrieve. When provided, getSettings won't use options.url.

  • options.url : string
    The url of the site using Frontity. The matches field of each set of settings will be tested against this url to determine which set of settings should be used.

Return

settings : Settings
An object with type Settings containing a set of settings.

async getAllSites() => sites

Used to retrieve all the sites with its name, mode and packages.

Return

Sites: { name: string; mode: string; packages: string[]; }[]
An array of sites containing name, mode and packages.

[
  {
    name: "my-site-1",
    mode: "html",
    packages: ["package-1", "package-2"]
  },
  {
    name: "my-site-1-amp",
    mode: "amp",
    packages: ["package-1", "package-3"]
  },
  {
    name: "my-site-2",
    mode: "html",
    packages: ["package-1", "package-2"]
  }
];

Settings File

The file must be located in the root directory of the project, it must be named frontity.settings.ts or frontity.settings.js, and it needs to export a serializable object.

The settings exported can be mono settings (only one):

{
  name?: string;
  match?: string[];
  mode?: string; // Default: "html"
  state?: object,
  packages: [
    string,
    {
      name: string;
      active?: boolean; // Default: true
      state?: object;
    }
  ]
}

Or multi settings:

// An array of more than one set of settings.
[
  {
    name: string; // Here name is mandatory and must be unique.
    match?: string[];
    mode?: string; // Default: "html"
    state?: { ... },
    packages: [ ... ]
  },
  {
    name: string; // Here name is mandatory and must be unique.
    match?: string[];
    mode?: string; // Default: "html"
    state?: { ... },
    packages: [ ... ]
  }
]

Typescript

The Settings interface is exposed to be used in development. It can be accessed like this:

import { Settings } from "@frontity/file-settings";

const settings: Settings = { ... };

Settings<T = Package>

Types for the imported settings object from the settings file. You'll want to use them on your frontity.settings.ts file.

Keywords

FAQs

Package last updated on 12 Jul 2019

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