Skip to content

Commit

Permalink
indexFn -> createIndex, as per #24075
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold authored and kylegach committed Sep 20, 2023
1 parent a49d41b commit db17655
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions docs/api/main-config-indexers.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Type:
```ts
{
test: RegExp;
indexFn: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
createIndex: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
}
```

Expand All @@ -54,7 +54,7 @@ Type: `RegExp`

A regular expression run against file names included in the [`stories`](./main-config-stories.md) configuration that should match all files to be handled by this indexer.

### `indexFn`
### `createIndex`

(Required)

Expand Down Expand Up @@ -192,7 +192,7 @@ import type { StorybookConfig, Indexer } from '@storybook/your-framework';

const combosIndexer: Indexer = {
test: /\.stories\.[tj]sx?$/,
indexFn: async (fileName, { makeTitle }) => {
createIndex: async (fileName, { makeTitle }) => {
// 👇 Grab title from fileName
const title = fileName.match(/\/(.*)\.stories/)[1];

Expand Down Expand Up @@ -330,7 +330,7 @@ import path from 'path';

const jsonFixtureIndexer: Indexer = {
test: /jsonstories\.[tj]sx?$/,
indexFn: async (fileName) => {
createIndex: async (fileName) => {
// JSON files in the current directory
const jsonFiles = (await fs.readdir(path.dirname(fileName)))
.filter(f => f.endsWith('.json'))
Expand Down Expand Up @@ -402,7 +402,7 @@ import { parseCombos } from '../utils';

const combosIndexer: Indexer = {
test: /\.combos\.[tj]sx?$/,
indexFn: async (fileName) => {
createIndex: async (fileName) => {
const code = await fs.readFile(fileName);
const combos = parseCombos(code);

Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/common/main-config-indexers.js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default {
experimental_indexers: async (existingIndexers) => {
const customIndexer = {
test: /\.custom-stories\.[tj]sx?$/,
indexFn: // See API and examples below...
createIndex: // See API and examples below...
};
return [...existingIndexers, customIndexer];
},
};
```
```
4 changes: 2 additions & 2 deletions docs/snippets/common/main-config-indexers.ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ const config: StorybookConfig = {
experimental_indexers: async (existingIndexers) => {
const customIndexer = {
test: /\.custom-stories\.[tj]sx?$/,
indexFn: // See API and examples below...
createIndex: // See API and examples below...
};
return [...existingIndexers, customIndexer];
},
};

export default config
```
```

0 comments on commit db17655

Please sign in to comment.