@brillout/docpress 0.13.0 → 0.13.2
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/EditLink.tsx
CHANGED
|
@@ -22,7 +22,8 @@ function EditLink({ className, style }: { className?: string; style: React.CSSPr
|
|
|
22
22
|
)
|
|
23
23
|
const { urlPathname } = pageContext
|
|
24
24
|
const fsPath = urlPathname === '/' ? '/index/+Page.tsx' : `${urlPathname}/+Page.mdx`
|
|
25
|
-
const
|
|
25
|
+
const docsDir = pageContext.config.docsDir ?? 'docs'
|
|
26
|
+
const editLink = getRepoHref(`/${docsDir}/pages${fsPath}`, true)
|
|
26
27
|
return (
|
|
27
28
|
<a href={editLink} className={className} style={{ display: 'flex', alignItems: 'center', ...style }}>
|
|
28
29
|
{icon} Edit this page
|
package/components/RepoLink.tsx
CHANGED
|
@@ -6,16 +6,18 @@ import { assert } from '../utils/server'
|
|
|
6
6
|
import { usePageContext } from '../renderer/usePageContext'
|
|
7
7
|
|
|
8
8
|
function isRepoLink(href: string) {
|
|
9
|
-
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some((start) =>
|
|
9
|
+
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/', '/packages/'].some((start) =>
|
|
10
|
+
href.startsWith(start),
|
|
11
|
+
)
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
function RepoLink({ path, text
|
|
14
|
+
function RepoLink({ path, text }: { path: string; text?: string | React.ReactNode }) {
|
|
13
15
|
text = text || path
|
|
14
|
-
const href = getRepoHref(path
|
|
16
|
+
const href = getRepoHref(path)
|
|
15
17
|
return <a href={href}>{text}</a>
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
function getRepoHref(path: string, editMode
|
|
20
|
+
function getRepoHref(path: string, editMode = false) {
|
|
19
21
|
const pageContext = usePageContext()
|
|
20
22
|
assert(isRepoLink(path), { path })
|
|
21
23
|
if (!path.startsWith('/')) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { RepoLink };
|
|
2
2
|
export { getRepoHref };
|
|
3
3
|
import React from 'react';
|
|
4
|
-
declare function RepoLink({ path, text
|
|
4
|
+
declare function RepoLink({ path, text }: {
|
|
5
5
|
path: string;
|
|
6
6
|
text?: string | React.ReactNode;
|
|
7
|
-
editMode?: true;
|
|
8
7
|
}): React.JSX.Element;
|
|
9
|
-
declare function getRepoHref(path: string, editMode?:
|
|
8
|
+
declare function getRepoHref(path: string, editMode?: boolean): string;
|
|
@@ -4,15 +4,18 @@ import React from 'react';
|
|
|
4
4
|
import { assert } from '../utils/server';
|
|
5
5
|
import { usePageContext } from '../renderer/usePageContext';
|
|
6
6
|
function isRepoLink(href) {
|
|
7
|
-
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/'].some(function (start) {
|
|
7
|
+
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/', '/packages/'].some(function (start) {
|
|
8
|
+
return href.startsWith(start);
|
|
9
|
+
});
|
|
8
10
|
}
|
|
9
11
|
function RepoLink(_a) {
|
|
10
|
-
var path = _a.path, text = _a.text
|
|
12
|
+
var path = _a.path, text = _a.text;
|
|
11
13
|
text = text || path;
|
|
12
|
-
var href = getRepoHref(path
|
|
14
|
+
var href = getRepoHref(path);
|
|
13
15
|
return React.createElement("a", { href: href }, text);
|
|
14
16
|
}
|
|
15
17
|
function getRepoHref(path, editMode) {
|
|
18
|
+
if (editMode === void 0) { editMode = false; }
|
|
16
19
|
var pageContext = usePageContext();
|
|
17
20
|
assert(isRepoLink(path), { path: path });
|
|
18
21
|
if (!path.startsWith('/')) {
|
package/dist/types/Config.d.ts
CHANGED
package/package.json
CHANGED