@docusaurus/theme-classic 0.0.0-5846 → 0.0.0-5848
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/lib/theme/BlogArchivePage/index.js +9 -1
- package/lib/theme/BlogPostItem/Header/Info/index.js +14 -4
- package/lib/theme/DocItem/Footer/index.js +2 -10
- package/lib/theme/LastUpdated/index.d.ts +1 -1
- package/lib/theme/LastUpdated/index.js +17 -16
- package/package.json +14 -14
- package/src/theme/BlogArchivePage/index.tsx +11 -1
- package/src/theme/BlogPostItem/Header/Info/index.tsx +23 -4
- package/src/theme/DocItem/Footer/index.tsx +2 -6
- package/src/theme/LastUpdated/index.tsx +18 -13
- package/src/theme-classic.d.ts +0 -1
|
@@ -8,9 +8,17 @@ import React from 'react';
|
|
|
8
8
|
import Link from '@docusaurus/Link';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {PageMetadata} from '@docusaurus/theme-common';
|
|
11
|
+
import {useDateTimeFormat} from '@docusaurus/theme-common/internal';
|
|
11
12
|
import Layout from '@theme/Layout';
|
|
12
13
|
import Heading from '@theme/Heading';
|
|
13
14
|
function Year({year, posts}) {
|
|
15
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
16
|
+
day: 'numeric',
|
|
17
|
+
month: 'long',
|
|
18
|
+
timeZone: 'UTC',
|
|
19
|
+
});
|
|
20
|
+
const formatDate = (lastUpdated) =>
|
|
21
|
+
dateTimeFormat.format(new Date(lastUpdated));
|
|
14
22
|
return (
|
|
15
23
|
<>
|
|
16
24
|
<Heading as="h3" id={year}>
|
|
@@ -20,7 +28,7 @@ function Year({year, posts}) {
|
|
|
20
28
|
{posts.map((post) => (
|
|
21
29
|
<li key={post.metadata.date}>
|
|
22
30
|
<Link to={post.metadata.permalink}>
|
|
23
|
-
{post.metadata.
|
|
31
|
+
{formatDate(post.metadata.date)} - {post.metadata.title}
|
|
24
32
|
</Link>
|
|
25
33
|
</li>
|
|
26
34
|
))}
|
|
@@ -8,7 +8,10 @@ import React from 'react';
|
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import {translate} from '@docusaurus/Translate';
|
|
10
10
|
import {usePluralForm} from '@docusaurus/theme-common';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useBlogPost,
|
|
13
|
+
useDateTimeFormat,
|
|
14
|
+
} from '@docusaurus/theme-common/internal';
|
|
12
15
|
import styles from './styles.module.css';
|
|
13
16
|
// Very simple pluralization: probably good enough for now
|
|
14
17
|
function useReadingTimePlural() {
|
|
@@ -33,7 +36,7 @@ function ReadingTime({readingTime}) {
|
|
|
33
36
|
const readingTimePlural = useReadingTimePlural();
|
|
34
37
|
return <>{readingTimePlural(readingTime)}</>;
|
|
35
38
|
}
|
|
36
|
-
function
|
|
39
|
+
function DateTime({date, formattedDate}) {
|
|
37
40
|
return <time dateTime={date}>{formattedDate}</time>;
|
|
38
41
|
}
|
|
39
42
|
function Spacer() {
|
|
@@ -41,10 +44,17 @@ function Spacer() {
|
|
|
41
44
|
}
|
|
42
45
|
export default function BlogPostItemHeaderInfo({className}) {
|
|
43
46
|
const {metadata} = useBlogPost();
|
|
44
|
-
const {date,
|
|
47
|
+
const {date, readingTime} = metadata;
|
|
48
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
49
|
+
day: 'numeric',
|
|
50
|
+
month: 'long',
|
|
51
|
+
year: 'numeric',
|
|
52
|
+
timeZone: 'UTC',
|
|
53
|
+
});
|
|
54
|
+
const formatDate = (blogDate) => dateTimeFormat.format(new Date(blogDate));
|
|
45
55
|
return (
|
|
46
56
|
<div className={clsx(styles.container, 'margin-vert--md', className)}>
|
|
47
|
-
<
|
|
57
|
+
<DateTime date={date} formattedDate={formatDate(date)} />
|
|
48
58
|
{typeof readingTime !== 'undefined' && (
|
|
49
59
|
<>
|
|
50
60
|
<Spacer />
|
|
@@ -25,12 +25,7 @@ function TagsRow(props) {
|
|
|
25
25
|
</div>
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
|
-
function EditMetaRow({
|
|
29
|
-
editUrl,
|
|
30
|
-
lastUpdatedAt,
|
|
31
|
-
lastUpdatedBy,
|
|
32
|
-
formattedLastUpdatedAt,
|
|
33
|
-
}) {
|
|
28
|
+
function EditMetaRow({editUrl, lastUpdatedAt, lastUpdatedBy}) {
|
|
34
29
|
return (
|
|
35
30
|
<div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, 'row')}>
|
|
36
31
|
<div className="col">{editUrl && <EditThisPage editUrl={editUrl} />}</div>
|
|
@@ -39,7 +34,6 @@ function EditMetaRow({
|
|
|
39
34
|
{(lastUpdatedAt || lastUpdatedBy) && (
|
|
40
35
|
<LastUpdated
|
|
41
36
|
lastUpdatedAt={lastUpdatedAt}
|
|
42
|
-
formattedLastUpdatedAt={formattedLastUpdatedAt}
|
|
43
37
|
lastUpdatedBy={lastUpdatedBy}
|
|
44
38
|
/>
|
|
45
39
|
)}
|
|
@@ -49,8 +43,7 @@ function EditMetaRow({
|
|
|
49
43
|
}
|
|
50
44
|
export default function DocItemFooter() {
|
|
51
45
|
const {metadata} = useDoc();
|
|
52
|
-
const {editUrl, lastUpdatedAt,
|
|
53
|
-
metadata;
|
|
46
|
+
const {editUrl, lastUpdatedAt, lastUpdatedBy, tags} = metadata;
|
|
54
47
|
const canDisplayTagsRow = tags.length > 0;
|
|
55
48
|
const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
|
|
56
49
|
const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
|
|
@@ -66,7 +59,6 @@ export default function DocItemFooter() {
|
|
|
66
59
|
editUrl={editUrl}
|
|
67
60
|
lastUpdatedAt={lastUpdatedAt}
|
|
68
61
|
lastUpdatedBy={lastUpdatedBy}
|
|
69
|
-
formattedLastUpdatedAt={formattedLastUpdatedAt}
|
|
70
62
|
/>
|
|
71
63
|
)}
|
|
72
64
|
</footer>
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
/// <reference types="react" />
|
|
8
8
|
import type { Props } from '@theme/LastUpdated';
|
|
9
|
-
export default function LastUpdated({ lastUpdatedAt,
|
|
9
|
+
export default function LastUpdated({ lastUpdatedAt, lastUpdatedBy, }: Props): JSX.Element;
|
|
@@ -7,7 +7,16 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import Translate from '@docusaurus/Translate';
|
|
9
9
|
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
10
|
-
|
|
10
|
+
import {useDateTimeFormat} from '@docusaurus/theme-common/internal';
|
|
11
|
+
function LastUpdatedAtDate({lastUpdatedAt}) {
|
|
12
|
+
const atDate = new Date(lastUpdatedAt * 1000);
|
|
13
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
14
|
+
day: 'numeric',
|
|
15
|
+
month: 'short',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
timeZone: 'UTC',
|
|
18
|
+
});
|
|
19
|
+
const formattedLastUpdatedAt = dateTimeFormat.format(atDate);
|
|
11
20
|
return (
|
|
12
21
|
<Translate
|
|
13
22
|
id="theme.lastUpdated.atDate"
|
|
@@ -15,7 +24,7 @@ function LastUpdatedAtDate({lastUpdatedAt, formattedLastUpdatedAt}) {
|
|
|
15
24
|
values={{
|
|
16
25
|
date: (
|
|
17
26
|
<b>
|
|
18
|
-
<time dateTime={
|
|
27
|
+
<time dateTime={atDate.toISOString()}>
|
|
19
28
|
{formattedLastUpdatedAt}
|
|
20
29
|
</time>
|
|
21
30
|
</b>
|
|
@@ -37,26 +46,18 @@ function LastUpdatedByUser({lastUpdatedBy}) {
|
|
|
37
46
|
</Translate>
|
|
38
47
|
);
|
|
39
48
|
}
|
|
40
|
-
export default function LastUpdated({
|
|
41
|
-
lastUpdatedAt,
|
|
42
|
-
formattedLastUpdatedAt,
|
|
43
|
-
lastUpdatedBy,
|
|
44
|
-
}) {
|
|
49
|
+
export default function LastUpdated({lastUpdatedAt, lastUpdatedBy}) {
|
|
45
50
|
return (
|
|
46
51
|
<span className={ThemeClassNames.common.lastUpdated}>
|
|
47
52
|
<Translate
|
|
48
53
|
id="theme.lastUpdated.lastUpdatedAtBy"
|
|
49
54
|
description="The sentence used to display when a page has been last updated, and by who"
|
|
50
55
|
values={{
|
|
51
|
-
atDate:
|
|
52
|
-
lastUpdatedAt
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/>
|
|
57
|
-
) : (
|
|
58
|
-
''
|
|
59
|
-
),
|
|
56
|
+
atDate: lastUpdatedAt ? (
|
|
57
|
+
<LastUpdatedAtDate lastUpdatedAt={lastUpdatedAt} />
|
|
58
|
+
) : (
|
|
59
|
+
''
|
|
60
|
+
),
|
|
60
61
|
byUser: lastUpdatedBy ? (
|
|
61
62
|
<LastUpdatedByUser lastUpdatedBy={lastUpdatedBy} />
|
|
62
63
|
) : (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/theme-classic",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5848",
|
|
4
4
|
"description": "Classic theme for Docusaurus",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/theme-classic.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"copy:watch": "node ../../admin/scripts/copyUntypedFiles.js --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "0.0.0-
|
|
24
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
25
|
-
"@docusaurus/module-type-aliases": "0.0.0-
|
|
26
|
-
"@docusaurus/plugin-content-blog": "0.0.0-
|
|
27
|
-
"@docusaurus/plugin-content-docs": "0.0.0-
|
|
28
|
-
"@docusaurus/plugin-content-pages": "0.0.0-
|
|
29
|
-
"@docusaurus/theme-common": "0.0.0-
|
|
30
|
-
"@docusaurus/theme-translations": "0.0.0-
|
|
31
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
-
"@docusaurus/utils": "0.0.0-
|
|
33
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
34
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
23
|
+
"@docusaurus/core": "0.0.0-5848",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5848",
|
|
25
|
+
"@docusaurus/module-type-aliases": "0.0.0-5848",
|
|
26
|
+
"@docusaurus/plugin-content-blog": "0.0.0-5848",
|
|
27
|
+
"@docusaurus/plugin-content-docs": "0.0.0-5848",
|
|
28
|
+
"@docusaurus/plugin-content-pages": "0.0.0-5848",
|
|
29
|
+
"@docusaurus/theme-common": "0.0.0-5848",
|
|
30
|
+
"@docusaurus/theme-translations": "0.0.0-5848",
|
|
31
|
+
"@docusaurus/types": "0.0.0-5848",
|
|
32
|
+
"@docusaurus/utils": "0.0.0-5848",
|
|
33
|
+
"@docusaurus/utils-common": "0.0.0-5848",
|
|
34
|
+
"@docusaurus/utils-validation": "0.0.0-5848",
|
|
35
35
|
"@mdx-js/react": "^3.0.0",
|
|
36
36
|
"clsx": "^2.0.0",
|
|
37
37
|
"copy-text-to-clipboard": "^3.2.0",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=18.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "e96ac1a4796aa654d6a6c200f785fb4059619718"
|
|
65
65
|
}
|
|
@@ -9,6 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import Link from '@docusaurus/Link';
|
|
10
10
|
import {translate} from '@docusaurus/Translate';
|
|
11
11
|
import {PageMetadata} from '@docusaurus/theme-common';
|
|
12
|
+
import {useDateTimeFormat} from '@docusaurus/theme-common/internal';
|
|
12
13
|
import Layout from '@theme/Layout';
|
|
13
14
|
import type {ArchiveBlogPost, Props} from '@theme/BlogArchivePage';
|
|
14
15
|
import Heading from '@theme/Heading';
|
|
@@ -19,6 +20,15 @@ type YearProp = {
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
function Year({year, posts}: YearProp) {
|
|
23
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
24
|
+
day: 'numeric',
|
|
25
|
+
month: 'long',
|
|
26
|
+
timeZone: 'UTC',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const formatDate = (lastUpdated: string) =>
|
|
30
|
+
dateTimeFormat.format(new Date(lastUpdated));
|
|
31
|
+
|
|
22
32
|
return (
|
|
23
33
|
<>
|
|
24
34
|
<Heading as="h3" id={year}>
|
|
@@ -28,7 +38,7 @@ function Year({year, posts}: YearProp) {
|
|
|
28
38
|
{posts.map((post) => (
|
|
29
39
|
<li key={post.metadata.date}>
|
|
30
40
|
<Link to={post.metadata.permalink}>
|
|
31
|
-
{post.metadata.
|
|
41
|
+
{formatDate(post.metadata.date)} - {post.metadata.title}
|
|
32
42
|
</Link>
|
|
33
43
|
</li>
|
|
34
44
|
))}
|
|
@@ -9,7 +9,10 @@ import React from 'react';
|
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import {translate} from '@docusaurus/Translate';
|
|
11
11
|
import {usePluralForm} from '@docusaurus/theme-common';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
useBlogPost,
|
|
14
|
+
useDateTimeFormat,
|
|
15
|
+
} from '@docusaurus/theme-common/internal';
|
|
13
16
|
import type {Props} from '@theme/BlogPostItem/Header/Info';
|
|
14
17
|
|
|
15
18
|
import styles from './styles.module.css';
|
|
@@ -39,7 +42,13 @@ function ReadingTime({readingTime}: {readingTime: number}) {
|
|
|
39
42
|
return <>{readingTimePlural(readingTime)}</>;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
function
|
|
45
|
+
function DateTime({
|
|
46
|
+
date,
|
|
47
|
+
formattedDate,
|
|
48
|
+
}: {
|
|
49
|
+
date: string;
|
|
50
|
+
formattedDate: string;
|
|
51
|
+
}) {
|
|
43
52
|
return <time dateTime={date}>{formattedDate}</time>;
|
|
44
53
|
}
|
|
45
54
|
|
|
@@ -51,11 +60,21 @@ export default function BlogPostItemHeaderInfo({
|
|
|
51
60
|
className,
|
|
52
61
|
}: Props): JSX.Element {
|
|
53
62
|
const {metadata} = useBlogPost();
|
|
54
|
-
const {date,
|
|
63
|
+
const {date, readingTime} = metadata;
|
|
64
|
+
|
|
65
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
66
|
+
day: 'numeric',
|
|
67
|
+
month: 'long',
|
|
68
|
+
year: 'numeric',
|
|
69
|
+
timeZone: 'UTC',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const formatDate = (blogDate: string) =>
|
|
73
|
+
dateTimeFormat.format(new Date(blogDate));
|
|
55
74
|
|
|
56
75
|
return (
|
|
57
76
|
<div className={clsx(styles.container, 'margin-vert--md', className)}>
|
|
58
|
-
<
|
|
77
|
+
<DateTime date={date} formattedDate={formatDate(date)} />
|
|
59
78
|
{typeof readingTime !== 'undefined' && (
|
|
60
79
|
<>
|
|
61
80
|
<Spacer />
|
|
@@ -33,13 +33,12 @@ function TagsRow(props: TagsListInlineProps) {
|
|
|
33
33
|
|
|
34
34
|
type EditMetaRowProps = Pick<
|
|
35
35
|
DocContextValue['metadata'],
|
|
36
|
-
'editUrl' | 'lastUpdatedAt' | 'lastUpdatedBy'
|
|
36
|
+
'editUrl' | 'lastUpdatedAt' | 'lastUpdatedBy'
|
|
37
37
|
>;
|
|
38
38
|
function EditMetaRow({
|
|
39
39
|
editUrl,
|
|
40
40
|
lastUpdatedAt,
|
|
41
41
|
lastUpdatedBy,
|
|
42
|
-
formattedLastUpdatedAt,
|
|
43
42
|
}: EditMetaRowProps) {
|
|
44
43
|
return (
|
|
45
44
|
<div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, 'row')}>
|
|
@@ -49,7 +48,6 @@ function EditMetaRow({
|
|
|
49
48
|
{(lastUpdatedAt || lastUpdatedBy) && (
|
|
50
49
|
<LastUpdated
|
|
51
50
|
lastUpdatedAt={lastUpdatedAt}
|
|
52
|
-
formattedLastUpdatedAt={formattedLastUpdatedAt}
|
|
53
51
|
lastUpdatedBy={lastUpdatedBy}
|
|
54
52
|
/>
|
|
55
53
|
)}
|
|
@@ -60,8 +58,7 @@ function EditMetaRow({
|
|
|
60
58
|
|
|
61
59
|
export default function DocItemFooter(): JSX.Element | null {
|
|
62
60
|
const {metadata} = useDoc();
|
|
63
|
-
const {editUrl, lastUpdatedAt,
|
|
64
|
-
metadata;
|
|
61
|
+
const {editUrl, lastUpdatedAt, lastUpdatedBy, tags} = metadata;
|
|
65
62
|
|
|
66
63
|
const canDisplayTagsRow = tags.length > 0;
|
|
67
64
|
const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
|
|
@@ -81,7 +78,6 @@ export default function DocItemFooter(): JSX.Element | null {
|
|
|
81
78
|
editUrl={editUrl}
|
|
82
79
|
lastUpdatedAt={lastUpdatedAt}
|
|
83
80
|
lastUpdatedBy={lastUpdatedBy}
|
|
84
|
-
formattedLastUpdatedAt={formattedLastUpdatedAt}
|
|
85
81
|
/>
|
|
86
82
|
)}
|
|
87
83
|
</footer>
|
|
@@ -8,15 +8,25 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import Translate from '@docusaurus/Translate';
|
|
10
10
|
import {ThemeClassNames} from '@docusaurus/theme-common';
|
|
11
|
+
import {useDateTimeFormat} from '@docusaurus/theme-common/internal';
|
|
11
12
|
import type {Props} from '@theme/LastUpdated';
|
|
12
13
|
|
|
13
14
|
function LastUpdatedAtDate({
|
|
14
15
|
lastUpdatedAt,
|
|
15
|
-
formattedLastUpdatedAt,
|
|
16
16
|
}: {
|
|
17
17
|
lastUpdatedAt: number;
|
|
18
|
-
formattedLastUpdatedAt: string;
|
|
19
18
|
}): JSX.Element {
|
|
19
|
+
const atDate = new Date(lastUpdatedAt * 1000);
|
|
20
|
+
|
|
21
|
+
const dateTimeFormat = useDateTimeFormat({
|
|
22
|
+
day: 'numeric',
|
|
23
|
+
month: 'short',
|
|
24
|
+
year: 'numeric',
|
|
25
|
+
timeZone: 'UTC',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const formattedLastUpdatedAt = dateTimeFormat.format(atDate);
|
|
29
|
+
|
|
20
30
|
return (
|
|
21
31
|
<Translate
|
|
22
32
|
id="theme.lastUpdated.atDate"
|
|
@@ -24,7 +34,7 @@ function LastUpdatedAtDate({
|
|
|
24
34
|
values={{
|
|
25
35
|
date: (
|
|
26
36
|
<b>
|
|
27
|
-
<time dateTime={
|
|
37
|
+
<time dateTime={atDate.toISOString()}>
|
|
28
38
|
{formattedLastUpdatedAt}
|
|
29
39
|
</time>
|
|
30
40
|
</b>
|
|
@@ -54,7 +64,6 @@ function LastUpdatedByUser({
|
|
|
54
64
|
|
|
55
65
|
export default function LastUpdated({
|
|
56
66
|
lastUpdatedAt,
|
|
57
|
-
formattedLastUpdatedAt,
|
|
58
67
|
lastUpdatedBy,
|
|
59
68
|
}: Props): JSX.Element {
|
|
60
69
|
return (
|
|
@@ -63,15 +72,11 @@ export default function LastUpdated({
|
|
|
63
72
|
id="theme.lastUpdated.lastUpdatedAtBy"
|
|
64
73
|
description="The sentence used to display when a page has been last updated, and by who"
|
|
65
74
|
values={{
|
|
66
|
-
atDate:
|
|
67
|
-
lastUpdatedAt
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/>
|
|
72
|
-
) : (
|
|
73
|
-
''
|
|
74
|
-
),
|
|
75
|
+
atDate: lastUpdatedAt ? (
|
|
76
|
+
<LastUpdatedAtDate lastUpdatedAt={lastUpdatedAt} />
|
|
77
|
+
) : (
|
|
78
|
+
''
|
|
79
|
+
),
|
|
75
80
|
byUser: lastUpdatedBy ? (
|
|
76
81
|
<LastUpdatedByUser lastUpdatedBy={lastUpdatedBy} />
|
|
77
82
|
) : (
|
package/src/theme-classic.d.ts
CHANGED