diff --git a/babel.config.js b/babel.config.js index a3dc1c53cc63..761fbcf30815 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,7 +6,18 @@ */ module.exports = { - presets: ['@babel/env', '@babel/react', '@babel/preset-flow'], + presets: [ + [ + '@babel/env', + { + targets: { + node: 'current', + }, + }, + ], + '@babel/react', + '@babel/preset-flow', + ], plugins: [ '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-object-rest-spread', diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/bar.md b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/bar.md new file mode 100644 index 000000000000..ac25e4969a31 --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/bar.md @@ -0,0 +1,66 @@ +--- +id: bar +title: Bar +--- + +# Remarkable + +> Experience real-time editing with Remarkable! + +Click the `clear` link to start with a clean slate, or get the `permalink` to share or save your results. + +*** + +# h1 Heading +## h2 Heading +### h3 Heading +#### h4 Heading +##### h5 Heading +###### h6 Heading + + +## Horizontal Rules + +___ + +*** + +*** + + +## Typographic replacements + +Enable typographer option to see result. + +(c) (C) (r) (R) (tm) (TM) (p) (P) +- + +test.. test... test..... test?..... test!.... + +!!!!!! ???? ,, + +Remarkable -- awesome + +"Smartypants, double quotes" + +'Smartypants, single quotes' + + +## Emphasis + +**This is bold text** + +__This is bold text__ + +*This is italic text* + +_This is italic text_ + +~~Deleted text~~ + +Superscript: 19^th^ + +Subscript: H~2~O + +++Inserted text++ + +==Marked text== diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/baz.md b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/baz.md new file mode 100644 index 000000000000..e3be91b5d689 --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/foo/baz.md @@ -0,0 +1,74 @@ +--- +id: baz +title: baz +--- + +## Images + +Like links, Images also have a footnote style syntax + +![Alt text][id] + +With a reference later in the document defining the URL location: + +[id]: https://octodex.github.com/images/dojocat.jpg "The Dojocat" + +## Links + +[link text](http://dev.nodeca.com) + +[link with title](http://nodeca.github.io/pica/demo/ "title text!") + +Autoconverted link https://github.com/nodeca/pica (enable linkify to see) + + + +## Footnotes + +Footnote 1 link[^first]. + +Footnote 2 link[^second]. + +Inline footnote^[Text of inline footnote] definition. + +Duplicated footnote reference[^second]. + +[^first]: Footnote **can have markup** + + and multiple paragraphs. + +[^second]: Footnote text. + + +## Definition lists + +Term 1 + +: Definition 1 +with lazy continuation. + +Term 2 with *inline markup* + +: Definition 2 + + { some code, part of Definition 2 } + + Third paragraph of definition 2. + +_Compact style:_ + +Term 1 + ~ Definition 1 + +Term 2 + ~ Definition 2a + ~ Definition 2b + + +## Abbreviations + +This is HTML abbreviation example. + +It converts "HTML", but keep intact partial entries like "xxxHTMLyyy" and so on. + +*[HTML]: Hyper Text Markup Language diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/hello.md b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/hello.md new file mode 100644 index 000000000000..c4aa17696c84 --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/hello.md @@ -0,0 +1,54 @@ +--- +id: hello +title: Hello, World ! +--- + +Hi, Endilie here :) + +## Relative links + +Replace this +[foo](foo/bar.md) + +Can't replace this +[file](file.md) + +Do not replace below + +``` +[hello](hello.md) +``` + +## Blockquotes + +> Blockquotes can also be nested... +>> ...by using additional greater-than signs right next to each other... +> > > ...or with spaces between arrows. + + +## Lists + +Unordered + ++ Create a list by starting a line with `+`, `-`, or `*` ++ Sub-lists are made by indenting 2 spaces: + - Marker character change forces new list start: + * Ac tristique libero volutpat at + + Facilisis in pretium nisl aliquet + - Nulla volutpat aliquam velit ++ Very easy! + +Ordered + +1. Lorem ipsum dolor sit amet +2. Consectetur adipiscing elit +3. Integer molestie lorem at massa + + +1. You can use sequential numbers... +1. ...or keep all the numbers as `1.` + +Start numbering with offset: + +57. foo +1. bar diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/permalink.md b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/permalink.md new file mode 100644 index 000000000000..6e31233dba20 --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/docs/permalink.md @@ -0,0 +1,7 @@ +--- +id: permalink +title: Permalink +permalink: :baseUrl:docsUrl/endiliey/:id +--- + +This has a different permalink \ No newline at end of file diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/sidebars.json b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/sidebars.json new file mode 100644 index 000000000000..24d61b49c760 --- /dev/null +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/website/sidebars.json @@ -0,0 +1,11 @@ +{ + "docs": { + "Test": [ + "foo/bar", + "foo/baz" + ], + "Guides": [ + "hello" + ] + } +} diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.js b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.js index 218fe9116b11..10d9ca56b1f4 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.js +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/index.test.js @@ -7,12 +7,21 @@ import '@babel/polyfill'; import path from 'path'; -import loadSetup from '../../../docusaurus/src/server/load/loadSetup'; import DocusaurusPluginContentDocs from '../index'; describe('loadDocs', () => { test('simple website', async () => { - const {siteDir, siteConfig} = await loadSetup('simple'); + 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( { @@ -20,7 +29,7 @@ describe('loadDocs', () => { siteConfig, }, { - path: '../docs', + path: 'docs', sidebarPath, }, ); diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.js b/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.js index ce91b66e4322..af3d7fa3bc0b 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.js +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/metadata.test.js @@ -8,13 +8,22 @@ import '@babel/polyfill'; import path from 'path'; import processMetadata from '../metadata'; -import loadSetup from '../../../docusaurus/src/server/load/loadSetup'; 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'); + test('normal docs', async () => { - const props = await loadSetup('simple'); - const {siteDir, siteConfig} = props; - const docsDir = path.resolve(siteDir, '..', 'docs'); const sourceA = path.join('foo', 'bar.md'); const sourceB = path.join('hello.md'); const dataA = await processMetadata( @@ -46,9 +55,6 @@ describe('processMetadata', () => { }); test('docs with custom permalink', async () => { - const props = await loadSetup('simple'); - const {siteDir, siteConfig} = props; - const docsDir = path.resolve(siteDir, '..', 'docs'); const source = path.join('permalink.md'); const data = await processMetadata(source, docsDir, {}, siteConfig, 'docs'); expect(data).toEqual({ diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.js b/packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.js index 54dd82df9de6..77db87cc534f 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.js +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/sidebars.test.js @@ -5,25 +5,26 @@ * LICENSE file in the root directory of this source tree. */ +import '@babel/polyfill'; import path from 'path'; import loadSidebars from '../sidebars'; -import loadSetup from '../../../docusaurus/src/server/load/loadSetup'; /* eslint-disable global-require, import/no-dynamic-require */ describe('loadSidebars', () => { - const fixtures = path.join(__dirname, '..', '__fixtures__'); - test('normal site with sidebars', async () => { - const {siteDir} = await loadSetup('simple'); - const sidebar = require(path.join(siteDir, 'sidebars.json')); - const result = loadSidebars({siteDir, sidebar}); + const sidebar = require(path.join( + __dirname, + '__fixtures__', + 'website', + 'sidebars.json', + )); + const result = loadSidebars({sidebar}); expect(result).toMatchSnapshot(); }); test('site without sidebars', () => { - const siteDir = path.join(fixtures, 'bad-site'); - const result = loadSidebars({siteDir, sidebar: {}}); + const result = loadSidebars({sidebar: {}}); expect(result).toMatchSnapshot(); }); }); diff --git a/packages/docusaurus-plugin-sitemap/src/__tests__/index.test.js b/packages/docusaurus-plugin-sitemap/src/__tests__/index.test.js index 21f7edafc74a..383b0af16715 100644 --- a/packages/docusaurus-plugin-sitemap/src/__tests__/index.test.js +++ b/packages/docusaurus-plugin-sitemap/src/__tests__/index.test.js @@ -5,13 +5,17 @@ * LICENSE file in the root directory of this source tree. */ -import loadSetup from '../../../docusaurus/src/server/load/loadSetup'; import DocusaurusPluginSitemap from '../index'; describe('docusaurus-plugin-sitemap', () => { describe('createSitemap', () => { - test.each(['simple'])('%s website', async type => { - const context = await loadSetup(type); + test('simple site', async () => { + const context = { + siteConfig: { + url: 'https://example.com', + }, + routesPaths: ['/', '/test'], + }; const plugin = new DocusaurusPluginSitemap(context, null); const sitemap = await plugin.createSitemap(context); expect(sitemap).toContain( @@ -20,7 +24,7 @@ describe('docusaurus-plugin-sitemap', () => { }); test('empty site', async () => { - const context = await loadSetup('empty'); + const context = {}; const plugin = new DocusaurusPluginSitemap(context, null); expect( plugin.createSitemap(context),