feat(v2): Provide type definitions for MDXPage from page plugin (#3354)

This commit is contained in:
Sam Zhou 2020-08-28 08:58:32 -04:00 committed by GitHub
parent 56c04c7834
commit c8d6e418ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 3 deletions

View file

@ -3,6 +3,7 @@
"version": "2.0.0-alpha.61",
"description": "Pages content plugin for Docusaurus",
"main": "lib/index.js",
"types": "src/plugin-content-pages.d.ts",
"scripts": {
"build": "tsc",
"watch": "tsc --watch"

View file

@ -0,0 +1,25 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare module '@theme/MDXPage' {
import type {MarkdownRightTableOfContents} from '@docusaurus/types';
export type Props = {
readonly content: {
readonly frontMatter: {
readonly title: string;
readonly description: string;
};
readonly metadata: {readonly permalink: string};
readonly rightToc: readonly MarkdownRightTableOfContents[];
(): JSX.Element;
};
};
const MDXPage: (props: Props) => JSX.Element;
export default MDXPage;
}

View file

@ -9,8 +9,9 @@ import React from 'react';
import Layout from '@theme/Layout';
import {MDXProvider} from '@mdx-js/react';
import MDXComponents from '@theme/MDXComponents';
import type {Props} from '@theme/MDXPage';
function MDXPage(props) {
function MDXPage(props: Props): JSX.Element {
const {content: MDXPageContent} = props;
const {frontMatter, metadata} = MDXPageContent;
const {title, description} = frontMatter;

View file

@ -10,6 +10,7 @@
/// <reference types="@docusaurus/module-type-aliases" />
/// <reference types="@docusaurus/plugin-content-blog" />
/// <reference types="@docusaurus/plugin-content-docs" />
/// <reference types="@docusaurus/plugin-content-pages" />
declare module '@theme/AnnouncementBar' {
const AnnouncementBar: () => JSX.Element | null;
@ -271,8 +272,6 @@ declare module '@theme/MDXComponents' {
export default MDXComponents;
}
// TODO @theme/MDXPage
declare module '@theme/Navbar' {
const Navbar: () => JSX.Element;
export default Navbar;