Skip to content

Commit

Permalink
Merge branch 'main' into jc/mjs-script
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jan 8, 2022
2 parents f6562c0 + bcc05e2 commit 25825cc
Show file tree
Hide file tree
Showing 67 changed files with 551 additions and 617 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ module.exports = {
],
},
overrides: [
{
files: [
'packages/docusaurus-theme-*/src/theme/**/*.js',
'packages/docusaurus-theme-*/src/theme/**/*.ts',
'packages/docusaurus-theme-*/src/theme/**/*.tsx',
],
rules: {
'import/no-named-export': ERROR,
},
},
{
files: [
'packages/create-docusaurus/templates/**/*.js',
Expand Down
4 changes: 4 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@ export default {
// TODO maybe use "projects" + multiple configs if we plan to add tests to another theme?
'@theme/(.*)': '@docusaurus/theme-classic/src/theme/$1',
'@site/(.*)': 'website/$1',

// TODO why Jest can't figure node package entry points?
'@docusaurus/plugin-content-docs/client':
'@docusaurus/plugin-content-docs/lib/client/index.js',
},
};
4 changes: 4 additions & 0 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "2.0.0-beta.14",
"description": "Docs plugin for Docusaurus.",
"main": "lib/index.js",
"exports": {
"./client": "./lib/client/index.js",
".": "./lib/index.js"
},
"types": "src/plugin-content-docs.d.ts",
"scripts": {
"build": "tsc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useGlobalData, {
usePluginData,
} from '@docusaurus/useGlobalData';

import type {GlobalPluginData, GlobalVersion} from '../../types';
import type {GlobalPluginData, GlobalVersion} from '../types';
import {
getActivePlugin,
getLatestVersion,
Expand All @@ -22,7 +22,7 @@ import {
type ActiveDocContext,
type DocVersionSuggestions,
type GetActivePluginOptions,
} from '../../client/docsClientUtils';
} from './docsClientUtils';

// Important to use a constant object to avoid React useEffect executions etc...,
// see https://github.com/facebook/docusaurus/issues/5089
Expand All @@ -37,6 +37,7 @@ export const useAllDocsData = (): Record<string, GlobalPluginData> =>
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;

// TODO this feature should be provided by docusaurus core
export const useActivePlugin = (
options: GetActivePluginOptions = {},
): ActivePlugin | undefined => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
* LICENSE file in the root directory of this source tree.
*/

import {createContext} from 'react';

const UserPreferencesContext = createContext(undefined);

export default UserPreferencesContext;
export * from './globalDataHooks';
8 changes: 0 additions & 8 deletions packages/docusaurus-plugin-content-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ export default async function pluginContentDocs(
return {
name: 'docusaurus-plugin-content-docs',

getThemePath() {
return path.resolve(__dirname, './theme');
},

getTypeScriptThemePath() {
return path.resolve(__dirname, '..', 'src', 'theme');
},

extendCli(cli) {
const isDefaultPluginId = pluginId === DEFAULT_PLUGIN_ID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ declare module '@theme/Seo' {
export default Seo;
}

declare module '@theme/hooks/useDocs' {
// TODO can't we infer types directly from code?
declare module '@docusaurus/plugin-content-docs/client' {
type GlobalPluginData = import('./types').GlobalPluginData;
type GlobalVersion = import('./types').GlobalVersion;
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
Expand Down
4 changes: 0 additions & 4 deletions packages/docusaurus-theme-classic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ export default function docusaurusThemeClassic(
.join('|');

return {
ignoreWarnings: [
// See https://github.com/facebook/docusaurus/pull/3382
(e) => e.message.includes("Can't resolve '@theme-init/hooks/useDocs"),
],
plugins: [
new ContextReplacementPlugin(
/prismjs[\\/]components$/,
Expand Down
Loading

0 comments on commit 25825cc

Please sign in to comment.