Skip to content

Commit d79b48b

Browse files
committed
chore: readme linting
1 parent 5c6f23f commit d79b48b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,44 +45,52 @@
4545
5. [Examples](#-examples)
4646

4747
## 🛠 Getting started
48+
4849
### Pre-Requisites
50+
4951
Before you begin, ensure you have the following:
52+
5053
- A Strapi backend up and running: [quick start guide](https://docs.strapi.io/dev-docs/quick-start).
5154
- The API URL of your Strapi instance: for example, `http://localhost:1337/api`.
5255
- A recent version of [Node.js](https://nodejs.org/en/download/package-manager) installed.
5356

5457
### Installation
58+
5559
Install the SDK as a dependency in your project:
5660

5761
**NPM**
62+
5863
```bash
5964
npm install @strapi/sdk-js
6065
```
6166

6267
**Yarn**
68+
6369
```bash
6470
yarn add @strapi/sdk-js
6571
```
6672

6773
**pnpm**
74+
6875
```bash
6976
pnpm add @strapi/sdk-js
7077
```
7178

7279
## ⚙️ Creating and configuring the SDK Instance
80+
7381
### Basic configuration
7482

7583
To interact with your Strapi backend, initialize the SDK with your Strapi API base URL:
7684

77-
``` typescript
85+
```typescript
7886
import { createStrapiSDK } from '@strapi/sdk-js';
7987

8088
const sdk = createStrapiSDK({ baseURL: 'http://localhost:1337/api' });
8189
```
8290

8391
Alternatively, use a `<script>` tag in a browser environment:
8492

85-
``` html
93+
```html
8694
<script src="https://cdn.jsdelivr.net/npm/@strapi/sdk-js"></script>
8795

8896
<script>
@@ -91,13 +99,14 @@ Alternatively, use a `<script>` tag in a browser environment:
9199
```
92100

93101
### Authentication
102+
94103
The SDK supports multiple authentication strategies for accessing authenticated content in your Strapi backend.
95104

96105
#### API-Token authentication
97106

98107
If your Strapi instance uses API tokens, configure the SDK like this:
99108

100-
``` typescript
109+
```typescript
101110
const sdk = createStrapiSDK({
102111
baseURL: 'http://localhost:1337/api',
103112
auth: {
@@ -110,12 +119,14 @@ const sdk = createStrapiSDK({
110119
## 📚 API Reference
111120

112121
The Strapi SDK instance provides key properties and utility methods for content and API interaction:
122+
113123
- **`baseURL`**: base URL of your Strapi backend.
114124
- **`fetch`**: perform generic requests to the Strapi Content API using fetch-like syntax.
115125
- **`.collection(resource: string)`**: get a manager instance for handling collection-type resources.
116126
- **`.single(resource: string)`**: get a manager instance for handling single-type resources.
117127

118128
## 📁 Resource Managers
129+
119130
### `.collection(resource)`
120131

121132
The `.collection()` method provides a manager for working with collection-type resources,
@@ -133,7 +144,7 @@ which can have multiple entries.
133144

134145
#### Examples:
135146

136-
``` typescript
147+
```typescript
137148
const articles = sdk.collection('articles');
138149

139150
// Fetch all english articles sorted by title
@@ -154,6 +165,7 @@ const updatedArticle = await articles.update('article-document-id', { title: 'Up
154165
// Delete an article
155166
await articles.delete('article-id');
156167
```
168+
157169
### `.single(resource)`
158170

159171
The `.single()` method provides a manager for working with collection-type resources, which have only one entry.
@@ -167,7 +179,8 @@ The `.single()` method provides a manager for working with collection-type resou
167179
3. **`delete(queryParams?)`**: remove the document.
168180

169181
#### Examples:
170-
``` typescript
182+
183+
```typescript
171184
const homepage = sdk.single('homepage');
172185

173186
// Fetch the default version of the homepage
@@ -177,7 +190,10 @@ const homepageContent = await homepage.find();
177190
const homepageContent = await homepage.find({ locale: 'es' });
178191

179192
// Update the homepage draft content
180-
const updatedHomepage = await homepage.update({ title: 'Updated Homepage Title' }, { status: 'draft' });
193+
const updatedHomepage = await homepage.update(
194+
{ title: 'Updated Homepage Title' },
195+
{ status: 'draft' }
196+
);
181197

182198
// Delete the homepage content
183199
await homepage.delete();
@@ -187,7 +203,7 @@ await homepage.delete();
187203

188204
Here’s how to combine `.collection()` and `.single()` methods in a real-world scenario:
189205

190-
``` typescript
206+
```typescript
191207
const sdk = createStrapiSDK({
192208
baseURL: 'http://localhost:1337/api',
193209
auth: {

0 commit comments

Comments
 (0)