refactor(v2): add typing for pages plugin (#1813)

* refactor(v2): add typing for pages plugin

* misc: new lines
This commit is contained in:
Yangshun Tay 2019-10-07 22:35:58 -07:00 committed by GitHub
parent 95f0552bad
commit c4cc7f881b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 70 additions and 22 deletions

View file

@ -6,6 +6,7 @@
*/
import path from 'path';
import pluginContentDocs from '../index';
import {LoadContext} from '@docusaurus/types';
@ -24,7 +25,7 @@ describe('loadDocs', () => {
const sidebarPath = path.join(siteDir, 'sidebars.json');
const pluginPath = 'docs';
const plugin = pluginContentDocs(context, {
path: 'docs',
path: pluginPath,
sidebarPath,
});
const {docs: docsMetadata} = await plugin.loadContent();
@ -38,7 +39,7 @@ describe('loadDocs', () => {
sidebar: 'docs',
source: path.join('@site', pluginPath, 'hello.md'),
title: 'Hello, World !',
description: `Hi, Endilie here :)`,
description: 'Hi, Endilie here :)',
});
expect(docsMetadata['foo/bar']).toEqual({

View file

@ -9,11 +9,11 @@ import globby from 'globby';
import fs from 'fs-extra';
import path from 'path';
import {idx, normalizeUrl, docuHash} from '@docusaurus/utils';
import {LoadContext, Plugin, DocusaurusConfig} from '@docusaurus/types';
import createOrder from './order';
import loadSidebars from './sidebars';
import processMetadata from './metadata';
import {LoadContext, Plugin, DocusaurusConfig} from '@docusaurus/types';
import {
PluginOptions,
Sidebar,
@ -46,7 +46,7 @@ export default function pluginContentDocs(
let sourceToPermalink: SourceToPermalink = {};
return {
name: 'docusaurus-plugin-content-docs',
name: 'docusaurus-plugin-content-docs-legacy',
getPathsToWatch() {
const {include = []} = options;
@ -66,7 +66,7 @@ export default function pluginContentDocs(
const docsSidebars: Sidebar = loadSidebars(sidebarPath);
// Build the docs ordering such as next, previous, category and sidebar
// Build the docs ordering such as next, previous, category and sidebar.
const order: Order = createOrder(docsSidebars);
// Prepare metadata container.

View file

@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export interface PluginOptions {
path: string;
routeBasePath: string;
@ -42,6 +43,7 @@ export type SidebarItem =
| SidebarItemDoc
| SidebarItemLink
| SidebarItemCategory;
export type SidebarItemRaw =
| string
| SidebarItemDoc

View file

@ -4,6 +4,6 @@
"incremental": true,
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"rootDir": "src",
"outDir": "lib",
"outDir": "lib"
}
}