mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-08 13:52:36 +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
|
@ -8,29 +8,34 @@
|
|||
import path from 'path';
|
||||
|
||||
import pluginContentPages from '../index';
|
||||
import {LoadContext} from '@docusaurus/types';
|
||||
|
||||
describe('docusaurus-plugin-content-pages', () => {
|
||||
test('simple pages', async () => {
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const siteConfig = {
|
||||
title: 'Hello',
|
||||
baseUrl: '/',
|
||||
url: 'https://docusaurus.io',
|
||||
};
|
||||
const siteDir = path.join(__dirname, '__fixtures__', 'website');
|
||||
const plugin = pluginContentPages({
|
||||
const context = {
|
||||
siteDir,
|
||||
siteConfig,
|
||||
} as LoadContext;
|
||||
const pluginPath = 'src/pages';
|
||||
const plugin = pluginContentPages(context, {
|
||||
path: pluginPath,
|
||||
});
|
||||
const pagesMetadatas = await plugin.loadContent();
|
||||
const pagesPath = path.relative(siteDir, plugin.contentPath);
|
||||
|
||||
expect(pagesMetadatas).toEqual([
|
||||
{
|
||||
permalink: '/',
|
||||
source: path.join('@site', pagesPath, 'index.js'),
|
||||
source: path.join('@site', pluginPath, 'index.js'),
|
||||
},
|
||||
{
|
||||
permalink: '/hello/world',
|
||||
source: path.join('@site', pagesPath, 'hello', 'world.js'),
|
||||
source: path.join('@site', pluginPath, 'hello', 'world.js'),
|
||||
},
|
||||
]);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue