@dino-ovum/theme 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +22 -2
- package/package.json +36 -3
- package/src/app/Root.jsx +5 -0
- package/src/app/components/DocumentCategoryPage.jsx +21 -0
- package/src/app/components/DocumentPagination.jsx +58 -0
- package/src/app/components/DocumentTable.jsx +116 -0
- package/src/app/components/ErrorPageContent.jsx +36 -0
- package/src/app/components/HomeHeading.jsx +34 -0
- package/src/app/components/LibraryLayout.jsx +36 -0
- package/src/app/components/NotFoundContent.jsx +24 -0
- package/src/app/components/SpaceOverview.jsx +17 -0
- package/src/app/components/StatusPage.jsx +54 -0
- package/src/app/components/Updates.jsx +137 -0
- package/src/app/components/navigation/Breadcrumbs.jsx +52 -0
- package/src/app/components/navigation/ColorModeToggle.jsx +66 -0
- package/src/app/components/navigation/LanguageDropdown.jsx +108 -0
- package/src/app/components/navigation/LibraryNavigation.jsx +20 -0
- package/src/app/components/navigation/MobileNavigation.jsx +12 -0
- package/src/app/components/navigation/RecentUpdatesLink.jsx +36 -0
- package/src/app/components/navigation/SidebarToggle.jsx +60 -0
- package/src/app/components/ui/DocumentDate.jsx +25 -0
- package/src/app/components/ui/FilterChip.jsx +14 -0
- package/src/app/components/ui/TopicBadge.jsx +14 -0
- package/src/app/hooks/useDocumentTable.js +60 -0
- package/src/app/hooks/useUpdates.js +23 -0
- package/src/app/logic/document-breadcrumbs.js +24 -0
- package/src/app/logic/document-dates.js +19 -0
- package/src/app/logic/document-list.js +15 -0
- package/src/app/logic/document-location.js +19 -0
- package/src/app/logic/document-taxonomy.js +10 -0
- package/src/app/logic/pagination.js +24 -0
- package/src/app/logic/update-groups.js +18 -0
- package/src/app/providers/AppProviders.jsx +5 -0
- package/src/app/providers/SidebarVisibility.jsx +19 -0
- package/src/app/routes.js +15 -0
- package/src/app/styles/components/DocumentCategoryPage.module.scss +50 -0
- package/src/app/styles/components/DocumentPagination.module.scss +45 -0
- package/src/app/styles/components/DocumentTable.module.scss +188 -0
- package/src/app/styles/components/LibraryLayout.module.scss +59 -0
- package/src/app/styles/components/StatusPage.module.scss +55 -0
- package/src/app/styles/components/Updates.module.scss +102 -0
- package/src/app/styles/components/navigation/Breadcrumbs.module.scss +5 -0
- package/src/app/styles/components/navigation/LanguageDropdown.module.scss +49 -0
- package/src/app/styles/components/navigation/MobileNavigation.module.scss +5 -0
- package/src/app/styles/components/navigation/NavigationControls.module.scss +70 -0
- package/src/app/styles/components/ui/FilterChip.module.scss +28 -0
- package/src/app/styles/components/ui/TopicBadge.module.scss +42 -0
- package/src/app/styles/custom.scss +7 -0
- package/src/app/styles/globals.css +64 -0
- package/src/app/styles/pages/home.scss +92 -0
- package/src/app/styles/theme/navigation.scss +56 -0
- package/src/app/styles/theme/tags.css +21 -0
- package/src/app/styles/tokens/_breakpoints.scss +4 -0
- package/src/app/styles/tokens/colors.css +62 -0
- package/src/app/styles/tokens/layout.css +20 -0
- package/src/app/styles/tokens/typography.css +11 -0
- package/src/assets/fonts/pretendard/LICENSE +94 -0
- package/src/assets/fonts/pretendard/PretendardStd-Bold.woff2 +0 -0
- package/src/assets/fonts/pretendard/README.md +8 -0
- package/src/index.js +48 -0
- package/src/theme/ColorModeToggle/index.jsx +1 -0
- package/src/theme/DinoOvum/DocumentTable.jsx +1 -0
- package/src/theme/DinoOvum/HomeHeading.jsx +1 -0
- package/src/theme/DinoOvum/LibraryLayout.jsx +1 -0
- package/src/theme/DinoOvum/Updates.jsx +1 -0
- package/src/theme/DinoOvum/UpdatesPage.jsx +20 -0
- package/src/theme/DocBreadcrumbs/index.jsx +1 -0
- package/src/theme/DocCardList/index.jsx +18 -0
- package/src/theme/DocItem/Layout/index.jsx +17 -0
- package/src/theme/DocRoot/Layout/index.jsx +1 -0
- package/src/theme/DocSidebarItem/Category/index.jsx +15 -0
- package/src/theme/ErrorPageContent.jsx +1 -0
- package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.jsx +1 -0
- package/src/theme/Navbar/Search/index.jsx +13 -0
- package/src/theme/NavbarItem/ComponentTypes.jsx +11 -0
- package/src/theme/NotFound/Content/index.jsx +1 -0
- package/src/theme/Root.jsx +1 -0
- package/src/translations/ja.json +107 -0
- package/src/translations/ko.json +107 -0
- package/src/utils.js +4 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import styles from '../../styles/components/navigation/Breadcrumbs.module.scss';
|
|
2
|
+
import {useLocation} from '@docusaurus/router';
|
|
3
|
+
import {usePluginData} from '@docusaurus/useGlobalData';
|
|
4
|
+
import Link from '@docusaurus/Link';
|
|
5
|
+
import OriginalDocBreadcrumbs from '@theme-init/DocBreadcrumbs';
|
|
6
|
+
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
|
|
7
|
+
import StructuredData from '@theme/DocBreadcrumbs/StructuredData';
|
|
8
|
+
import {documentBreadcrumbs} from '../../logic/document-breadcrumbs.js';
|
|
9
|
+
import {translate} from '@docusaurus/Translate';
|
|
10
|
+
|
|
11
|
+
export default function DocBreadcrumbs() {
|
|
12
|
+
const {pathname} = useLocation();
|
|
13
|
+
const {documentEntries, categoryLabels} = usePluginData('library-navigation');
|
|
14
|
+
const items = documentBreadcrumbs(documentEntries, pathname, categoryLabels);
|
|
15
|
+
if (!items) return <OriginalDocBreadcrumbs />;
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<StructuredData
|
|
19
|
+
breadcrumbs={items.filter((item) => item.href).map((item) => ({...item, type: 'link'}))}
|
|
20
|
+
/>
|
|
21
|
+
<nav
|
|
22
|
+
aria-label={translate({id: 'docnest.breadcrumbs', message: 'Breadcrumbs'})}
|
|
23
|
+
className={`theme-doc-breadcrumbs ${styles.breadcrumbs}`}
|
|
24
|
+
>
|
|
25
|
+
<ul className="breadcrumbs">
|
|
26
|
+
<HomeBreadcrumbItem />
|
|
27
|
+
{items.map((item, index) => {
|
|
28
|
+
const last = index === items.length - 1;
|
|
29
|
+
return (
|
|
30
|
+
<li
|
|
31
|
+
key={index}
|
|
32
|
+
className={`breadcrumbs__item${last ? ' breadcrumbs__item--active' : ''}`}
|
|
33
|
+
aria-current={last ? 'page' : undefined}
|
|
34
|
+
>
|
|
35
|
+
{!last && item.href ? (
|
|
36
|
+
<Link
|
|
37
|
+
to={item.href}
|
|
38
|
+
className="breadcrumbs__link"
|
|
39
|
+
>
|
|
40
|
+
{item.label}
|
|
41
|
+
</Link>
|
|
42
|
+
) : (
|
|
43
|
+
<span className="breadcrumbs__link">{item.label}</span>
|
|
44
|
+
)}
|
|
45
|
+
</li>
|
|
46
|
+
);
|
|
47
|
+
})}
|
|
48
|
+
</ul>
|
|
49
|
+
</nav>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {useEffect, useRef} from 'react';
|
|
2
|
+
import styles from '../../styles/components/navigation/NavigationControls.module.scss';
|
|
3
|
+
import {flushSync} from 'react-dom';
|
|
4
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
5
|
+
import {useColorMode} from '@docusaurus/theme-common';
|
|
6
|
+
import IconLightMode from '@theme/Icon/LightMode';
|
|
7
|
+
import IconDarkMode from '@theme/Icon/DarkMode';
|
|
8
|
+
import {translate} from '@docusaurus/Translate';
|
|
9
|
+
|
|
10
|
+
export default function ColorModeToggle({className, buttonClassName, onChange}) {
|
|
11
|
+
const {colorMode} = useColorMode();
|
|
12
|
+
const isBrowser = useIsBrowser();
|
|
13
|
+
const transitionRef = useRef(null);
|
|
14
|
+
const label =
|
|
15
|
+
colorMode === 'dark'
|
|
16
|
+
? translate({id: 'docnest.theme.light', message: 'Switch to light mode'})
|
|
17
|
+
: translate({id: 'docnest.theme.dark', message: 'Switch to dark mode'});
|
|
18
|
+
|
|
19
|
+
useEffect(() => () => transitionRef.current?.skipTransition(), []);
|
|
20
|
+
|
|
21
|
+
function toggleTheme() {
|
|
22
|
+
transitionRef.current?.skipTransition();
|
|
23
|
+
// Read at update time so rapid clicks still alternate correctly.
|
|
24
|
+
const updateTheme = () =>
|
|
25
|
+
onChange(document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark');
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
!document.startViewTransition ||
|
|
29
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
30
|
+
) {
|
|
31
|
+
updateTheme();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const transition = document.startViewTransition(() => flushSync(updateTheme));
|
|
36
|
+
transitionRef.current = transition;
|
|
37
|
+
// Skipping an interrupted transition rejects ready, but still applies its update.
|
|
38
|
+
transition.ready.catch(() => {});
|
|
39
|
+
const clearTransition = () => {
|
|
40
|
+
if (transitionRef.current === transition) transitionRef.current = null;
|
|
41
|
+
};
|
|
42
|
+
transition.finished.then(clearTransition, clearTransition);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className={`${styles['theme-toggle']} ${className ?? ''}`}>
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
className={`library-theme-toggle clean-btn ${styles.control} ${buttonClassName ?? ''}`}
|
|
50
|
+
aria-label={label}
|
|
51
|
+
title={label}
|
|
52
|
+
disabled={!isBrowser}
|
|
53
|
+
onClick={toggleTheme}
|
|
54
|
+
>
|
|
55
|
+
<IconLightMode
|
|
56
|
+
className={styles['light-icon']}
|
|
57
|
+
aria-hidden="true"
|
|
58
|
+
/>
|
|
59
|
+
<IconDarkMode
|
|
60
|
+
className={styles['dark-icon']}
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
/>
|
|
63
|
+
</button>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {useEffect, useId, useRef, useState} from 'react';
|
|
2
|
+
import {useHistorySelector} from '@docusaurus/theme-common';
|
|
3
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
4
|
+
import {useAlternatePageUtils} from '@docusaurus/theme-common/internal';
|
|
5
|
+
import {translate} from '@docusaurus/Translate';
|
|
6
|
+
import IconLanguage from '@theme/Icon/Language';
|
|
7
|
+
import controls from '../../styles/components/navigation/NavigationControls.module.scss';
|
|
8
|
+
import styles from '../../styles/components/navigation/LanguageDropdown.module.scss';
|
|
9
|
+
|
|
10
|
+
export default function LanguageDropdown({mobile = false}) {
|
|
11
|
+
const {
|
|
12
|
+
i18n: {currentLocale, locales, localeConfigs},
|
|
13
|
+
} = useDocusaurusContext();
|
|
14
|
+
const {createUrl} = useAlternatePageUtils();
|
|
15
|
+
const search = useHistorySelector((history) => history.location.search);
|
|
16
|
+
const hash = useHistorySelector((history) => history.location.hash);
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const root = useRef(null);
|
|
19
|
+
const button = useRef(null);
|
|
20
|
+
const id = useId();
|
|
21
|
+
const label = translate({id: 'docnest.language.label', message: 'Change language'});
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!open) return undefined;
|
|
25
|
+
const closeOutside = (event) => {
|
|
26
|
+
if (!root.current?.contains(event.target)) setOpen(false);
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener('pointerdown', closeOutside);
|
|
29
|
+
document.addEventListener('focusin', closeOutside);
|
|
30
|
+
return () => {
|
|
31
|
+
document.removeEventListener('pointerdown', closeOutside);
|
|
32
|
+
document.removeEventListener('focusin', closeOutside);
|
|
33
|
+
};
|
|
34
|
+
}, [open]);
|
|
35
|
+
|
|
36
|
+
// The same control remains in the top bar at every viewport size.
|
|
37
|
+
if (mobile) return null;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
className={styles.dropdown}
|
|
42
|
+
ref={root}
|
|
43
|
+
onKeyDown={(event) => {
|
|
44
|
+
if (event.key === 'Escape') {
|
|
45
|
+
setOpen(false);
|
|
46
|
+
button.current?.focus();
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<button
|
|
51
|
+
ref={button}
|
|
52
|
+
type="button"
|
|
53
|
+
className={`clean-btn ${controls.control} ${styles.trigger}`}
|
|
54
|
+
title={label}
|
|
55
|
+
aria-label={`${label}: ${localeConfigs[currentLocale].label}`}
|
|
56
|
+
aria-expanded={open}
|
|
57
|
+
aria-controls={id}
|
|
58
|
+
onClick={() => setOpen((value) => !value)}
|
|
59
|
+
onKeyDown={(event) => {
|
|
60
|
+
if (event.key === 'ArrowDown') {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
setOpen(true);
|
|
63
|
+
requestAnimationFrame(() => root.current?.querySelector('a')?.focus());
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<IconLanguage
|
|
68
|
+
width={20}
|
|
69
|
+
height={20}
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
/>
|
|
72
|
+
<svg
|
|
73
|
+
width="8"
|
|
74
|
+
height="8"
|
|
75
|
+
viewBox="0 0 8 8"
|
|
76
|
+
aria-hidden="true"
|
|
77
|
+
>
|
|
78
|
+
<path
|
|
79
|
+
d="m1 2.5 3 3 3-3"
|
|
80
|
+
fill="none"
|
|
81
|
+
stroke="currentColor"
|
|
82
|
+
strokeWidth="1.2"
|
|
83
|
+
/>
|
|
84
|
+
</svg>
|
|
85
|
+
</button>
|
|
86
|
+
<ul
|
|
87
|
+
id={id}
|
|
88
|
+
className={styles.options}
|
|
89
|
+
hidden={!open}
|
|
90
|
+
aria-label={label}
|
|
91
|
+
>
|
|
92
|
+
{locales.map((locale) => (
|
|
93
|
+
<li key={locale}>
|
|
94
|
+
<a
|
|
95
|
+
href={`${createUrl({locale, fullyQualified: false})}${search}${hash}`}
|
|
96
|
+
lang={localeConfigs[locale].htmlLang}
|
|
97
|
+
hrefLang={localeConfigs[locale].htmlLang}
|
|
98
|
+
aria-current={locale === currentLocale ? 'true' : undefined}
|
|
99
|
+
>
|
|
100
|
+
<span>{localeConfigs[locale].label}</span>
|
|
101
|
+
{locale === currentLocale && <span aria-hidden="true">✓</span>}
|
|
102
|
+
</a>
|
|
103
|
+
</li>
|
|
104
|
+
))}
|
|
105
|
+
</ul>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {useLocation} from '@docusaurus/router';
|
|
2
|
+
import {usePluginData} from '@docusaurus/useGlobalData';
|
|
3
|
+
import DocSidebarItems from '@theme/DocSidebarItems';
|
|
4
|
+
|
|
5
|
+
export default function LibraryNavigation({onNavigate}) {
|
|
6
|
+
const {sidebar} = usePluginData('library-navigation');
|
|
7
|
+
const {pathname} = useLocation();
|
|
8
|
+
return (
|
|
9
|
+
<ul className="menu__list">
|
|
10
|
+
<DocSidebarItems
|
|
11
|
+
items={sidebar}
|
|
12
|
+
activePath={pathname}
|
|
13
|
+
level={1}
|
|
14
|
+
onItemClick={(item) => {
|
|
15
|
+
if (item.type === 'link' || item.href) onNavigate?.();
|
|
16
|
+
}}
|
|
17
|
+
/>
|
|
18
|
+
</ul>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styles from '../../styles/components/navigation/MobileNavigation.module.scss';
|
|
2
|
+
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
|
|
3
|
+
import LibraryNavigation from './LibraryNavigation.jsx';
|
|
4
|
+
|
|
5
|
+
export default function MobileNavigation() {
|
|
6
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
7
|
+
return (
|
|
8
|
+
<div className={styles.tree}>
|
|
9
|
+
<LibraryNavigation onNavigate={() => mobileSidebar.toggle()} />
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import styles from '../../styles/components/navigation/NavigationControls.module.scss';
|
|
2
|
+
import Link from '@docusaurus/Link';
|
|
3
|
+
import {SITE_ROUTES} from '../../routes.js';
|
|
4
|
+
import {translate} from '@docusaurus/Translate';
|
|
5
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
6
|
+
|
|
7
|
+
export default function RecentUpdatesLink({mobile = false, onClick}) {
|
|
8
|
+
const url = useBaseUrl(SITE_ROUTES.updates);
|
|
9
|
+
const label = translate({id: 'docnest.updates.title', message: 'Recent Updates'});
|
|
10
|
+
const link = (
|
|
11
|
+
<Link
|
|
12
|
+
to={url}
|
|
13
|
+
className={mobile ? `menu__link ${styles['menu-link']}` : styles.control}
|
|
14
|
+
aria-label={label}
|
|
15
|
+
title={label}
|
|
16
|
+
onClick={onClick}
|
|
17
|
+
>
|
|
18
|
+
<svg
|
|
19
|
+
width="20"
|
|
20
|
+
height="20"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
fill="none"
|
|
23
|
+
stroke="currentColor"
|
|
24
|
+
strokeWidth="1.7"
|
|
25
|
+
strokeLinecap="round"
|
|
26
|
+
strokeLinejoin="round"
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
>
|
|
29
|
+
<path d="M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7" />
|
|
30
|
+
<path d="M12 7v5l3 2" />
|
|
31
|
+
</svg>
|
|
32
|
+
{mobile && <span>{label}</span>}
|
|
33
|
+
</Link>
|
|
34
|
+
);
|
|
35
|
+
return mobile ? <li className="menu__list-item">{link}</li> : link;
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import styles from '../../styles/components/navigation/NavigationControls.module.scss';
|
|
2
|
+
import {useWindowSize} from '@docusaurus/theme-common';
|
|
3
|
+
import {useNavbarMobileSidebar} from '@docusaurus/theme-common/internal';
|
|
4
|
+
import {useLocation} from '@docusaurus/router';
|
|
5
|
+
import {usePluginData} from '@docusaurus/useGlobalData';
|
|
6
|
+
import {useSidebarVisibility} from '../../providers/SidebarVisibility.jsx';
|
|
7
|
+
import {SITE_ROUTES, isSameRoute, normalizePath} from '../../routes.js';
|
|
8
|
+
import {translate} from '@docusaurus/Translate';
|
|
9
|
+
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
10
|
+
|
|
11
|
+
export default function SidebarToggle({mobile = false}) {
|
|
12
|
+
const {collapsed, setCollapsed} = useSidebarVisibility();
|
|
13
|
+
const mobileSidebar = useNavbarMobileSidebar();
|
|
14
|
+
const isMobile = useWindowSize() === 'mobile';
|
|
15
|
+
const {pathname} = useLocation();
|
|
16
|
+
const {paths} = usePluginData('library-navigation');
|
|
17
|
+
const hasSidebar = paths.includes(normalizePath(pathname));
|
|
18
|
+
const updatesUrl = useBaseUrl(SITE_ROUTES.updates);
|
|
19
|
+
const hasUpdates = isSameRoute(pathname, updatesUrl);
|
|
20
|
+
if (mobile || (!hasSidebar && !hasUpdates && !isMobile)) return null;
|
|
21
|
+
const expanded = isMobile ? mobileSidebar.shown : !collapsed;
|
|
22
|
+
const label = expanded
|
|
23
|
+
? translate({id: 'docnest.navigation.collapse', message: 'Collapse navigation'})
|
|
24
|
+
: translate({id: 'docnest.navigation.expand', message: 'Expand navigation'});
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
className={`library-sidebar-toggle clean-btn ${styles.control} ${styles['sidebar-toggle']}`}
|
|
30
|
+
aria-label={label}
|
|
31
|
+
title={label}
|
|
32
|
+
aria-expanded={expanded}
|
|
33
|
+
aria-controls={isMobile ? undefined : 'doc-library-navigation'}
|
|
34
|
+
onClick={() => (isMobile ? mobileSidebar.toggle() : setCollapsed((value) => !value))}
|
|
35
|
+
>
|
|
36
|
+
<svg
|
|
37
|
+
width="16"
|
|
38
|
+
height="16"
|
|
39
|
+
viewBox="0 0 24 24"
|
|
40
|
+
fill="none"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
>
|
|
43
|
+
<rect
|
|
44
|
+
x="3"
|
|
45
|
+
y="4"
|
|
46
|
+
width="18"
|
|
47
|
+
height="16"
|
|
48
|
+
rx="1.5"
|
|
49
|
+
stroke="currentColor"
|
|
50
|
+
strokeWidth="1.7"
|
|
51
|
+
/>
|
|
52
|
+
<path
|
|
53
|
+
d="M9 4v16"
|
|
54
|
+
stroke="currentColor"
|
|
55
|
+
strokeWidth="1.7"
|
|
56
|
+
/>
|
|
57
|
+
</svg>
|
|
58
|
+
</button>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
2
|
+
|
|
3
|
+
export default function DocumentDate({value}) {
|
|
4
|
+
const {
|
|
5
|
+
i18n: {currentLocale},
|
|
6
|
+
} = useDocusaurusContext();
|
|
7
|
+
const dateFormat = new Intl.DateTimeFormat(currentLocale, {
|
|
8
|
+
year: 'numeric',
|
|
9
|
+
month: 'short',
|
|
10
|
+
day: 'numeric',
|
|
11
|
+
timeZone: 'UTC',
|
|
12
|
+
});
|
|
13
|
+
const date = value ? new Date(`${value}T00:00:00Z`) : null;
|
|
14
|
+
if (!date || Number.isNaN(date.getTime())) return '—';
|
|
15
|
+
const tooltip = `${date.getUTCMonth() + 1}.${date.getUTCDate()}, ${date.getUTCFullYear()}`;
|
|
16
|
+
return (
|
|
17
|
+
<time
|
|
18
|
+
dateTime={value}
|
|
19
|
+
title={tooltip}
|
|
20
|
+
lang={currentLocale}
|
|
21
|
+
>
|
|
22
|
+
{dateFormat.format(date)}
|
|
23
|
+
</time>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styles from '../../styles/components/ui/FilterChip.module.scss';
|
|
2
|
+
|
|
3
|
+
export default function FilterChip({active, onClick, children}) {
|
|
4
|
+
return (
|
|
5
|
+
<button
|
|
6
|
+
type="button"
|
|
7
|
+
className={styles.chip}
|
|
8
|
+
aria-pressed={active}
|
|
9
|
+
onClick={onClick}
|
|
10
|
+
>
|
|
11
|
+
{children}
|
|
12
|
+
</button>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import styles from '../../styles/components/ui/TopicBadge.module.scss';
|
|
3
|
+
|
|
4
|
+
export default function TopicBadge({children, tone = 0, title, className}) {
|
|
5
|
+
return (
|
|
6
|
+
<span
|
|
7
|
+
className={clsx(styles.badge, className)}
|
|
8
|
+
data-tone={tone}
|
|
9
|
+
title={title}
|
|
10
|
+
>
|
|
11
|
+
{children}
|
|
12
|
+
</span>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
|
|
2
|
+
import {useHistory, useLocation} from '@docusaurus/router';
|
|
3
|
+
import {usePluginData} from '@docusaurus/useGlobalData';
|
|
4
|
+
import {directoryDocuments} from '../logic/document-list.js';
|
|
5
|
+
import {pagination, viewportPageSize} from '../logic/pagination.js';
|
|
6
|
+
|
|
7
|
+
export default function useDocumentTable(directory) {
|
|
8
|
+
const {documentEntries} = usePluginData('library-navigation');
|
|
9
|
+
const {pathname, search, hash} = useLocation();
|
|
10
|
+
const history = useHistory();
|
|
11
|
+
const documents = useMemo(
|
|
12
|
+
() => directoryDocuments(documentEntries, directory, pathname),
|
|
13
|
+
[documentEntries, directory, pathname],
|
|
14
|
+
);
|
|
15
|
+
const tableAreaRef = useRef(null);
|
|
16
|
+
const headRef = useRef(null);
|
|
17
|
+
const firstRowRef = useRef(null);
|
|
18
|
+
const [pageSize, setPageSize] = useState(1);
|
|
19
|
+
const [measured, setMeasured] = useState(false);
|
|
20
|
+
const requestedPage = new URLSearchParams(search).get('page') || '1';
|
|
21
|
+
const {page, pages, start, end, numbers} = pagination(documents.length, pageSize, requestedPage);
|
|
22
|
+
|
|
23
|
+
const pageUrl = useCallback(
|
|
24
|
+
(number) => {
|
|
25
|
+
const params = new URLSearchParams(search);
|
|
26
|
+
if (number === 1) params.delete('page');
|
|
27
|
+
else params.set('page', String(number));
|
|
28
|
+
const query = params.toString();
|
|
29
|
+
return `${pathname}${query ? `?${query}` : ''}${hash}`;
|
|
30
|
+
},
|
|
31
|
+
[pathname, search, hash],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const area = tableAreaRef.current;
|
|
36
|
+
function measure() {
|
|
37
|
+
const rowHeight = firstRowRef.current?.getBoundingClientRect().height || 44;
|
|
38
|
+
setPageSize(
|
|
39
|
+
viewportPageSize(
|
|
40
|
+
area.clientHeight,
|
|
41
|
+
headRef.current?.getBoundingClientRect().height || 0,
|
|
42
|
+
rowHeight,
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
setMeasured(true);
|
|
46
|
+
}
|
|
47
|
+
const observer = new ResizeObserver(measure);
|
|
48
|
+
observer.observe(area);
|
|
49
|
+
if (headRef.current) observer.observe(headRef.current);
|
|
50
|
+
if (firstRowRef.current) observer.observe(firstRowRef.current);
|
|
51
|
+
measure();
|
|
52
|
+
return () => observer.disconnect();
|
|
53
|
+
}, [documents.length, page]);
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (measured && String(page) !== requestedPage) history.replace(pageUrl(page));
|
|
57
|
+
}, [measured, page, requestedPage, pageUrl, history]);
|
|
58
|
+
|
|
59
|
+
return {documents, page, pages, start, end, numbers, pageUrl, tableAreaRef, headRef, firstRowRef};
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {useMemo, useState} from 'react';
|
|
2
|
+
import {usePluginData} from '@docusaurus/useGlobalData';
|
|
3
|
+
import {groupUpdates} from '../logic/update-groups.js';
|
|
4
|
+
|
|
5
|
+
export default function useUpdates() {
|
|
6
|
+
const {entries = []} = usePluginData('recent-updates') || {};
|
|
7
|
+
const [instance, setInstance] = useState('All');
|
|
8
|
+
const [newOnly, setNewOnly] = useState(false);
|
|
9
|
+
const [days, setDays] = useState(30);
|
|
10
|
+
|
|
11
|
+
const instances = useMemo(
|
|
12
|
+
() => ['All', ...Array.from(new Set(entries.map((e) => e.instance)))],
|
|
13
|
+
[entries],
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const groups = useMemo(
|
|
17
|
+
() => groupUpdates(entries, {instance, newOnly, days}, Date.now()),
|
|
18
|
+
[entries, instance, newOnly, days],
|
|
19
|
+
);
|
|
20
|
+
const total = groups.reduce((count, [, items]) => count + items.length, 0);
|
|
21
|
+
|
|
22
|
+
return {instance, setInstance, newOnly, setNewOnly, days, setDays, instances, groups, total};
|
|
23
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {findDocumentByRoute} from './document-list.js';
|
|
2
|
+
import {SITE_ROUTES, isSameRoute} from '../routes.js';
|
|
3
|
+
|
|
4
|
+
export function documentBreadcrumbs(documents, currentPath, categoryLabels = {}) {
|
|
5
|
+
const current = findDocumentByRoute(documents, currentPath);
|
|
6
|
+
if (
|
|
7
|
+
!current ||
|
|
8
|
+
isSameRoute(current.href, SITE_ROUTES.home) ||
|
|
9
|
+
(current.isIndex && !current.directory)
|
|
10
|
+
)
|
|
11
|
+
return null;
|
|
12
|
+
const items = [];
|
|
13
|
+
const segments = current.directory.split('/').filter(Boolean);
|
|
14
|
+
segments.forEach((label, index) => {
|
|
15
|
+
const directory = segments.slice(0, index + 1).join('/');
|
|
16
|
+
const overview = documents.find((doc) => doc.isIndex && doc.directory === directory);
|
|
17
|
+
items.push({
|
|
18
|
+
label: overview?.title || categoryLabels[directory] || label,
|
|
19
|
+
href: overview?.href,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
if (!current.isIndex) items.push({label: current.title, href: current.href});
|
|
23
|
+
return items;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Shared frontmatter policy for build-time document collectors.
|
|
2
|
+
function toDay(value) {
|
|
3
|
+
if (value instanceof Date) {
|
|
4
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString().slice(0, 10);
|
|
5
|
+
}
|
|
6
|
+
if (typeof value !== 'string') return null;
|
|
7
|
+
|
|
8
|
+
// Preserve the written date of a string; do not shift it through local time.
|
|
9
|
+
const day = value.match(/^(\d{4}-\d{2}-\d{2})/)?.[1];
|
|
10
|
+
if (!day) return null;
|
|
11
|
+
const date = new Date(`${day}T00:00:00Z`);
|
|
12
|
+
return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === day ? day : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function documentDates(frontMatter) {
|
|
16
|
+
const created = toDay(frontMatter?.created_at) || toDay(frontMatter?.date);
|
|
17
|
+
const updated = toDay(frontMatter?.updated_at) || toDay(frontMatter?.updated) || created;
|
|
18
|
+
return {created, updated};
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {isSameRoute} from '../routes.js';
|
|
2
|
+
|
|
3
|
+
export function findDocumentByRoute(documents, pathname) {
|
|
4
|
+
return documents.find((doc) => isSameRoute(doc.href, pathname));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function directoryDocuments(documents, directory, currentPath) {
|
|
8
|
+
return documents
|
|
9
|
+
.filter(
|
|
10
|
+
(doc) =>
|
|
11
|
+
(!directory || doc.directory === directory || doc.directory.startsWith(`${directory}/`)) &&
|
|
12
|
+
!isSameRoute(doc.href, currentPath),
|
|
13
|
+
)
|
|
14
|
+
.sort((a, b) => a.title.localeCompare(b.title, 'ko', {numeric: true}));
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Interpret paths relative to the starter's document root.
|
|
2
|
+
export function documentLocation(source, sourceDirName) {
|
|
3
|
+
const relativeSource =
|
|
4
|
+
sourceDirName === undefined
|
|
5
|
+
? source.replace(/^@site\/documents\//, '')
|
|
6
|
+
: [sourceDirName === '.' ? '' : sourceDirName, source.split('/').at(-1)]
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.join('/');
|
|
9
|
+
const segments = relativeSource.split('/');
|
|
10
|
+
const filename = segments.pop();
|
|
11
|
+
const directory = segments.join('/');
|
|
12
|
+
const isIndex = /^(index|home)\.(md|mdx)$/.test(filename);
|
|
13
|
+
return {
|
|
14
|
+
segments,
|
|
15
|
+
directory,
|
|
16
|
+
isIndex,
|
|
17
|
+
isDocumentCategory: segments.length > 0 && isIndex,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function documentTaxonomy(directory) {
|
|
2
|
+
const parts = directory.split('/').filter(Boolean);
|
|
3
|
+
const category = parts[0] || 'Documents';
|
|
4
|
+
const topic = parts.slice(1).join(' / ') || category;
|
|
5
|
+
const tone = Array.from(directory).reduce(
|
|
6
|
+
(value, char) => (value * 31 + char.charCodeAt(0)) % 6,
|
|
7
|
+
0,
|
|
8
|
+
);
|
|
9
|
+
return {category, topic, tone};
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const MAX_PAGE_SIZE = 30;
|
|
2
|
+
|
|
3
|
+
export function viewportPageSize(availableHeight, headerHeight, rowHeight) {
|
|
4
|
+
return Math.min(
|
|
5
|
+
MAX_PAGE_SIZE,
|
|
6
|
+
Math.max(1, Math.floor((availableHeight - headerHeight) / Math.max(1, rowHeight))),
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function pagination(total, pageSize, requestedPage) {
|
|
11
|
+
const size = Math.min(MAX_PAGE_SIZE, Math.max(1, pageSize));
|
|
12
|
+
const pages = Math.max(1, Math.ceil(total / size));
|
|
13
|
+
const requested = /^\d+$/.test(String(requestedPage)) ? Number(requestedPage) : 1;
|
|
14
|
+
const page = Math.min(pages, Math.max(1, requested));
|
|
15
|
+
const start = (page - 1) * size;
|
|
16
|
+
const first = Math.max(1, Math.min(page - 2, pages - 4));
|
|
17
|
+
return {
|
|
18
|
+
page,
|
|
19
|
+
pages,
|
|
20
|
+
start,
|
|
21
|
+
end: Math.min(total, start + size),
|
|
22
|
+
numbers: Array.from({length: Math.min(5, pages)}, (_, i) => first + i),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function groupUpdates(entries, {instance, newOnly, days}, now) {
|
|
2
|
+
// 기준일을 UTC 자정으로 고정한다 - frontmatter 날짜에 시간이 없어서 시차로 하루가 밀리면 안 된다
|
|
3
|
+
const since = days === 0 ? null : new Date(now - days * 86400000).toISOString().slice(0, 10);
|
|
4
|
+
|
|
5
|
+
const filtered = entries.filter(
|
|
6
|
+
(e) =>
|
|
7
|
+
(instance === 'All' || e.instance === instance) &&
|
|
8
|
+
(!newOnly || e.isNew) &&
|
|
9
|
+
(!since || (e.updated || e.created) >= since),
|
|
10
|
+
);
|
|
11
|
+
const byDay = new Map();
|
|
12
|
+
for (const e of filtered) {
|
|
13
|
+
const day = e.updated || e.created;
|
|
14
|
+
if (!byDay.has(day)) byDay.set(day, []);
|
|
15
|
+
byDay.get(day).push(e);
|
|
16
|
+
}
|
|
17
|
+
return Array.from(byDay.entries());
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {createContext, useContext, useState} from 'react';
|
|
2
|
+
|
|
3
|
+
const SidebarVisibilityContext = createContext(null);
|
|
4
|
+
|
|
5
|
+
export function SidebarVisibilityProvider({children}) {
|
|
6
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
7
|
+
return (
|
|
8
|
+
<SidebarVisibilityContext.Provider value={{collapsed, setCollapsed}}>
|
|
9
|
+
<div
|
|
10
|
+
className="doc-library-app"
|
|
11
|
+
data-sidebar-collapsed={collapsed}
|
|
12
|
+
>
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
</SidebarVisibilityContext.Provider>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const useSidebarVisibility = () => useContext(SidebarVisibilityContext);
|