{"id":19499496,"url":"https://github.com/stackbit/stackbit-sdk","last_synced_at":"2025-04-25T22:34:00.676Z","repository":{"id":45191823,"uuid":"335687025","full_name":"stackbit/stackbit-sdk","owner":"stackbit","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-28T11:22:27.000Z","size":5567,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T06:20:58.823Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackbit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-03T16:31:52.000Z","updated_at":"2022-01-02T09:36:13.000Z","dependencies_parsed_at":"2022-08-28T14:11:35.765Z","dependency_job_id":null,"html_url":"https://github.com/stackbit/stackbit-sdk","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbit%2Fstackbit-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbit%2Fstackbit-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbit%2Fstackbit-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackbit%2Fstackbit-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackbit","download_url":"https://codeload.github.com/stackbit/stackbit-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224019619,"owners_count":17242176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T22:04:37.885Z","updated_at":"2024-11-10T22:04:39.193Z","avatar_url":"https://github.com/stackbit.png","language":"TypeScript","readme":"# Stackbit SDK\n\nStackbit SDK contains set of utilities to work with stackbit.yaml file. \n\n\n## Add to your project\n\n```bash\nnpm install @stackbit/sdk\n```\n\n\n## Generate stackbit.yaml\n\nCreate a `FileBrowser` with `FileSystemFileBrowserAdapter` or `GitHubFileBrowserAdapter`:\n\n- Analyzing a local project:\n\n    ```js\n    import { FileSystemFileBrowserAdapter, FileBrowser } from '@stackbit/sdk';\n  \n    const fileBrowserAdapter = new FileSystemFileBrowserAdapter({ dirPath: inputDir });\n    const fileBrowser = new FileBrowser({ fileBrowserAdapter });\n    ```\n\n- Analyzing a remote GitHub project:\n\n    ```js\n    import { GitHubFileBrowserAdapter, FileBrowser } from '@stackbit/sdk';\n  \n    const fileBrowserAdapter = new GitHubFileBrowserAdapter({\n        owner: 'stackbit',\n        repo: 'theme',\n        branch: 'master',\n        auth: GITHUB_PERSONAL_ACCESS_TOKEN\n    });\n    const fileBrowser = new FileBrowser({ fileBrowserAdapter });\n    ```\n\nThen, pass the `fileBrowser` to the `analyzeSite()` method, get the result and save the `config` as `stackbit.yaml`:\n\n```js\nimport { writeConfig, analyzeSite } from '@stackbit/sdk';\n\nconst analyzeResult = await analyzeSite({ fileBrowser });\nawait writeConfig({ dirPath: inputDir, config: analyzeResult.config });\n```\n\n\n## Validate stackbit.yaml\n\nLoad and validate `stackbit.yaml`. Any errors will be returned within the `errors` array.\n\n```js\nimport { loadConfig } from '@stackbit/sdk';\n\nconst configResult = await loadConfig({ dirPath: inputDir });\n\nconfigResult.errors.forEach((error) =\u003e {\n    console.log(error.message);\n});\n```\n\nIf `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`:\n\n```js\nimport { loadContent } from '@stackbit/sdk';\n\nif (configResult.config) {\n    return;\n}\n\nconst contentResult = await loadContent({ dirPath: inputDir, config: configResult.config });\n\ncontentResult.contentItems.forEach((contentItem) =\u003e {\n    console.log(contentItem.__metadata.filePath);\n});\n\ncontentResult.errors.forEach((error) =\u003e {\n    console.log(error.message);\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbit%2Fstackbit-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackbit%2Fstackbit-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackbit%2Fstackbit-sdk/lists"}