Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-pages/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fs = require('fs');
const {encodePath, fileToPath, docuHash} = require('@docusaurus/utils');

const DEFAULT_OPTIONS = {
path: 'pages', // Path to data on filesystem, relative to site dir.
path: 'src/pages', // Path to data on filesystem, relative to site dir.
routeBasePath: '', // URL Route.
include: ['**/*.{js,jsx}'], // Extensions to include.
};
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Added Google analytics and Google gtag plugins.
- Moved source components to `/src`. Please create a `website/src` directory and move your `/pages` and `/theme` code into it. This is to make it easier to integrate your website with external build/static analysis tooling (you can now just pass in `src/**/*.js` as the path to process).

## 2.0.0-alpha.19

Expand Down
10 changes: 7 additions & 3 deletions packages/docusaurus/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import fs from 'fs-extra';
import path from 'path';
import shell from 'shelljs';
import {CONFIG_FILE_NAME} from '../constants';
import {
BUILD_DIR_NAME,
CONFIG_FILE_NAME,
GENERATED_FILES_DIR_NAME,
} from '../constants';
import {loadConfig} from '../server/config';
import {build} from './build';

Expand Down Expand Up @@ -131,9 +135,9 @@ export async function deploy(siteDir: string): Promise<void> {

shell.cd('../..');

const fromPath = path.join('build');
const fromPath = path.join(BUILD_DIR_NAME);
const toPath = path.join(
'.docusaurus',
GENERATED_FILES_DIR_NAME,
`${projectName}-${deploymentBranch}`,
);

Expand Down
4 changes: 3 additions & 1 deletion packages/docusaurus/src/commands/swizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import fs from 'fs-extra';
import importFresh from 'import-fresh';
import path from 'path';

import {THEME_PATH} from '../constants';

export async function swizzle(
siteDir: string,
themeName: string,
Expand All @@ -20,7 +22,7 @@ export async function swizzle(
let fromPath = pluginInstance.getThemePath();

if (fromPath) {
let toPath = path.resolve(siteDir, 'theme');
let toPath = path.resolve(siteDir, THEME_PATH);
if (componentName) {
fromPath = path.join(fromPath, componentName);
toPath = path.join(toPath, componentName);
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

export const BUILD_DIR_NAME = 'build';
export const CONFIG_FILE_NAME = 'docusaurus.config.js';
export const GENERATED_FILES_DIR_NAME = '.docusaurus';
export const SRC_DIR_NAME = 'src';
export const STATIC_DIR_NAME = 'static';
export const CONFIG_FILE_NAME = 'docusaurus.config.js';
export const THEME_PATH = `${SRC_DIR_NAME}/theme`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'@docusaurus/plugin-content-docs',
{
path: '../docs',
sidebarPath: require.resolve('./sidebars.json'),
sidebarPath: require.resolve('./sidebars.js'),
},
],
'@docusaurus/plugin-content-pages',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* 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.
*/

module.exports = {
docs: {
Test: ['foo/bar', 'foo/baz'],
Guides: ['hello'],
},
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'@docusaurus/plugin-content-docs',
{
path: '../docs',
sidebarPath: require.resolve('./sidebars.json'),
sidebarPath: require.resolve('./sidebars.js'),
},
],
'@docusaurus/plugin-content-pages',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* 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.
*/

module.exports = {
docs: {
Test: ['foo/bar', 'foo/baz'],
Guides: ['hello'],
},
};

This file was deleted.

11 changes: 8 additions & 3 deletions packages/docusaurus/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import {generate} from '@docusaurus/utils';
import _ from 'lodash';
import path from 'path';
import {CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME} from '../constants';
import {
BUILD_DIR_NAME,
CONFIG_FILE_NAME,
GENERATED_FILES_DIR_NAME,
THEME_PATH,
} from '../constants';
import {loadClientModules} from './client-modules';
import {loadConfig} from './config';
import {loadPlugins} from './plugins';
Expand Down Expand Up @@ -39,7 +44,7 @@ export async function load(
`export default ${JSON.stringify(siteConfig, null, 2)};`,
);

const outDir = path.resolve(siteDir, 'build');
const outDir = path.resolve(siteDir, BUILD_DIR_NAME);
const {baseUrl} = siteConfig;

const context: LoadContext = {
Expand Down Expand Up @@ -72,7 +77,7 @@ export async function load(
const pluginThemes = _.compact(
plugins.map(plugin => plugin.getThemePath && plugin.getThemePath()),
);
const userTheme = path.resolve(siteDir, 'theme');
const userTheme = path.resolve(siteDir, THEME_PATH);
const alias = loadThemeAlias([fallbackTheme, ...pluginThemes, userTheme]);
// Make a fake plugin to resolve aliased theme components.
plugins.push({
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/templates/classic/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
sidebarPath: require.resolve('./sidebars.js'),
},
theme: {
customCss: require.resolve('./css/custom.css'),
customCss: require.resolve('./src/css/custom.css'),
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion website/docs/writing-docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The headers are well-spaced so that the hierarchy is clear.

This will render in the browser as follows:

import BrowserWindow from '../components/BrowserWindow';
import BrowserWindow from '../src/components/BrowserWindow';

<BrowserWindow url="http://localhost:3000">
<h2>Hello from Docusaurus</h2>
Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
postsPerPage: 3,
},
theme: {
customCss: require.resolve('./css/custom.css'),
customCss: require.resolve('./src/css/custom.css'),
},
},
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.