mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 03:12:35 +02:00
refactor(v2): add typing for pages plugin (#1813)
* refactor(v2): add typing for pages plugin * misc: new lines
This commit is contained in:
parent
95f0552bad
commit
c4cc7f881b
13 changed files with 70 additions and 22 deletions
|
@ -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({
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
"incremental": true,
|
||||
"tsBuildInfoFile": "./lib/.tsbuildinfo",
|
||||
"rootDir": "src",
|
||||
"outDir": "lib",
|
||||
"outDir": "lib"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue