Skip to content

Commit 6423047

Browse files
author
Laegel
committed
feat(editLink): Adapted relevant edit link to target core repo
1 parent b22871a commit 6423047

File tree

4 files changed

+148
-316
lines changed

4 files changed

+148
-316
lines changed

src/theme/DocItem/index.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
import React from 'react';
8+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
9+
import DocPaginator from '@theme/DocPaginator';
10+
import DocVersionSuggestions from '@theme/DocVersionSuggestions';
11+
import Seo from '@theme/Seo';
12+
import LastUpdated from '@theme/LastUpdated';
13+
import TOC from '@theme/TOC';
14+
import EditThisPage from '@theme/EditThisPage';
15+
import clsx from 'clsx';
16+
import styles from './styles.module.css';
17+
import {
18+
useActivePlugin,
19+
useVersions,
20+
useActiveVersion,
21+
} from '@theme/hooks/useDocs';
22+
23+
function DocItem(props) {
24+
const context = useDocusaurusContext()
25+
const { siteConfig = {} } = context
26+
const {content: DocContent} = props;
27+
const {
28+
metadata,
29+
frontMatter: {
30+
image,
31+
keywords,
32+
hide_title: hideTitle,
33+
hide_table_of_contents: hideTableOfContents,
34+
},
35+
} = DocContent;
36+
const {
37+
description,
38+
title,
39+
editUrl,
40+
lastUpdatedAt,
41+
formattedLastUpdatedAt,
42+
lastUpdatedBy,
43+
} = metadata;
44+
const {pluginId} = useActivePlugin({
45+
failfast: true,
46+
});
47+
const versions = useVersions(pluginId);
48+
const version = useActiveVersion(pluginId); // If site is not versioned or only one version is included
49+
// we don't show the version badge
50+
// See https://github.com/facebook/docusaurus/issues/3362
51+
52+
const showVersionBadge = versions.length > 1;
53+
const tauriEditURL = editUrl.replace(siteConfig.presets[0][1].docs.editUrl + 'docs/en/', 'https://github.com/tauri-apps/tauri/edit/dev/docs/')
54+
return (
55+
<>
56+
<Seo
57+
{...{
58+
title,
59+
description,
60+
keywords,
61+
image,
62+
}}
63+
/>
64+
65+
<div className="row">
66+
<div
67+
className={clsx('col', {
68+
[styles.docItemCol]: !hideTableOfContents,
69+
})}>
70+
<DocVersionSuggestions />
71+
<div className={styles.docItemContainer}>
72+
<article>
73+
{showVersionBadge && (
74+
<div>
75+
<span className="badge badge--secondary">
76+
Version: {version.label}
77+
</span>
78+
</div>
79+
)}
80+
{!hideTitle && (
81+
<header>
82+
<h1 className={styles.docTitle}>{title}</h1>
83+
</header>
84+
)}
85+
<div className="markdown">
86+
<DocContent />
87+
</div>
88+
</article>
89+
{(tauriEditURL || lastUpdatedAt || lastUpdatedBy) && (
90+
<div className="margin-vert--xl">
91+
<div className="row">
92+
<div className="col">
93+
{tauriEditURL && <EditThisPage editUrl={tauriEditURL} />}
94+
</div>
95+
{(lastUpdatedAt || lastUpdatedBy) && (
96+
<LastUpdated
97+
lastUpdatedAt={lastUpdatedAt}
98+
formattedLastUpdatedAt={formattedLastUpdatedAt}
99+
lastUpdatedBy={lastUpdatedBy}
100+
/>
101+
)}
102+
</div>
103+
</div>
104+
)}
105+
<div className="margin-vert--lg">
106+
<DocPaginator metadata={metadata} />
107+
</div>
108+
</div>
109+
</div>
110+
{!hideTableOfContents && DocContent.toc && (
111+
<div className="col col--3">
112+
<TOC toc={DocContent.toc} />
113+
</div>
114+
)}
115+
</div>
116+
</>
117+
);
118+
}
119+
120+
export default DocItem;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
.docTitle {
9+
font-size: 3rem;
10+
margin-bottom: calc(var(--ifm-leading-desktop) * var(--ifm-leading));
11+
}
12+
13+
.docItemContainer {
14+
margin: 0 auto;
15+
padding: 0 0.5rem;
16+
}
17+
18+
@media only screen and (min-width: 997px) {
19+
.docItemCol {
20+
max-width: 75% !important;
21+
}
22+
}
23+
24+
@media only screen and (max-width: 996px) {
25+
.docItemContainer {
26+
padding: 0 0.3rem;
27+
}
28+
}

src/theme/DocItemOld/index.js

Lines changed: 0 additions & 241 deletions
This file was deleted.

0 commit comments

Comments
 (0)