mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
Fix mdx and markdoc integrations return type (#6552)
This commit is contained in:
parent
b0b5ba84a9
commit
392ba3e4d5
3 changed files with 24 additions and 35 deletions
6
.changeset/small-pens-knock.md
Normal file
6
.changeset/small-pens-knock.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@astrojs/markdoc': patch
|
||||
'@astrojs/mdx': patch
|
||||
---
|
||||
|
||||
Fix integration return type
|
|
@ -11,24 +11,19 @@ import {
|
|||
prependForwardSlash,
|
||||
} from './utils.js';
|
||||
|
||||
type IntegrationWithPrivateHooks = {
|
||||
name: string;
|
||||
hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
|
||||
'astro:config:setup': (
|
||||
params: HookParameters<'astro:config:setup'> & {
|
||||
// `contentEntryType` is not a public API
|
||||
// Add type defs here
|
||||
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
||||
}
|
||||
) => void | Promise<void>;
|
||||
};
|
||||
type SetupHookParams = HookParameters<'astro:config:setup'> & {
|
||||
// `contentEntryType` is not a public API
|
||||
// Add type defs here
|
||||
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
||||
};
|
||||
|
||||
export default function markdoc(markdocConfig: Config = {}): IntegrationWithPrivateHooks {
|
||||
export default function markdoc(markdocConfig: Config = {}): AstroIntegration {
|
||||
return {
|
||||
name: '@astrojs/markdoc',
|
||||
hooks: {
|
||||
'astro:config:setup': async ({ updateConfig, config, addContentEntryType }) => {
|
||||
'astro:config:setup': async (params) => {
|
||||
const { updateConfig, config, addContentEntryType } = params as SetupHookParams;
|
||||
|
||||
function getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) {
|
||||
const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl));
|
||||
return {
|
||||
|
|
|
@ -23,33 +23,21 @@ export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | '
|
|||
remarkRehype: RemarkRehypeOptions;
|
||||
};
|
||||
|
||||
type IntegrationWithPrivateHooks = {
|
||||
name: string;
|
||||
hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
|
||||
'astro:config:setup': (
|
||||
params: HookParameters<'astro:config:setup'> & {
|
||||
// `addPageExtension` and `contentEntryType` are not a public APIs
|
||||
// Add type defs here
|
||||
addPageExtension: (extension: string) => void;
|
||||
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
||||
}
|
||||
) => void | Promise<void>;
|
||||
};
|
||||
type SetupHookParams = HookParameters<'astro:config:setup'> & {
|
||||
// `addPageExtension` and `contentEntryType` are not a public APIs
|
||||
// Add type defs here
|
||||
addPageExtension: (extension: string) => void;
|
||||
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
||||
};
|
||||
|
||||
export default function mdx(
|
||||
partialMdxOptions: Partial<MdxOptions> = {}
|
||||
): IntegrationWithPrivateHooks {
|
||||
export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroIntegration {
|
||||
return {
|
||||
name: '@astrojs/mdx',
|
||||
hooks: {
|
||||
'astro:config:setup': async ({
|
||||
updateConfig,
|
||||
config,
|
||||
addPageExtension,
|
||||
addContentEntryType,
|
||||
command,
|
||||
}) => {
|
||||
'astro:config:setup': async (params) => {
|
||||
const { updateConfig, config, addPageExtension, addContentEntryType, command } =
|
||||
params as SetupHookParams;
|
||||
|
||||
addPageExtension('.mdx');
|
||||
addContentEntryType({
|
||||
extensions: ['.mdx'],
|
||||
|
|
Loading…
Reference in a new issue