Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more refactoring
Browse files Browse the repository at this point in the history
endiliey committed May 8, 2019
1 parent 8d7f44f commit 81d43bb
Showing 6 changed files with 67 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import '@babel/polyfill';
import path from 'path';
import DocusaurusPluginContentDocs from '../index';

@@ -14,13 +13,8 @@ describe('loadDocs', () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const siteConfig = {
title: 'Hello',
tagline: 'Hello World',
organizationName: 'endiliey',
projectName: 'hello',
baseUrl: '/',
url: 'https://docusaurus.io',
headerIcon: '',
favicon: '',
};
const sidebarPath = path.join(siteDir, 'sidebars.json');
const plugin = new DocusaurusPluginContentDocs(
Original file line number Diff line number Diff line change
@@ -13,13 +13,8 @@ describe('processMetadata', () => {
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const siteConfig = {
title: 'Hello',
tagline: 'Hello World',
organizationName: 'endiliey',
projectName: 'hello',
baseUrl: '/',
url: 'https://docusaurus.io',
headerIcon: '',
favicon: '',
};
const docsDir = path.resolve(siteDir, 'docs');

Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import '@babel/polyfill';
import path from 'path';
import loadSidebars from '../sidebars';

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import Head from '@docusaurus/Head';

export default class World extends React.Component {
render() {
return (
<div>
<Head>
<title>World</title>
</Head>
<div>Hello World </div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import Head from '@docusaurus/Head';

export default class Home extends React.Component {
render() {
return (
<div>
<Head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="/css/basic.css" />
</Head>
<div>Home ... </div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -7,35 +7,31 @@

import path from 'path';

import loadSetup from '../../../docusaurus/src/server/load/loadSetup';
import DocusaurusPluginContentPages from '../index';

describe('docusaurus-plugin-content-pages', () => {
describe('loadContent', () => {
test.each([
[
'simple',
pagesDir => [
{
permalink: '/',
source: path.join(pagesDir, 'index.js'),
},
{
permalink: '/hello/world',
source: path.join(pagesDir, 'hello', 'world.js'),
},
],
],
])('%s website', async (type, expected) => {
const {siteDir, siteConfig} = await loadSetup(type);
const plugin = new DocusaurusPluginContentPages({
siteDir,
siteConfig,
});
const pagesMetadatas = await plugin.loadContent();
const pagesDir = plugin.contentPath;

expect(pagesMetadatas).toEqual(expected(pagesDir));
test('simple pages', async () => {
const siteConfig = {
title: 'Hello',
baseUrl: '/',
url: 'https://docusaurus.io',
};
const siteDir = path.join(__dirname, '__fixtures__', 'website');
const plugin = new DocusaurusPluginContentPages({
siteDir,
siteConfig,
});
const pagesMetadatas = await plugin.loadContent();
const pagesDir = plugin.contentPath;
expect(pagesMetadatas).toEqual([
{
permalink: '/',
source: path.join(pagesDir, 'index.js'),
},
{
permalink: '/hello/world',
source: path.join(pagesDir, 'hello', 'world.js'),
},
]);
});
});

0 comments on commit 81d43bb

Please sign in to comment.