@stackbit/sdk
TypeScript icon, indicating that this package has built-in type declarations

2.1.15 • Public • Published

Stackbit SDK

Stackbit SDK contains set of utilities to work with stackbit.yaml file.

Add to your project

npm install @stackbit/sdk

Generate stackbit.yaml

Create a FileBrowser with FileSystemFileBrowserAdapter or GitHubFileBrowserAdapter:

  • Analyzing a local project:

    import { FileSystemFileBrowserAdapter, FileBrowser } from '@stackbit/sdk';
    
    const fileBrowserAdapter = new FileSystemFileBrowserAdapter({ dirPath: inputDir });
    const fileBrowser = new FileBrowser({ fileBrowserAdapter });
  • Analyzing a remote GitHub project:

    import { GitHubFileBrowserAdapter, FileBrowser } from '@stackbit/sdk';
    
    const fileBrowserAdapter = new GitHubFileBrowserAdapter({
        owner: 'stackbit',
        repo: 'theme',
        branch: 'master',
        auth: GITHUB_PERSONAL_ACCESS_TOKEN
    });
    const fileBrowser = new FileBrowser({ fileBrowserAdapter });

Then, pass the fileBrowser to the analyzeSite() method, get the result and save the config as stackbit.yaml:

import { writeConfig, analyzeSite } from '@stackbit/sdk';

const analyzeResult = await analyzeSite({ fileBrowser });
await writeConfig({ dirPath: inputDir, config: analyzeResult.config });

Validate stackbit.yaml

Load and validate stackbit.yaml. Any errors will be returned within the errors array.

import { loadConfig } from '@stackbit/sdk';

const configResult = await loadConfig({ dirPath: inputDir });

configResult.errors.forEach((error) => {
    console.log(error.message);
});

If configResult.config is not null, pass it to load and validate web-site's content. Any errors will be returned within the errors array, and loaded content within the contentItems:

import { loadContent } from '@stackbit/sdk';

if (configResult.config) {
    return;
}

const contentResult = await loadContent({ dirPath: inputDir, config: configResult.config });

contentResult.contentItems.forEach((contentItem) => {
    console.log(contentItem.__metadata.filePath);
});

contentResult.errors.forEach((error) => {
    console.log(error.message);
});

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.3.8-locale.11locale
0.3.10-canary.01canary
1.0.27-feature-custom-actions-permissions.10feature-custom-actions-permissions
1.0.20-develop.20develop
1.0.18-feature-clac.00feature-clac
0.3.23-alpha.10alpha
0.3.22-types-alpha.00types-alpha
0.3.19-gitcms.30gitcms
0.3.18-cloudinary-presets.00cloudinary-presets
0.3.15-cross-references.00cross-references
0.3.13-sanity-locale.00sanity-locale
2.1.152,559latest
2.1.16-staging.22staging
2.0.7-feature-dev-server.11feature-dev-server
1.0.21-feature-document-statuses.11feature-document-statuses

Version History

