Skip to content

Commit

Permalink
fix: format readmes and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Jan 2, 2023
1 parent 2109f76 commit 6d26a0c
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 107 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ cd /path/to/my-studio
npx yalc add sanity-plugin-testing-it-out && npx yalc link sanity-plugin-testing-it-out && npm install
```

Now, configure the plugin in sanity.config.ts (or .js) in Sanity Studio:
Now, configure the plugin in `sanity.config.ts` (or .js) in Sanity Studio:

```ts
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-testing-it-out'

export const defineConfig({
export default defineConfig({
//...
plugins: [
myPlugin({})
Expand Down
10 changes: 3 additions & 7 deletions src/configs/default-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export function defaultSourceJs(pkg: PackageJson) {
*
* export default defineConfig({
* // ...
* plugins: [
* myPlugin({}),
* ],
* plugins: [myPlugin({})],
* })
* \`\`\`
*/
Expand All @@ -42,17 +40,15 @@ export function defaultSourceTs(pkg: PackageJson) {
}
/**
* Usage in sanity.config.ts (or .js)
* Usage in \`sanity.config.ts\` (or .js)
*
* \`\`\`ts
* import {defineConfig} from 'sanity'
* import {myPlugin} from '${pkg.name}'
*
* export default defineConfig({
* // ...
* plugins: [
* myPlugin(),
* ],
* plugins: [myPlugin()],
* })
* \`\`\`
*/
Expand Down
32 changes: 17 additions & 15 deletions src/util/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,32 @@ import {User} from './user'
export function generateReadme(data: PackageData) {
const {user, pluginName, license, description} = data

return outdent`
return (
outdent`
# ${pluginName}
${v3BannerNotice()}
${installationSnippet(pluginName ?? 'unknown')}
## Usage
Add it as a plugin in sanity.config.ts (or .js):
Add it as a plugin in \`sanity.config.ts\` (or .js):
\`\`\`ts
import {defineConfig} from 'sanity'
import {myPlugin} from '${pluginName}'
export default defineConfig({
//...
plugins: [myPlugin({})],
})
\`\`\`
import {defineConfig} from 'sanity'
import {myPlugin} from '${pluginName}'
export const defineConfig({
//...
plugins: [
myPlugin({})
]
})
\`\`\`
${getLicenseText(license?.id, user?.name ? (user as User) : undefined)}
${developTestSnippet()}
`
` + '\n'
)
}

export function v3BannerNotice() {
Expand All @@ -41,8 +43,8 @@ export function installationSnippet(packageName: string) {
return outdent`
## Installation
\`\`\`
npm install --save ${packageName}@studio-v3
\`\`\`sh
npm install ${packageName}
\`\`\`
`
}
Expand Down
7 changes: 2 additions & 5 deletions test/fixtures/inject/valid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ Install the plugin in your [Sanity Studio](https://sanity.io/studio) configurati
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-test-plugin'

export const defineConfig({
export default defineConfig({
// ...

plugins: [
myPlugin(),
],
plugins: [myPlugin({})],
})
```

Expand Down
12 changes: 5 additions & 7 deletions test/fixtures/inject/valid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ interface MyPluginConfig {
}

/**
* ## Usage in sanity.config.ts (or .js)
* Usage in `sanity.config.ts` (or .js)
*
* ```
* ```ts
* import {defineConfig} from 'sanity'
* import {myPlugin} from 'sanity-plugin-test-plugin'
*
* export const defineConfig({
* /...
* plugins: [
* myPlugin({})
* ]
* export default defineConfig({
* // ...
* plugins: [myPlugin({})],
* })
* ```
*/
Expand Down
30 changes: 11 additions & 19 deletions test/fixtures/verify-package/every-failure-possible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@

## Installation

```
npm install --save my-plugin
```

or

```
yarn add my-plugin
```sh
npm install my-plugin
```

## Usage

Add it as a plugin in sanity.config.ts (or .js):
Add it as a plugin in `sanity.config.ts` (or .js):

```
import {defineConfig} from 'sanity'
import {myPlugin} from 'my-plugin'
export const defineConfig({
/...
plugins: [
myPlugin({})
]
})
```ts
import {defineConfig} from 'sanity'
import {myPlugin} from 'my-plugin'

export default defineConfig({
// ...
plugins: [myPlugin({})],
})
```

## License
Expand Down
30 changes: 11 additions & 19 deletions test/fixtures/verify-package/invalid-eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@

## Installation

```
npm install --save sanity-plugin-test-plugin
```

or

```
yarn add sanity-plugin-test-plugin
```sh
npm install sanity-plugin-test-plugin
```

## Usage

Add it as a plugin in sanity.config.ts (or .js):
Add it as a plugin in `sanity.config.ts` (or .js):

```
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-test-plugin'
export const defineConfig({
/...
plugins: [
myPlugin({})
]
})
```ts
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-test-plugin'

export default defineConfig({
// ...
plugins: [myPlugin({})],
})
```

## License
Expand Down
12 changes: 5 additions & 7 deletions test/fixtures/verify-package/invalid-eslint/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ interface MyPluginConfig {
}

/**
* ## Usage in sanity.config.ts (or .js)
* Usage in `sanity.config.ts` (or .js)
*
* ```
* ```ts
* import {defineConfig} from 'sanity'
* import {myPlugin} from 'sanity-plugin-test-plugin'
*
* export const defineConfig({
* /...
* plugins: [
* myPlugin({})
* ]
* export default defineConfig({
* // ...
* plugins: [myPlugin({})],
* })
* ```
*/
Expand Down
30 changes: 11 additions & 19 deletions test/fixtures/verify-package/valid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@

## Installation

```
npm install --save sanity-plugin-test-plugin
```

or

```
yarn add sanity-plugin-test-plugin
```sh
npm install sanity-plugin-test-plugin
```

## Usage

Add it as a plugin in sanity.config.ts (or .js):
Add it as a plugin in `sanity.config.ts` (or .js):

```
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-test-plugin'
export const defineConfig({
/...
plugins: [
myPlugin({})
]
})
```ts
import {defineConfig} from 'sanity'
import {myPlugin} from 'sanity-plugin-test-plugin'

export default defineConfig({
// ...
plugins: [myPlugin({})],
})
```

## License
Expand Down
12 changes: 5 additions & 7 deletions test/fixtures/verify-package/valid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ interface MyPluginConfig {
}

/**
* ## Usage in sanity.config.ts (or .js)
* Usage in `sanity.config.ts` (or .js)
*
* ```
* ```ts
* import {defineConfig} from 'sanity'
* import {myPlugin} from 'sanity-plugin-test-plugin'
*
* export const defineConfig({
* /...
* plugins: [
* myPlugin({})
* ]
* export default defineConfig({
* // ...
* plugins: [myPlugin({})],
* })
* ```
*/
Expand Down

0 comments on commit 6d26a0c

Please sign in to comment.