Skip to content

Commit

Permalink
fix: fixed options type for builder apis
Browse files Browse the repository at this point in the history
  • Loading branch information
yankeeinlondon committed Dec 15, 2022
1 parent a79ca6f commit 2475cd6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function resolveOptions(userOptions: Omit<Options, 'usingBuilder'> = {}):
...userOptions.style,
},
usingBuilder: (name: string) => {
return !options.builders.every(b => b().name !== name)
return !options.builders.every(b => b.name !== name)
},
frontmatterPreprocess: (frontmatter: Frontmatter, options: ResolvedOptions) => {
if (!options.usingBuilder('link')) {
Expand Down
24 changes: 0 additions & 24 deletions src/pipeline/addBuilderDependencies.ts

This file was deleted.

4 changes: 1 addition & 3 deletions src/pipeline/convertHandlerToTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const getBuilders = <
) => {
const builders = options.builders.reduce(
(acc, b) => {
const defn = b()

return defn.lifecycle === stage ? [...acc, defn as BuilderRegistration<BuilderOptions, S>] : acc
return b.lifecycle === stage ? [...acc, b as BuilderRegistration<BuilderOptions, S>] : acc
},
[] as readonly BuilderRegistration<BuilderOptions, S>[],
)
Expand Down
1 change: 0 additions & 1 deletion src/pipeline/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './addBuilderDependencies'
export * from './applyMarkdownItOptions'
export * from './baseStyling'
export * from '../composeSfcBlocks'
Expand Down
6 changes: 4 additions & 2 deletions src/types/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export interface Options {
}

/** allows adding in Builder's which help to expand functionality of this plugin */
builders?: (<S extends IPipelineStage, O extends BuilderOptions>() => BuilderRegistration<O, S>)[]
builders?: readonly BuilderRegistration<BuilderOptions, IPipelineStage>[]

/**
* Explicitly set the Vue version.
Expand Down Expand Up @@ -400,7 +400,9 @@ export interface ResolvedOptions extends Required<Options> {
wrapperClasses: string
frontmatterDefaults: FmValueCallback | Record<string, FmAllowedValue>
frontmatterOverrides: FmValueCallback | Record<string, FmAllowedValue>
/** a utility which tests whether a given builder is being used */
/**
* a utility which tests whether a given builder is being used
*/
usingBuilder: (name: string) => boolean
}

Expand Down

0 comments on commit 2475cd6

Please sign in to comment.