VersionDownloads (Last 7 Days)Published
2.1.16-staging.22
2.1.16-staging.11
2.1.152,559
2.1.15-staging.10
2.1.1414
2.1.14-staging.20
2.1.14-staging.11
2.1.1318
2.1.12257
2.1.12-staging.21
2.1.12-staging.10
2.1.1164
2.1.11-staging.10
2.1.101
2.1.10-staging.20
2.1.10-staging.10
2.1.93
2.1.9-staging.11
2.1.81
2.1.8-staging.11
2.1.71,149
2.1.7-staging.10
2.1.62,905
2.1.6-staging.10
2.1.558
2.1.5-staging.30
2.1.5-staging.21
2.1.5-staging.11
2.1.416
2.1.4-staging.11
2.1.350
2.1.23
2.1.2-staging.10
2.1.12
2.1.1-staging.10
2.1.09
2.0.132
2.0.13-staging.10
2.0.121,460
2.0.11139
2.0.11-staging.10
2.0.102
2.0.10-staging.10
2.0.96
2.0.9-staging.11
2.0.882
2.0.8-staging.21
2.0.8-staging.10
2.0.730
2.0.7-staging.20
2.0.7-feature-dev-server.11
2.0.7-feature-dev-server.00
2.0.7-staging.10
2.0.615
2.0.6-staging.20
2.0.6-staging.11
2.0.52
2.0.5-staging.11
2.0.42
2.0.4-staging.11
2.0.315
2.0.3-staging.20
2.0.3-staging.11
2.0.224
2.0.2-staging.30
2.0.2-staging.21
2.0.2-staging.11
2.0.112,716
2.0.1-staging.12
2.0.02
2.0.0-staging.00
1.0.29-staging.10
1.0.281
1.0.28-staging.10
1.0.271
1.0.27-staging.20
1.0.27-staging.10
1.0.262
1.0.26-staging.21
1.0.27-feature-custom-actions-permissions.10
1.0.26-staging.11
1.0.2564
1.0.25-staging.11
1.0.242
1.0.24-staging.21
1.0.24-staging.11
1.0.231,012
1.0.23-staging.10
1.0.222
1.0.22-staging.21
1.0.22-staging.10
1.0.2140
1.0.201
1.0.21-feature-document-statuses.11
1.0.20-staging.20
1.0.20-staging.10
1.0.1910
1.0.20-develop.20
1.0.20-develop.10
1.0.19-staging.10
1.0.18418
1.0.19-develop.20
1.0.18-staging.21
1.0.18-feature-clac.00
1.0.19-develop.10
1.0.18-staging.11
1.0.178
1.0.18-develop.13
1.0.17-staging.11
1.0.1651
1.0.17-develop.30
1.0.16-staging.30
1.0.17-develop.20
1.0.16-staging.20
1.0.17-develop.11
1.0.16-staging.10
1.0.152
1.0.16-develop.11
1.0.15-staging.11
1.0.141
1.0.15-develop.20
1.0.14-staging.20
1.0.15-develop.10
1.0.14-staging.11
1.0.133
1.0.14-develop.11
1.0.13-staging.10
1.0.13-staging.00
1.0.1210
1.0.13-develop.20
1.0.13-develop.10
1.0.12-staging.10
1.0.11238
1.0.12-develop.31
1.0.11-staging.40
1.0.12-develop.20
1.0.11-staging.30
1.0.11-staging.21
1.0.12-develop.10
1.0.11-staging.11
1.0.109
1.0.11-develop.20
1.0.11-develop.10
1.0.10-staging.10
1.0.92
1.0.10-develop.20
1.0.10-develop.11
1.0.9-staging.10
1.0.81
1.0.9-develop.10
1.0.8-staging.10
1.0.8-develop.10
1.0.7-staging.10
1.0.61
1.0.7-develop.11
1.0.6-staging.10
1.0.5166
1.0.6-develop.10
1.0.5-staging.10
1.0.48
1.0.5-develop.40
1.0.4-staging.30
1.0.5-develop.31
1.0.4-staging.20
1.0.5-develop.20
1.0.5-develop.11
1.0.4-staging.10
1.0.32
1.0.4-develop.10
1.0.3-staging.10
1.0.3-develop.11
1.0.2-staging.10
1.0.2-develop.20
1.0.2-develop.10
1.0.1-staging.10
1.0.01
1.0.1-develop.10
1.0.0-staging.10
0.7.172
1.0.0-develop.01
0.7.18-develop.10
0.7.17-staging.10
0.7.161
0.7.17-develop.10
0.7.16-staging.10
0.7.152
0.7.16-develop.31
0.7.16-develop.20
0.7.15-staging.20
0.7.16-develop.10
0.7.15-staging.10
0.7.142
0.7.14-develop.10
0.7.13-staging.11
0.7.13-develop.10
0.7.12-staging.10
0.7.114
0.7.101
0.7.9-staging.10
0.7.82
0.7.9-develop.10
0.7.8-staging.10
0.7.75
0.7.8-develop.30
0.7.8-develop.20
0.7.8-develop.10
0.7.7-staging.10
0.7.61
0.7.6-staging.20
0.7.7-develop.31
0.7.7-develop.20
0.7.7-develop.10
0.7.6-staging.11
0.7.51
0.7.6-develop.40
0.7.5-staging.21
0.7.6-develop.30
0.7.6-develop.21
0.7.6-develop.10
0.7.5-staging.10
0.7.425
0.7.5-develop.11
0.7.4-staging.10
0.7.4-develop.31
0.7.4-develop.20
0.7.4-develop.10
0.7.3-staging.10
0.7.23
0.7.3-develop.10
0.7.2-staging.11
0.7.11
0.7.2-develop.10
0.7.1-staging.10
0.7.01
0.7.1-develop.20
0.7.1-develop.10
0.7.0-staging.10
0.6.52
0.7.0-develop.00
0.6.6-develop.21
0.6.6-develop.10
0.6.5-staging.11
0.6.42
0.6.5-develop.20
0.6.5-develop.10
0.6.4-staging.10
0.6.3-staging.20
0.6.3-staging.10
0.6.33
0.6.21
0.6.3-develop.20
0.6.2-staging.20
0.6.3-develop.11
0.6.2-staging.12
0.6.11
0.6.2-develop.10
0.6.1-staging.10
0.6.06
0.6.0-staging.11
0.5.91
0.5.81
0.6.0-develop.00
0.5.9-develop.10
0.5.8-staging.10
0.5.71
0.5.8-develop.10
0.5.7-staging.10
0.5.625
0.5.7-develop.10
0.5.6-staging.10
0.5.52
0.5.6-develop.30
0.5.6-develop.20
0.5.5-staging.21
0.5.6-develop.11
0.5.5-staging.10
0.5.45
0.5.5-develop.20
0.5.4-staging.40
0.5.4-staging.31
0.5.5-develop.11
0.5.4-staging.10
0.5.31
0.5.4-develop.10
0.5.3-staging.10
0.5.22
0.5.3-develop.31
0.5.3-develop.20
0.5.3-develop.11
0.5.2-staging.11
0.5.2-develop.11
0.5.1-staging.11
0.5.01
0.5.0-staging.20
0.5.0-staging.10
0.5.0-staging.00
0.4.4-develop.10
0.4.3-staging.11
0.4.3-develop.10
0.4.2-staging.10
0.4.11
0.4.2-develop.10
0.4.1-staging.10
0.4.01
0.4.1-develop.30
0.4.0-staging.10
0.4.1-develop.20
0.4.1-develop.10
0.4.0-develop.10
0.4.0-develop.00
0.4.0-staging.00
0.3.2630
0.3.26-develop.10
0.3.26-develop.00
0.3.26-staging.01
0.3.251
0.3.19-develop.10
0.3.19-staging.20
0.3.19-staging.10
0.3.19-staging.00
0.3.19-gitcms.30
0.3.19-develop.01
0.3.19-gitcms.20
0.3.19-gitcms.10
0.3.2419
0.3.232
0.3.19-gitcms.00
0.3.23-alpha.10
0.3.23-alpha.01
0.3.222
0.3.22-alpha.00
0.3.22-types-alpha.00
0.3.2113
0.3.20-alpha.00
0.3.18-cloudinary-presets.00
0.3.181
0.3.18-alpha.00
0.3.171
0.3.17-alpha.00
0.3.161
0.3.16-alpha.00
0.3.151
0.3.15-alpha.00
0.3.15-cross-references.00
0.3.142
0.3.14-alpha.00
0.3.132
0.3.13-alpha.11
0.3.13-alpha.00
0.3.13-sanity-locale.00
0.3.122
0.3.111
0.3.1025
0.3.10-canary.01
0.3.10-alpha.01
0.3.91
0.3.9-alpha.01
0.3.82
0.3.8-locale.11
0.3.8-locale.00
0.3.8-alpha.00
0.3.71
0.3.61
0.3.52
0.3.424
0.3.32
0.3.3-alpha.30
0.3.3-alpha.21
0.3.3-alpha.10
0.3.3-alpha.00
0.3.21
0.3.12
0.3.01
0.2.3969
0.2.39-alpha.20
0.2.39-alpha.10
0.2.39-alpha.00
0.2.381
0.2.371
0.2.36-alpha.00
0.2.351
0.2.341
0.2.331
0.2.321
0.2.311
0.2.302
0.2.291
0.2.281
0.2.271
0.2.266
0.2.251
0.2.241
0.2.232
0.2.221
0.2.211
0.2.202
0.2.1916
0.2.182
0.2.1728
0.2.161
0.2.151
0.2.141
0.2.131
0.2.121
0.2.112
0.2.101
0.2.91
0.2.72
0.2.61
0.2.52
0.2.42
0.2.31
0.2.22
0.2.11
0.2.01
0.1.1931
0.1.181
0.1.172
0.1.163
0.1.152
0.1.141
0.1.131
0.1.122
0.1.111
0.1.102
0.1.92
0.1.82
0.1.72
0.1.62
0.1.52
0.1.41
0.1.31
0.1.21
0.1.11

Package Sidebar

Install

npm i @stackbit/sdk

Weekly Downloads

4,651

Version

2.1.15

License

MIT

Unpacked Size

1.1 MB

Total Files

153

Last publish

Collaborators

  • smnh
  • berdav
  • stackbit-admin
  • vitaliyr
  • denar90
  • youvalv
  • bob_netlify
  • bwwhite
  • merlyn_at_netlify
  • cmparsons
  • suzanneaitchison