@brillout/docpress 0.10.25 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/+config.ts +13 -2
- package/components/Link.tsx +9 -14
- package/components/RepoLink.tsx +3 -4
- package/config/resolveHeadingsData.ts +1 -2
- package/config/resolvePageContext.ts +1 -2
- package/dist/+config.d.ts +17 -2
- package/dist/+config.js +10 -2
- package/dist/components/Link.js +6 -12
- package/dist/components/RepoLink.d.ts +1 -3
- package/dist/components/RepoLink.js +2 -3
- package/dist/config/resolveHeadingsData.js +1 -2
- package/dist/config/resolvePageContext.js +1 -2
- package/dist/parsePageSections.d.ts +2 -5
- package/dist/utils/assert.js +7 -3
- package/dist/vite.config.d.ts +2 -2
- package/dist/vite.config.js +6 -8
- package/package.json +2 -6
- package/parsePageSections.ts +2 -1
- package/renderer/onBeforeRender.ts +1 -1
- package/utils/assert.ts +5 -3
- package/vite.config.ts +9 -11
- package/config/getConfig.ts +0 -19
- package/dist/config/getConfig.d.ts +0 -3
- package/dist/config/getConfig.js +0 -14
package/+config.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
export { config as default }
|
|
2
|
+
|
|
1
3
|
import type { Config, ImportString } from 'vike/types'
|
|
2
4
|
import type { Exports } from './config/resolvePageContext'
|
|
5
|
+
import { viteConfig } from './vite.config.js'
|
|
6
|
+
import type { Config as DocpressConfig } from './types/Config'
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
// @ts-ignore Remove this ts-ignore once Vike's new version is released.
|
|
8
|
+
const config = {
|
|
6
9
|
name: '@brillout/docpress',
|
|
10
|
+
require: { vike: '>=0.4.222' },
|
|
11
|
+
vite: viteConfig,
|
|
12
|
+
prerender: { noExtraDir: true },
|
|
7
13
|
onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
|
|
8
14
|
onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
|
|
9
15
|
onBeforeRender: 'import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender',
|
|
@@ -18,6 +24,10 @@ export default {
|
|
|
18
24
|
TopNavigation: {
|
|
19
25
|
env: { client: true, server: true },
|
|
20
26
|
},
|
|
27
|
+
docpress: {
|
|
28
|
+
env: { server: true },
|
|
29
|
+
global: true,
|
|
30
|
+
},
|
|
21
31
|
},
|
|
22
32
|
prefetch: {
|
|
23
33
|
staticAssets: 'hover',
|
|
@@ -35,6 +45,7 @@ declare global {
|
|
|
35
45
|
interface Config {
|
|
36
46
|
Layout?: ReactComponent | null | ImportString
|
|
37
47
|
TopNavigation?: ReactComponent
|
|
48
|
+
docpress?: DocpressConfig
|
|
38
49
|
}
|
|
39
50
|
}
|
|
40
51
|
}
|
package/components/Link.tsx
CHANGED
|
@@ -2,7 +2,6 @@ export { Link }
|
|
|
2
2
|
export type { LinkData }
|
|
3
3
|
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { isRepoLink, RepoLink } from './RepoLink'
|
|
6
5
|
import type { PageContextResolved } from '../config/resolvePageContext'
|
|
7
6
|
import { usePageContext } from '../renderer/usePageContext'
|
|
8
7
|
import { assert, assertUsage, assertWarning, determineSectionTitle, determineSectionUrlHash } from '../utils/server'
|
|
@@ -31,20 +30,16 @@ function Link({
|
|
|
31
30
|
// assertWarning(!text, 'prop `text` is deprecated')
|
|
32
31
|
text = text ?? children
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
noBreadcrumb,
|
|
43
|
-
...linkTextData,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
return <a href={href}>{text}</a>
|
|
33
|
+
const linkTextData = getLinkTextData(href, pageContext, doNotInferSectionTitle)
|
|
34
|
+
if (!linkTextData) {
|
|
35
|
+
text = 'LINK-TARGET-NOT-FOUND'
|
|
36
|
+
} else if (!text) {
|
|
37
|
+
text = getLinkText({
|
|
38
|
+
noBreadcrumb,
|
|
39
|
+
...linkTextData,
|
|
40
|
+
})
|
|
47
41
|
}
|
|
42
|
+
return <a href={href}>{text}</a>
|
|
48
43
|
}
|
|
49
44
|
|
|
50
45
|
function getLinkText({
|
package/components/RepoLink.tsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
export { RepoLink }
|
|
2
|
+
export { getRepoHref }
|
|
3
|
+
|
|
1
4
|
import React from 'react'
|
|
2
5
|
import { assert } from '../utils/server'
|
|
3
6
|
import { usePageContext } from '../renderer/usePageContext'
|
|
4
7
|
|
|
5
|
-
export { RepoLink }
|
|
6
|
-
export { isRepoLink }
|
|
7
|
-
export { getRepoHref }
|
|
8
|
-
|
|
9
8
|
function isRepoLink(href: string) {
|
|
10
9
|
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some((start) => href.startsWith(start))
|
|
11
10
|
}
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
HeadingDetachedResolved,
|
|
10
10
|
} from '../types/Heading'
|
|
11
11
|
import type { Config } from '../types/Config'
|
|
12
|
-
import { getConfig } from './getConfig'
|
|
13
12
|
import type { NavItem } from '../NavItemComponent'
|
|
14
13
|
import type { LinkData } from '../components'
|
|
15
14
|
import type { Exports, PageContextOriginal } from './resolvePageContext'
|
|
@@ -33,7 +32,7 @@ type ActiveCategory = {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
function resolveHeadingsData(pageContext: PageContextOriginal) {
|
|
36
|
-
const config =
|
|
35
|
+
const config = pageContext.config.docpress!
|
|
37
36
|
|
|
38
37
|
{
|
|
39
38
|
const { headings, headingsDetached } = config
|
|
@@ -6,7 +6,6 @@ export type { Exports }
|
|
|
6
6
|
import { objectAssign } from '../utils/server'
|
|
7
7
|
import type { PageContextServer } from 'vike/types'
|
|
8
8
|
import type { PageSection } from '../parsePageSections'
|
|
9
|
-
import { getConfig } from './getConfig'
|
|
10
9
|
import { resolveHeadingsData } from './resolveHeadingsData'
|
|
11
10
|
|
|
12
11
|
type Exports = {
|
|
@@ -22,7 +21,7 @@ function resolvePageContext(pageContext: PageContextOriginal) {
|
|
|
22
21
|
|
|
23
22
|
objectAssign(pageContextResolved, resolveHeadingsData(pageContext))
|
|
24
23
|
|
|
25
|
-
const config =
|
|
24
|
+
const config = pageContext.config.docpress!
|
|
26
25
|
const {
|
|
27
26
|
algolia,
|
|
28
27
|
tagline,
|
package/dist/+config.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
export { config as default };
|
|
1
2
|
import type { ImportString } from 'vike/types';
|
|
2
3
|
import type { Exports } from './config/resolvePageContext';
|
|
3
|
-
|
|
4
|
+
import type { Config as DocpressConfig } from './types/Config';
|
|
5
|
+
declare const config: {
|
|
4
6
|
name: string;
|
|
7
|
+
require: {
|
|
8
|
+
vike: string;
|
|
9
|
+
};
|
|
10
|
+
vite: import("vite").UserConfig;
|
|
11
|
+
prerender: {
|
|
12
|
+
noExtraDir: true;
|
|
13
|
+
};
|
|
5
14
|
onRenderHtml: "import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml";
|
|
6
15
|
onRenderClient: "import:@brillout/docpress/renderer/onRenderClient:onRenderClient";
|
|
7
16
|
onBeforeRender: "import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender";
|
|
@@ -22,13 +31,18 @@ declare const _default: {
|
|
|
22
31
|
server: true;
|
|
23
32
|
};
|
|
24
33
|
};
|
|
34
|
+
docpress: {
|
|
35
|
+
env: {
|
|
36
|
+
server: true;
|
|
37
|
+
};
|
|
38
|
+
global: true;
|
|
39
|
+
};
|
|
25
40
|
};
|
|
26
41
|
prefetch: {
|
|
27
42
|
staticAssets: "hover";
|
|
28
43
|
pageContext: number;
|
|
29
44
|
};
|
|
30
45
|
};
|
|
31
|
-
export default _default;
|
|
32
46
|
type ReactComponent = () => React.JSX.Element;
|
|
33
47
|
declare global {
|
|
34
48
|
namespace Vike {
|
|
@@ -39,6 +53,7 @@ declare global {
|
|
|
39
53
|
interface Config {
|
|
40
54
|
Layout?: ReactComponent | null | ImportString;
|
|
41
55
|
TopNavigation?: ReactComponent;
|
|
56
|
+
docpress?: DocpressConfig;
|
|
42
57
|
}
|
|
43
58
|
}
|
|
44
59
|
}
|
package/dist/+config.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export default
|
|
2
|
-
|
|
1
|
+
export { config as default };
|
|
2
|
+
import { viteConfig } from './vite.config.js';
|
|
3
|
+
var config = {
|
|
3
4
|
name: '@brillout/docpress',
|
|
5
|
+
require: { vike: '>=0.4.222' },
|
|
6
|
+
vite: viteConfig,
|
|
7
|
+
prerender: { noExtraDir: true },
|
|
4
8
|
onRenderHtml: 'import:@brillout/docpress/renderer/onRenderHtml:onRenderHtml',
|
|
5
9
|
onRenderClient: 'import:@brillout/docpress/renderer/onRenderClient:onRenderClient',
|
|
6
10
|
onBeforeRender: 'import:@brillout/docpress/renderer/onBeforeRender:onBeforeRender',
|
|
@@ -15,6 +19,10 @@ export default {
|
|
|
15
19
|
TopNavigation: {
|
|
16
20
|
env: { client: true, server: true },
|
|
17
21
|
},
|
|
22
|
+
docpress: {
|
|
23
|
+
env: { server: true },
|
|
24
|
+
global: true,
|
|
25
|
+
},
|
|
18
26
|
},
|
|
19
27
|
prefetch: {
|
|
20
28
|
staticAssets: 'hover',
|
package/dist/components/Link.js
CHANGED
|
@@ -11,7 +11,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
export { Link };
|
|
13
13
|
import React from 'react';
|
|
14
|
-
import { isRepoLink, RepoLink } from './RepoLink';
|
|
15
14
|
import { usePageContext } from '../renderer/usePageContext';
|
|
16
15
|
import { assert, assertUsage, assertWarning, determineSectionTitle, determineSectionUrlHash } from '../utils/server';
|
|
17
16
|
import { parseMarkdownMini } from '../parseMarkdownMini';
|
|
@@ -23,19 +22,14 @@ function Link(_a) {
|
|
|
23
22
|
assertUsage(!text || !children, 'Cannot use both `text` or `children`');
|
|
24
23
|
// assertWarning(!text, 'prop `text` is deprecated')
|
|
25
24
|
text = text !== null && text !== void 0 ? text : children;
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
var linkTextData = getLinkTextData(href, pageContext, doNotInferSectionTitle);
|
|
26
|
+
if (!linkTextData) {
|
|
27
|
+
text = 'LINK-TARGET-NOT-FOUND';
|
|
28
28
|
}
|
|
29
|
-
else {
|
|
30
|
-
|
|
31
|
-
if (!linkTextData) {
|
|
32
|
-
text = 'LINK-TARGET-NOT-FOUND';
|
|
33
|
-
}
|
|
34
|
-
else if (!text) {
|
|
35
|
-
text = getLinkText(__assign({ noBreadcrumb: noBreadcrumb }, linkTextData));
|
|
36
|
-
}
|
|
37
|
-
return React.createElement("a", { href: href }, text);
|
|
29
|
+
else if (!text) {
|
|
30
|
+
text = getLinkText(__assign({ noBreadcrumb: noBreadcrumb }, linkTextData));
|
|
38
31
|
}
|
|
32
|
+
return React.createElement("a", { href: href }, text);
|
|
39
33
|
}
|
|
40
34
|
function getLinkText(_a) {
|
|
41
35
|
var _b;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export { RepoLink };
|
|
3
|
-
export { isRepoLink };
|
|
4
2
|
export { getRepoHref };
|
|
5
|
-
|
|
3
|
+
import React from 'react';
|
|
6
4
|
declare function RepoLink({ path, text, editMode }: {
|
|
7
5
|
path: string;
|
|
8
6
|
text?: string | React.ReactNode;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
export { RepoLink };
|
|
2
|
+
export { getRepoHref };
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { assert } from '../utils/server';
|
|
3
5
|
import { usePageContext } from '../renderer/usePageContext';
|
|
4
|
-
export { RepoLink };
|
|
5
|
-
export { isRepoLink };
|
|
6
|
-
export { getRepoHref };
|
|
7
6
|
function isRepoLink(href) {
|
|
8
7
|
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some(function (start) { return href.startsWith(start); });
|
|
9
8
|
}
|
|
@@ -20,14 +20,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
20
20
|
};
|
|
21
21
|
export { resolveHeadingsData };
|
|
22
22
|
import { assert, isBrowser, jsxToTextContent } from '../utils/server';
|
|
23
|
-
import { getConfig } from './getConfig';
|
|
24
23
|
import pc from '@brillout/picocolors';
|
|
25
24
|
import { parseMarkdownMini } from '../parseMarkdownMini';
|
|
26
25
|
import { determineNavItemsColumnLayout } from '../renderer/determineNavItemsColumnLayout';
|
|
27
26
|
assert(!isBrowser());
|
|
28
27
|
function resolveHeadingsData(pageContext) {
|
|
29
28
|
var _a, _b;
|
|
30
|
-
var config =
|
|
29
|
+
var config = pageContext.config.docpress;
|
|
31
30
|
{
|
|
32
31
|
var headings = config.headings, headingsDetached = config.headingsDetached;
|
|
33
32
|
assertHeadingsDefinition(__spreadArray(__spreadArray([], headings, true), headingsDetached, true));
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export { resolvePageContext };
|
|
2
2
|
import { objectAssign } from '../utils/server';
|
|
3
|
-
import { getConfig } from './getConfig';
|
|
4
3
|
import { resolveHeadingsData } from './resolveHeadingsData';
|
|
5
4
|
function resolvePageContext(pageContext) {
|
|
6
5
|
var _a;
|
|
7
6
|
var pageContextResolved = {};
|
|
8
7
|
objectAssign(pageContextResolved, resolveHeadingsData(pageContext));
|
|
9
|
-
var config =
|
|
8
|
+
var config = pageContext.config.docpress;
|
|
10
9
|
var algolia = config.algolia, tagline = config.tagline, twitterHandle = config.twitterHandle, bannerUrl = config.bannerUrl, websiteUrl = config.websiteUrl, projectName = config.projectInfo.projectName;
|
|
11
10
|
var logoUrl = (_a = config.logoUrl) !== null && _a !== void 0 ? _a : config.faviconUrl;
|
|
12
11
|
objectAssign(pageContextResolved, {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export { parsePageSections };
|
|
2
2
|
export type { PageSection };
|
|
3
|
+
import type { PluginOption } from 'vite';
|
|
3
4
|
type PageSection = {
|
|
4
5
|
pageSectionTitle: string;
|
|
5
6
|
pageSectionId: string | null;
|
|
6
7
|
pageSectionLevel: number;
|
|
7
8
|
};
|
|
8
|
-
declare function parsePageSections():
|
|
9
|
-
name: string;
|
|
10
|
-
enforce: string;
|
|
11
|
-
transform: (code: string, id: string) => Promise<string | undefined>;
|
|
12
|
-
};
|
|
9
|
+
declare function parsePageSections(): PluginOption;
|
package/dist/utils/assert.js
CHANGED
|
@@ -72,8 +72,12 @@ function assertWarning(condition, msg) {
|
|
|
72
72
|
}
|
|
73
73
|
msg = '[DocPress][Warning] ' + msg;
|
|
74
74
|
var err = new Error(msg);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if (import.meta.env.DEV) {
|
|
76
|
+
console.warn(err);
|
|
77
|
+
if (isDevMode())
|
|
78
|
+
window.alert(err);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw err;
|
|
78
82
|
}
|
|
79
83
|
}
|
package/dist/vite.config.d.ts
CHANGED
package/dist/vite.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export { config as viteConfig };
|
|
1
2
|
import mdx from '@mdx-js/rollup';
|
|
2
3
|
import react from '@vitejs/plugin-react-swc';
|
|
3
|
-
import vike from 'vike/plugin';
|
|
4
4
|
import { parsePageSections } from './parsePageSections.js';
|
|
5
5
|
import rehypePrettyCode from 'rehype-pretty-code';
|
|
6
6
|
import remarkGfm from 'remark-gfm';
|
|
@@ -16,12 +16,6 @@ var config = {
|
|
|
16
16
|
mdx({ rehypePlugins: rehypePlugins, remarkPlugins: remarkPlugins }),
|
|
17
17
|
// @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
|
|
18
18
|
react(),
|
|
19
|
-
vike({
|
|
20
|
-
prerender: {
|
|
21
|
-
noExtraDir: true,
|
|
22
|
-
},
|
|
23
|
-
includeAssetsImportedByServer: true,
|
|
24
|
-
}),
|
|
25
19
|
],
|
|
26
20
|
optimizeDeps: {
|
|
27
21
|
include: ['react', 'react-dom', 'react-dom/client'],
|
|
@@ -30,6 +24,10 @@ var config = {
|
|
|
30
24
|
ssr: {
|
|
31
25
|
noExternal: ['@brillout/docpress', '@docsearch/react'],
|
|
32
26
|
},
|
|
27
|
+
// Suppress following warning:
|
|
28
|
+
// ```
|
|
29
|
+
// ▲ [WARNING] Transforming this CSS nesting syntax is not supported in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14") [unsupported-css-nesting]
|
|
30
|
+
// ```
|
|
31
|
+
build: { target: 'es2022' },
|
|
33
32
|
clearScreen: false,
|
|
34
33
|
};
|
|
35
|
-
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/docpress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@brillout/picocolors": "^1.0.10",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"react": ">=18.0.0",
|
|
22
22
|
"react-dom": ">=18.0.0",
|
|
23
23
|
"typescript": ">=5.0.0",
|
|
24
|
-
"vike": ">=0.4.
|
|
24
|
+
"vike": ">=0.4.222",
|
|
25
25
|
"vite": ">=5.2.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependenciesMeta": {
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"./renderer/onBeforeRender": "./renderer/onBeforeRender.ts",
|
|
39
39
|
"./Layout": "./Layout.tsx",
|
|
40
40
|
".": "./index.ts",
|
|
41
|
-
"./vite-config": "./dist/vite.config.js",
|
|
42
41
|
"./config": "./dist/+config.js",
|
|
43
42
|
"./style": "./css/index.css",
|
|
44
43
|
"./types": {
|
|
@@ -53,9 +52,6 @@
|
|
|
53
52
|
"types": [
|
|
54
53
|
"./types.d.ts"
|
|
55
54
|
],
|
|
56
|
-
"vite-config": [
|
|
57
|
-
"./dist/vite.config.d.ts"
|
|
58
|
-
],
|
|
59
55
|
"config": [
|
|
60
56
|
"./dist/+config.d.ts"
|
|
61
57
|
]
|
package/parsePageSections.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { parsePageSections }
|
|
2
2
|
export type { PageSection }
|
|
3
3
|
|
|
4
|
+
import type { PluginOption } from 'vite'
|
|
4
5
|
import { assert } from './utils/assert.js'
|
|
5
6
|
import { determineSectionUrlHash } from './utils/determineSectionUrlHash.js'
|
|
6
7
|
import os from 'os'
|
|
@@ -11,7 +12,7 @@ type PageSection = {
|
|
|
11
12
|
pageSectionLevel: number
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
function parsePageSections() {
|
|
15
|
+
function parsePageSections(): PluginOption {
|
|
15
16
|
return {
|
|
16
17
|
name: '@brillout/docpress:parsePageSections',
|
|
17
18
|
enforce: 'pre',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { onBeforeRender }
|
|
2
2
|
|
|
3
|
-
import { resolvePageContext, type PageContextOriginal
|
|
3
|
+
import { resolvePageContext, type PageContextOriginal } from '../config/resolvePageContext'
|
|
4
4
|
|
|
5
5
|
function onBeforeRender(pageContextOriginal: PageContextOriginal) {
|
|
6
6
|
const pageContextResolved = resolvePageContext(pageContextOriginal)
|
package/utils/assert.ts
CHANGED
|
@@ -76,8 +76,10 @@ function assertWarning(condition: unknown, msg: string) {
|
|
|
76
76
|
}
|
|
77
77
|
msg = '[DocPress][Warning] ' + msg
|
|
78
78
|
const err = new Error(msg)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
window.alert(err)
|
|
79
|
+
if (import.meta.env.DEV) {
|
|
80
|
+
console.warn(err)
|
|
81
|
+
if (isDevMode()) window.alert(err)
|
|
82
|
+
} else {
|
|
83
|
+
throw err
|
|
82
84
|
}
|
|
83
85
|
}
|
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export { config as viteConfig }
|
|
2
|
+
|
|
1
3
|
import mdx from '@mdx-js/rollup'
|
|
2
4
|
import react from '@vitejs/plugin-react-swc'
|
|
3
|
-
import
|
|
4
|
-
import { UserConfig } from 'vite'
|
|
5
|
+
import type { PluginOption, UserConfig } from 'vite'
|
|
5
6
|
import { parsePageSections } from './parsePageSections.js'
|
|
6
7
|
import rehypePrettyCode from 'rehype-pretty-code'
|
|
7
8
|
import remarkGfm from 'remark-gfm'
|
|
@@ -16,15 +17,9 @@ const config: UserConfig = {
|
|
|
16
17
|
root,
|
|
17
18
|
plugins: [
|
|
18
19
|
parsePageSections(),
|
|
19
|
-
mdx({ rehypePlugins, remarkPlugins }),
|
|
20
|
+
mdx({ rehypePlugins, remarkPlugins }) as PluginOption,
|
|
20
21
|
// @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
|
|
21
22
|
react(),
|
|
22
|
-
vike({
|
|
23
|
-
prerender: {
|
|
24
|
-
noExtraDir: true,
|
|
25
|
-
},
|
|
26
|
-
includeAssetsImportedByServer: true,
|
|
27
|
-
}),
|
|
28
23
|
],
|
|
29
24
|
optimizeDeps: {
|
|
30
25
|
include: ['react', 'react-dom', 'react-dom/client'],
|
|
@@ -33,7 +28,10 @@ const config: UserConfig = {
|
|
|
33
28
|
ssr: {
|
|
34
29
|
noExternal: ['@brillout/docpress', '@docsearch/react'],
|
|
35
30
|
},
|
|
31
|
+
// Suppress following warning:
|
|
32
|
+
// ```
|
|
33
|
+
// ▲ [WARNING] Transforming this CSS nesting syntax is not supported in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14") [unsupported-css-nesting]
|
|
34
|
+
// ```
|
|
35
|
+
build: { target: 'es2022' },
|
|
36
36
|
clearScreen: false,
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
export default config
|
package/config/getConfig.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export { getConfig }
|
|
2
|
-
import { assert, assertUsage } from '../utils/server'
|
|
3
|
-
import { Config } from '../types/Config'
|
|
4
|
-
|
|
5
|
-
function getConfig(): Config {
|
|
6
|
-
// We use `@ts-ignore` because the DocPress user most likely didn't add `vite/client` in his `tsconfig.json`.
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const globResult = import.meta.glob('/**/docpress.config.*([a-zA-Z0-9])', { eager: true })
|
|
9
|
-
const files = Object.keys(globResult)
|
|
10
|
-
assertUsage(files.length >= 1, 'No DocPress config file found `docpress.config.(js|ts|tsx|...)`')
|
|
11
|
-
assertUsage(
|
|
12
|
-
files.length === 1,
|
|
13
|
-
`Found multiple \`docpress.config.js\` files: ${files.map((f) => `\`${f}\``).join(', ')}. Define only one instead.`,
|
|
14
|
-
)
|
|
15
|
-
const exports: any = Object.values(globResult)[0]
|
|
16
|
-
const config: Config = exports.default || exports.config
|
|
17
|
-
assert(config)
|
|
18
|
-
return config
|
|
19
|
-
}
|
package/dist/config/getConfig.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { getConfig };
|
|
2
|
-
import { assert, assertUsage } from '../utils/server';
|
|
3
|
-
function getConfig() {
|
|
4
|
-
// We use `@ts-ignore` because the DocPress user most likely didn't add `vite/client` in his `tsconfig.json`.
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
var globResult = import.meta.glob('/**/docpress.config.*([a-zA-Z0-9])', { eager: true });
|
|
7
|
-
var files = Object.keys(globResult);
|
|
8
|
-
assertUsage(files.length >= 1, 'No DocPress config file found `docpress.config.(js|ts|tsx|...)`');
|
|
9
|
-
assertUsage(files.length === 1, "Found multiple `docpress.config.js` files: ".concat(files.map(function (f) { return "`".concat(f, "`"); }).join(', '), ". Define only one instead."));
|
|
10
|
-
var exports = Object.values(globResult)[0];
|
|
11
|
-
var config = exports.default || exports.config;
|
|
12
|
-
assert(config);
|
|
13
|
-
return config;
|
|
14
|
-
}
|