-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs):component & example source (#16)
- Loading branch information
Showing
19 changed files
with
304 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
--- | ||
import { Code } from "astro/components" | ||
import type { HTMLAttributes } from "astro/types" | ||
import type { BuiltinLanguage } from "shiki" | ||
import CodeWrapper from "./code-wrapper" | ||
interface Props extends HTMLAttributes<"div"> { | ||
lang?: "tsx" | "vue" | "ts" | "json" | ||
src?: string | ||
lang?: BuiltinLanguage | ||
className?: string | ||
collapsible?: boolean | ||
src: string | ||
copy?: boolean | ||
} | ||
const { src, lang, className, collapsible, ...props } = Astro.props | ||
const { src, lang, className, ...props } = Astro.props | ||
--- | ||
|
||
<CodeWrapper | ||
client:visible | ||
src={src} | ||
collapsible={!!collapsible} | ||
className={className} | ||
{...props} | ||
> | ||
<Code lang={lang || "plaintext"} theme="vesper" code={src} /> | ||
<CodeWrapper client:visible src={src} className={className} {...props}> | ||
<Code lang={lang || "plaintext"} theme="vesper" code={src || "Not found"} /> | ||
</CodeWrapper> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
--- | ||
import fs from "node:fs" | ||
import { resolvePath } from "mlly" | ||
import { frameworks } from "@/atoms/framework" | ||
import { getComponentSource } from "@/lib/source" | ||
import CodeWrapper from "./code-wrapper/index.astro" | ||
export interface Props { | ||
component: string | ||
} | ||
const { component } = Astro.props | ||
const filePath = await resolvePath(`@ui/react/${component}`, { | ||
conditions: ["source"], | ||
}) | ||
const source = fs.readFileSync(filePath, "utf-8") | ||
const frameworkSources = await Promise.all( | ||
frameworks.map((framework) => getComponentSource(framework, component)) | ||
) | ||
--- | ||
|
||
<CodeWrapper lang="tsx" src={source} collapsible /> | ||
{ | ||
frameworks.map((framework, index) => ( | ||
<div data-framework={framework}> | ||
{frameworkSources[index]?.length ? ( | ||
frameworkSources[index]?.map((src) => ( | ||
<div data-framework={framework}> | ||
<p class="mb-2">{src.filename}</p> | ||
<CodeWrapper | ||
className="mt-0" | ||
lang={src.lang} | ||
src={src.source} | ||
collapsible | ||
/> | ||
</div> | ||
)) | ||
) : ( | ||
<CodeWrapper src={"Not Found"} /> | ||
)} | ||
</div> | ||
)) | ||
} |
Oops, something went wrong.