mirror of
https://github.com/HoshinoSuzumi/rayine-ui.git
synced 2025-04-10 04:58:51 +08:00
🚧 docs wip
This commit is contained in:
parent
64abbba614
commit
ab9fe5f242
@ -4,6 +4,8 @@ import FileTypeTypescript from "./icon/VscodeIconsFileTypeTypescriptOfficial.vue
|
|||||||
import FileTypeJavascript from "./icon/VscodeIconsFileTypeJsOfficial.vue"
|
import FileTypeJavascript from "./icon/VscodeIconsFileTypeJsOfficial.vue"
|
||||||
import TablerTerminal from "./icon/TablerTerminal.vue";
|
import TablerTerminal from "./icon/TablerTerminal.vue";
|
||||||
|
|
||||||
|
const hightlighter = useShikiHighlighter();
|
||||||
|
|
||||||
const slots = defineSlots<{
|
const slots = defineSlots<{
|
||||||
default?: () => VNode[];
|
default?: () => VNode[];
|
||||||
code?: () => VNode[];
|
code?: () => VNode[];
|
||||||
@ -43,7 +45,7 @@ const codeSlotContent = computed(() => {
|
|||||||
return '';
|
return '';
|
||||||
})
|
})
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
filename: {
|
filename: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
@ -52,6 +54,35 @@ defineProps({
|
|||||||
type: String as PropType<keyof typeof IconComponents>,
|
type: String as PropType<keyof typeof IconComponents>,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
code: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { data: ast } = await useAsyncData(`${'name'}-ast-${JSON.stringify({ slots: props.slots, code: props.code })}`, async () => {
|
||||||
|
let formatted = ''
|
||||||
|
try {
|
||||||
|
// @ts-ignore
|
||||||
|
formatted = await $prettier.format(code.value, {
|
||||||
|
trailingComma: 'none',
|
||||||
|
semi: false,
|
||||||
|
singleQuote: true
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
formatted = props.code
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseMarkdown(formatted, {
|
||||||
|
highlight: {
|
||||||
|
highlighter,
|
||||||
|
theme: {
|
||||||
|
light: 'material-theme-lighter',
|
||||||
|
default: 'material-theme',
|
||||||
|
dark: 'material-theme-palenight'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -72,7 +103,8 @@ defineProps({
|
|||||||
|
|
||||||
<template v-if="slots.code">
|
<template v-if="slots.code">
|
||||||
<div class="p-4 overflow-auto">
|
<div class="p-4 overflow-auto">
|
||||||
<LazyShiki class="text-sm" :lang="lang" :code="codeSlotContent" />
|
<!-- <LazyShiki class="text-sm" :lang="lang" :code="codeSlotContent" /> -->
|
||||||
|
<ContentRenderer :value="ast" v-if="ast"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
32
docs/composables/useShikiHighlighter.ts
Normal file
32
docs/composables/useShikiHighlighter.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { createShikiHighlighter } from "@nuxtjs/mdc/runtime/highlighter/shiki";
|
||||||
|
import MaterialTheme from "shiki/themes/material-theme.mjs";
|
||||||
|
import MaterialThemeLighter from "shiki/themes/material-theme-lighter.mjs";
|
||||||
|
import MaterialThemePalenight from "shiki/themes/material-theme-palenight.mjs";
|
||||||
|
import HtmlLang from "shiki/langs/html.mjs";
|
||||||
|
import MdcLang from "shiki/langs/mdc.mjs";
|
||||||
|
import VueLang from "shiki/langs/vue.mjs";
|
||||||
|
import YamlLang from "shiki/langs/yaml.mjs";
|
||||||
|
import PostcssLang from "shiki/langs/postcss.mjs";
|
||||||
|
import type { Highlighter } from "@nuxtjs/mdc";
|
||||||
|
|
||||||
|
let highlighter: Highlighter;
|
||||||
|
export const useShikiHighlighter = () => {
|
||||||
|
if (!highlighter) {
|
||||||
|
highlighter = createShikiHighlighter({
|
||||||
|
bundledThemes: {
|
||||||
|
"material-theme": MaterialTheme,
|
||||||
|
"material-theme-lighter": MaterialThemeLighter,
|
||||||
|
"material-theme-palenight": MaterialThemePalenight,
|
||||||
|
},
|
||||||
|
bundledLangs: {
|
||||||
|
html: HtmlLang,
|
||||||
|
mdc: MdcLang,
|
||||||
|
vue: VueLang,
|
||||||
|
yml: YamlLang,
|
||||||
|
postcss: PostcssLang,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return highlighter;
|
||||||
|
};
|
3
docs/content/1.installation/1.index.md
Normal file
3
docs/content/1.installation/1.index.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# index
|
||||||
|
|
||||||
|
index docs/content/1.installation/1.index.md test
|
25
docs/content/2.components/button.md
Normal file
25
docs/content/2.components/button.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Button
|
||||||
|
|
||||||
|
Buttons are used to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```html
|
||||||
|
<RayButton>Click me</RayButton>
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
::DocExampleBlock
|
||||||
|
test
|
||||||
|
|
||||||
|
#code
|
||||||
|
console.log('Hello Rayine')
|
||||||
|
::
|
||||||
|
|
||||||
|
::RayButton
|
||||||
|
---
|
||||||
|
color: red
|
||||||
|
---
|
||||||
|
Hello Rayine
|
||||||
|
::
|
18
docs/content/index.md
Normal file
18
docs/content/index.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
::DocContentBlock
|
||||||
|
---
|
||||||
|
title: Button
|
||||||
|
accent-title: true
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
::DocContentBlock
|
||||||
|
---
|
||||||
|
title: Variants
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
|
::DocExampleBlock
|
||||||
|
---
|
||||||
|
lang: vue
|
||||||
|
---
|
||||||
|
::
|
@ -4,13 +4,15 @@ import defaultTheme from "tailwindcss/defaultTheme";
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: "2024-04-03",
|
compatibilityDate: "2024-04-03",
|
||||||
modules: ["@nuxt/fonts", module],
|
modules: ["@nuxt/content", "@nuxt/fonts", module],
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
rayui: {
|
rayui: {
|
||||||
|
globalComponents: true,
|
||||||
safeColors: ["amber", "emerald", "red", "sky", "violet", "cyan"],
|
safeColors: ["amber", "emerald", "red", "sky", "violet", "cyan"],
|
||||||
},
|
},
|
||||||
tailwindcss: {
|
tailwindcss: {
|
||||||
config: {
|
config: {
|
||||||
|
darkMode: "media",
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
fontFamily: {
|
fontFamily: {
|
||||||
@ -20,4 +22,18 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
path: "~/components",
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
content: {
|
||||||
|
highlight: {
|
||||||
|
langs: ["postcss", "mdc", "html", "vue", "ts", "js"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typescript: {
|
||||||
|
includeWorkspace: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,10 @@
|
|||||||
"postinstall": "nuxt prepare"
|
"postinstall": "nuxt prepare"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@nuxt/content": "^2.13.4",
|
||||||
|
"@nuxtjs/mdc": "^0.9.2",
|
||||||
"nuxt": "^3.14.159",
|
"nuxt": "^3.14.159",
|
||||||
|
"nuxt-shiki": "^0.3.0",
|
||||||
"rayine-ui": "workspace:rayine-ui",
|
"rayine-ui": "workspace:rayine-ui",
|
||||||
"vue": "latest",
|
"vue": "latest",
|
||||||
"vue-router": "latest"
|
"vue-router": "latest"
|
||||||
|
35
docs/pages/[...slug].vue
Normal file
35
docs/pages/[...slug].vue
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
|
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
|
||||||
|
|
||||||
|
if (!page.value) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: 404, statusMessage: 'Page not found', fatal: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<ContentRenderer v-if="page.body" :value="page" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.doc-body {
|
||||||
|
@apply prose dark:prose-invert max-w-none;
|
||||||
|
|
||||||
|
hr {
|
||||||
|
@apply my-8 border-t border-neutral-200 dark:border-neutral-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
@apply text-3xl text-primary font-bold my-4 first:mt-0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > p {
|
||||||
|
@apply text-base text-neutral-900 dark:text-neutral-100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
1454
pnpm-lock.yaml
generated
1454
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": "./.nuxt/tsconfig.json",
|
|
||||||
|
"extends": [
|
||||||
|
"./.nuxt/tsconfig.json",
|
||||||
|
"./docs/.nuxt/tsconfig.json",
|
||||||
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist",
|
"dist",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
|
Loading…
Reference in New Issue
Block a user