Skip to content

Commit

Permalink
Fix AIK plugin, Update READMEs (#23)
Browse files Browse the repository at this point in the history
* Move `injectRoute` argument to `injectPages` function

* lint

* Update READMEs

* Fix AIK plugin

* lint
  • Loading branch information
BryceRussell authored Mar 1, 2024
1 parent e3e2ae2 commit 3ed0ab7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function(options): AstroIntegration {
cwd: import.meta.url,
dir: 'pages',
config,
logger,
injectRoute
logger
}

const {
Expand All @@ -47,7 +46,7 @@ export default function(options): AstroIntegration {
} = addPageDir(pageConfig)

// Injects pages inside 'package/pages'
injectPages()
injectPages(injectRoute)

}
}
Expand Down
5 changes: 2 additions & 3 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export default function(options): AstroIntegration {
cwd: import.meta.url,
dir: 'pages',
config,
logger,
injectRoute
logger
}

const {
Expand All @@ -140,7 +139,7 @@ export default function(options): AstroIntegration {
} = addPageDir(pageConfig)

// Injects pages inside 'package/pages'
injectPages()
injectPages(injectRoute)

}
}
Expand Down
18 changes: 11 additions & 7 deletions package/plugins/astro-integration-kit.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { definePlugin } from "astro-integration-kit";
import type { Option } from "../types";
import type { IntegrationOption, Option } from "../types";
import addPageDir from "../utils/add-page-dir";

export default definePlugin({
name: "addPageDir",
hook: "astro:config:setup",
implementation: ({ config, logger }) => {
implementation: ({ config, logger, injectRoute }) => {
return (option: string | Option) => {
if (typeof option === "string") {
option = {
dir: option,
};
}
return addPageDir({
...option,
config,
logger,
});

Object.assign(option, { config, logger });

const { pages, injectPages } = addPageDir(option as IntegrationOption);

return {
pages,
injectPages: () => injectPages(injectRoute),
};
};
},
});

0 comments on commit 3ed0ab7

Please sign in to comment.