@umami/shiso 0.55.0 → 1.0.0
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/CHANGELOG.md +39 -0
- package/README.md +9 -49
- package/bin/shiso.mjs +132 -0
- package/docs.schema.json +896 -0
- package/mdx.config.ts +143 -0
- package/package.json +74 -83
- package/scripts/check-package.mjs +54 -0
- package/scripts/generate-icon-registry.mjs +196 -0
- package/scripts/generate-last-modified.mjs +128 -0
- package/scripts/generate-search-index.mjs +298 -0
- package/scripts/lib/mdast.mjs +23 -0
- package/scripts/lib/slug.mjs +21 -0
- package/scripts/load-docs-config.mjs +244 -0
- package/scripts/prerender.mjs +194 -0
- package/scripts/validate-config.mjs +104 -0
- package/scripts/vite-docs-config.mjs +60 -0
- package/src/App.tsx +38 -0
- package/src/components/Banner.tsx +69 -0
- package/src/components/CodeBlock.tsx +46 -0
- package/src/components/ConfiguredIcon.tsx +15 -0
- package/src/components/ContextualMenu.tsx +93 -0
- package/src/components/DocContent.tsx +105 -0
- package/src/components/Docs.tsx +134 -0
- package/src/components/Footer.tsx +81 -0
- package/src/components/Header.tsx +82 -0
- package/src/components/LanguageSwitcher.tsx +59 -0
- package/src/components/Layout.tsx +24 -0
- package/src/components/PageLinks.tsx +71 -0
- package/src/components/Search.tsx +217 -0
- package/src/components/SideNav.tsx +347 -0
- package/src/components/SocialIcon.tsx +88 -0
- package/src/components/ThemeToggle.tsx +34 -0
- package/src/components/TopNav.tsx +127 -0
- package/src/components/VersionSwitcher.tsx +60 -0
- package/src/components/docs/Accordion.tsx +68 -0
- package/src/components/docs/Badge.tsx +171 -0
- package/src/components/docs/Callout.tsx +73 -0
- package/src/components/docs/Card.tsx +158 -0
- package/src/components/docs/CodeGroup.tsx +73 -0
- package/src/components/docs/Columns.tsx +20 -0
- package/src/components/docs/Expandable.tsx +28 -0
- package/src/components/docs/Frame.tsx +56 -0
- package/src/components/docs/Icon.tsx +30 -0
- package/src/components/docs/ParamField.tsx +45 -0
- package/src/components/docs/PropertiesTable.tsx +84 -0
- package/src/components/docs/ResponseField.tsx +36 -0
- package/src/components/docs/Steps.tsx +47 -0
- package/src/components/docs/Tabs.tsx +116 -0
- package/src/components/docs/Tooltip.tsx +21 -0
- package/src/components/docs/index.ts +15 -0
- package/src/components/docs/styles.ts +82 -0
- package/src/components/docs/utils.ts +118 -0
- package/src/components/icons/index.ts +17 -0
- package/src/components/ui/accordion.tsx +69 -0
- package/src/components/ui/alert.tsx +69 -0
- package/src/components/ui/badge.tsx +49 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +88 -0
- package/src/components/ui/collapsible.tsx +15 -0
- package/src/components/ui/command.tsx +173 -0
- package/src/components/ui/dialog.tsx +137 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/scroll-area.tsx +71 -0
- package/src/components/ui/sheet.tsx +124 -0
- package/src/components/ui/tabs.tsx +73 -0
- package/src/components/ui/tooltip.tsx +52 -0
- package/src/declarations.d.ts +9 -0
- package/src/entry-client.tsx +17 -0
- package/src/entry-server.tsx +89 -0
- package/src/generated/last-modified.ts +2 -0
- package/src/lib/content.ts +44 -0
- package/src/lib/docs-config.ts +986 -0
- package/src/lib/head.ts +231 -0
- package/src/lib/icon-registry.generated.ts +4 -0
- package/src/lib/icons.ts +29 -0
- package/src/lib/inline-markdown.tsx +86 -0
- package/src/lib/locale.ts +39 -0
- package/src/lib/mdast.ts +56 -0
- package/src/lib/paths.ts +86 -0
- package/src/lib/remark-toc.ts +71 -0
- package/src/lib/search/config.ts +43 -0
- package/src/lib/search/provider.ts +85 -0
- package/src/lib/search/providers/local.ts +15 -0
- package/src/lib/search-index.generated.ts +4 -0
- package/src/lib/search.ts +128 -0
- package/src/lib/site-config.ts +117 -0
- package/src/lib/site-model.ts +221 -0
- package/src/lib/slug.ts +38 -0
- package/src/lib/types.ts +515 -0
- package/src/lib/utils.ts +6 -0
- package/src/pages/DocPage.tsx +33 -0
- package/src/styles/global.css +268 -0
- package/src/styles/tokens.css +114 -0
- package/types/client.d.ts +3 -0
- package/types/search.d.ts +27 -0
- package/vite.config.ts +342 -0
- package/LICENSE +0 -21
- package/dist/index.css +0 -189
- package/dist/index.d.ts +0 -57
- package/dist/index.js +0 -464
- package/dist/index.mjs +0 -437
- package/server/index.d.ts +0 -30
- package/server/index.js +0 -189
- package/styles.css +0 -4766
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
function TooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {
|
|
6
|
+
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function Tooltip({ ...props }: TooltipPrimitive.Root.Props) {
|
|
10
|
+
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {
|
|
14
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function TooltipContent({
|
|
18
|
+
className,
|
|
19
|
+
side = 'top',
|
|
20
|
+
sideOffset = 4,
|
|
21
|
+
align = 'center',
|
|
22
|
+
alignOffset = 0,
|
|
23
|
+
children,
|
|
24
|
+
...props
|
|
25
|
+
}: TooltipPrimitive.Popup.Props &
|
|
26
|
+
Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
|
|
27
|
+
return (
|
|
28
|
+
<TooltipPrimitive.Portal>
|
|
29
|
+
<TooltipPrimitive.Positioner
|
|
30
|
+
align={align}
|
|
31
|
+
alignOffset={alignOffset}
|
|
32
|
+
side={side}
|
|
33
|
+
sideOffset={sideOffset}
|
|
34
|
+
className="isolate z-50"
|
|
35
|
+
>
|
|
36
|
+
<TooltipPrimitive.Popup
|
|
37
|
+
data-slot="tooltip-content"
|
|
38
|
+
className={cn(
|
|
39
|
+
'z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-sm text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" />
|
|
46
|
+
</TooltipPrimitive.Popup>
|
|
47
|
+
</TooltipPrimitive.Positioner>
|
|
48
|
+
</TooltipPrimitive.Portal>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { hydrateRoot } from 'react-dom/client';
|
|
2
|
+
import { BrowserRouter } from 'react-router';
|
|
3
|
+
import { App } from '@/App';
|
|
4
|
+
import { BASE_URL } from '@/lib/paths';
|
|
5
|
+
|
|
6
|
+
export function mount(element: HTMLElement | null = document.getElementById('root')) {
|
|
7
|
+
if (!element) {
|
|
8
|
+
throw new Error('Shiso could not find the root element.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return hydrateRoot(
|
|
12
|
+
element,
|
|
13
|
+
<BrowserRouter basename={BASE_URL || undefined}>
|
|
14
|
+
<App />
|
|
15
|
+
</BrowserRouter>,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { renderToString } from 'react-dom/server';
|
|
2
|
+
import { StaticRouter } from 'react-router';
|
|
3
|
+
import { App } from '@/App';
|
|
4
|
+
import { getDocModule, getLastModified } from '@/lib/content';
|
|
5
|
+
import { getScopeForPage } from '@/lib/docs-config';
|
|
6
|
+
import { buildHead, renderHeadToString } from '@/lib/head';
|
|
7
|
+
import { BASE_URL, toAbsoluteUrl } from '@/lib/paths';
|
|
8
|
+
import {
|
|
9
|
+
docsHomeUrl,
|
|
10
|
+
docsSite,
|
|
11
|
+
getLocaleByPathname,
|
|
12
|
+
getRedirects,
|
|
13
|
+
getSeo,
|
|
14
|
+
siteName,
|
|
15
|
+
} from '@/lib/site-config';
|
|
16
|
+
|
|
17
|
+
export interface RenderResult {
|
|
18
|
+
html: string;
|
|
19
|
+
head: string;
|
|
20
|
+
/** Attributes for the document element: language and text direction. */
|
|
21
|
+
htmlAttrs: { lang: string; dir: 'ltr' | 'rtl' };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SitemapEntry {
|
|
25
|
+
url: string;
|
|
26
|
+
lastmod?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Base-relative routes for every scope. The prerenderer prepends the deploy base itself. */
|
|
30
|
+
export function getRoutes(): string[] {
|
|
31
|
+
return docsSite.pages.map(page => page.url);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Redirect rules with exact-match sources, for static redirect pages. */
|
|
35
|
+
export { getRedirects };
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Source file for every routed page, so the prerenderer can publish raw
|
|
39
|
+
* markdown next to each HTML page (used by the contextual menu's copy/view
|
|
40
|
+
* options and by AI tools). `filePath` is a module key like
|
|
41
|
+
* "/content/docs/index.mdx", resolved against the project root.
|
|
42
|
+
*/
|
|
43
|
+
export function getMarkdownPages(): { route: string; filePath: string }[] {
|
|
44
|
+
return docsSite.pages.map(page => ({ route: page.url, filePath: page.filePath }));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Absolute URLs for the sitemap, honoring `seo.indexing` and per-page
|
|
49
|
+
* noindex. Empty when `$shiso.siteUrl` is not configured, since a sitemap
|
|
50
|
+
* of relative URLs is invalid.
|
|
51
|
+
*/
|
|
52
|
+
export function getSitemapEntries(): SitemapEntry[] {
|
|
53
|
+
const { indexing } = getSeo();
|
|
54
|
+
const entries: SitemapEntry[] = [];
|
|
55
|
+
|
|
56
|
+
for (const page of docsSite.pages) {
|
|
57
|
+
// Hidden pages and pages of hidden scopes (versions/languages) stay out
|
|
58
|
+
// of the sitemap unless `seo.indexing: "all"` opts them in.
|
|
59
|
+
if ((page.hidden || getScopeForPage(docsSite, page).hidden) && indexing !== 'all') {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (getDocModule(page.filePath)?.frontmatter?.noindex === true) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const url = toAbsoluteUrl(page.url);
|
|
68
|
+
|
|
69
|
+
if (url) {
|
|
70
|
+
entries.push({ url, lastmod: getLastModified(page.filePath) });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return entries;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function render(url: string): RenderResult {
|
|
78
|
+
// basename must match the client's BrowserRouter, or every <Link> in the
|
|
79
|
+
// prerendered HTML would omit the deploy base and mismatch on hydration.
|
|
80
|
+
const html = renderToString(
|
|
81
|
+
<StaticRouter basename={BASE_URL || undefined} location={`${BASE_URL}${url}`}>
|
|
82
|
+
<App />
|
|
83
|
+
</StaticRouter>,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return { html, head: renderHeadToString(buildHead(url)), htmlAttrs: getLocaleByPathname(url) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { docsHomeUrl, siteName };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LAST_MODIFIED } from '@/generated/last-modified';
|
|
2
|
+
import { CONTENT_DIR } from '@/lib/paths';
|
|
3
|
+
import type { DocModule } from '@/lib/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Eagerly imports every content file at build time. Each module exports:
|
|
7
|
+
* - default: the compiled MDX component
|
|
8
|
+
* - frontmatter: parsed YAML frontmatter
|
|
9
|
+
* - toc: heading anchors injected by the remark-toc plugin
|
|
10
|
+
*
|
|
11
|
+
* Eager loading keeps server prerendering and client hydration in sync
|
|
12
|
+
* without Suspense, at the cost of bundling all pages together.
|
|
13
|
+
*
|
|
14
|
+
* The glob pattern must be a literal for Vite to statically analyze it, so it
|
|
15
|
+
* covers all of `content/` and the configured `$shiso.contentDir` is applied at
|
|
16
|
+
* lookup time instead. That also lets later versioned/localized content roots
|
|
17
|
+
* (`content/v2`, `content/es`) work without touching this glob.
|
|
18
|
+
*/
|
|
19
|
+
export const docModules = import.meta.glob('/content/**/*.{md,mdx}', {
|
|
20
|
+
eager: true,
|
|
21
|
+
}) as Record<string, DocModule>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a docs.json page reference (e.g. "components/tabs") to a module
|
|
25
|
+
* key (e.g. "/content/docs/components/tabs.mdx"). Returns undefined when the
|
|
26
|
+
* file does not exist, which makes config normalization fail at startup/build.
|
|
27
|
+
*/
|
|
28
|
+
export function resolveDocFile(fileSlug: string, contentDir = CONTENT_DIR): string | undefined {
|
|
29
|
+
const candidates = [`/${contentDir}/${fileSlug}.mdx`, `/${contentDir}/${fileSlug}.md`];
|
|
30
|
+
return candidates.find(candidate => candidate in docModules);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getDocModule(filePath: string): DocModule | undefined {
|
|
34
|
+
return docModules[filePath];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Last-modified date of a content file, captured from git history at build
|
|
39
|
+
* time (see scripts/generate-last-modified.mjs). ISO 8601, or undefined for
|
|
40
|
+
* files outside the generated map.
|
|
41
|
+
*/
|
|
42
|
+
export function getLastModified(filePath: string): string | undefined {
|
|
43
|
+
return LAST_MODIFIED[filePath];
|
|
44
|
+
}
|