@brillout/docpress 0.15.6 → 0.15.7
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/components/RepoLink.tsx
CHANGED
|
@@ -2,15 +2,8 @@ export { RepoLink }
|
|
|
2
2
|
export { getRepoHref }
|
|
3
3
|
|
|
4
4
|
import React from 'react'
|
|
5
|
-
import { assert } from '../utils/server'
|
|
6
5
|
import { usePageContext } from '../renderer/usePageContext'
|
|
7
6
|
|
|
8
|
-
function isRepoLink(href: string) {
|
|
9
|
-
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/', '/packages/'].some((start) =>
|
|
10
|
-
href.startsWith(start),
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
7
|
function RepoLink({ path, text }: { path: string; text?: string | React.ReactNode }) {
|
|
15
8
|
text = text || path
|
|
16
9
|
const href = getRepoHref(path)
|
|
@@ -19,7 +12,6 @@ function RepoLink({ path, text }: { path: string; text?: string | React.ReactNod
|
|
|
19
12
|
|
|
20
13
|
function getRepoHref(path: string, editMode = false) {
|
|
21
14
|
const pageContext = usePageContext()
|
|
22
|
-
assert(isRepoLink(path), { path })
|
|
23
15
|
if (!path.startsWith('/')) {
|
|
24
16
|
path = '/' + path
|
|
25
17
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export { RepoLink };
|
|
2
2
|
export { getRepoHref };
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { assert } from '../utils/server';
|
|
5
4
|
import { usePageContext } from '../renderer/usePageContext';
|
|
6
|
-
function isRepoLink(href) {
|
|
7
|
-
return ['/examples/', '/docs/', '/boilerplates/', '.github/', '/test/', '/packages/'].some(function (start) {
|
|
8
|
-
return href.startsWith(start);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
5
|
function RepoLink(_a) {
|
|
12
6
|
var path = _a.path, text = _a.text;
|
|
13
7
|
text = text || path;
|
|
@@ -17,7 +11,6 @@ function RepoLink(_a) {
|
|
|
17
11
|
function getRepoHref(path, editMode) {
|
|
18
12
|
if (editMode === void 0) { editMode = false; }
|
|
19
13
|
var pageContext = usePageContext();
|
|
20
|
-
assert(isRepoLink(path), { path: path });
|
|
21
14
|
if (!path.startsWith('/')) {
|
|
22
15
|
path = '/' + path;
|
|
23
16
|
}
|