Initial api docs in vitepress
This commit is contained in:
parent
4f870c63a6
commit
fdb8ffcf2d
|
@ -15,7 +15,12 @@ export default defineConfig({
|
||||||
text: 'API',
|
text: 'API',
|
||||||
activeMatch: `^/api/`,
|
activeMatch: `^/api/`,
|
||||||
items: [
|
items: [
|
||||||
|
{ text: '@schlechtenburg/standalone', link: '/api/@schlechtenburg/standalone' },
|
||||||
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' },
|
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' },
|
||||||
|
{ text: '@schlechtenburg/layout', link: '/api/@schlechtenburg/layout' },
|
||||||
|
{ text: '@schlechtenburg/heading', link: '/api/@schlechtenburg/heading' },
|
||||||
|
{ text: '@schlechtenburg/paragraph', link: '/api/@schlechtenburg/paragraph' },
|
||||||
|
{ text: '@schlechtenburg/image', link: '/api/@schlechtenburg/image' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -34,7 +39,12 @@ export default defineConfig({
|
||||||
{
|
{
|
||||||
text: 'API',
|
text: 'API',
|
||||||
children: [
|
children: [
|
||||||
{ text: 'Core', link: '/api/core' },
|
{ text: '@schlechtenburg/standalone', link: '/api/@schlechtenburg/standalone' },
|
||||||
|
{ text: '@schlechtenburg/core', link: '/api/@schlechtenburg/core' },
|
||||||
|
{ text: '@schlechtenburg/layout', link: '/api/@schlechtenburg/layout' },
|
||||||
|
{ text: '@schlechtenburg/heading', link: '/api/@schlechtenburg/heading' },
|
||||||
|
{ text: '@schlechtenburg/paragraph', link: '/api/@schlechtenburg/paragraph' },
|
||||||
|
{ text: '@schlechtenburg/image', link: '/api/@schlechtenburg/image' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/core.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/core.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/core" />
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/heading.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/heading.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/heading" />
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/image.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/image.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/image" />
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/layout.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/layout.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/layout" />
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/paragraph.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/paragraph.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/paragraph" />
|
||||||
|
|
6
packages/docs/lib/api/@schlechtenburg/standalone.md
Normal file
6
packages/docs/lib/api/@schlechtenburg/standalone.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<script setup>
|
||||||
|
import Package from '../Package'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Package name="@schlechtenburg/standalone" />
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { ComponentDoc } from 'vue-docgen-api';
|
import { ComponentDoc } from 'vue-docgen-api';
|
||||||
import { DeclarationReflection } from 'typedoc';
|
import { DeclarationReflection } from 'typedoc';
|
||||||
|
|
||||||
import { getByName } from '../docs';
|
import { getByName } from '../docs';
|
||||||
import ComponentDocs from '../ComponentDocs';
|
import { getShortPackageName } from './package';
|
||||||
import TsDocs from '../TsDocs';
|
import ComponentDocs from './ComponentDocs';
|
||||||
|
import TSDocs from './TSDocs';
|
||||||
|
|
||||||
import './Package.scss';
|
import './Package.scss';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Package',
|
name: 'Package',
|
||||||
|
|
||||||
setup() {
|
props: {
|
||||||
const route = useRoute();
|
name: {
|
||||||
const packageName = route.params.package;
|
type: String,
|
||||||
const docs = getByName(Array.isArray(packageName) ? packageName[0] : packageName);
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
setup(props) {
|
||||||
|
const packageName = props.name;
|
||||||
|
const docs = getByName(getShortPackageName(Array.isArray(packageName) ? packageName[0] : packageName));
|
||||||
if (!docs) {
|
if (!docs) {
|
||||||
return () => <div>Unknown package name {packageName}</div>;
|
return () => <div>Unknown package name {packageName}</div>;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +38,7 @@ export default defineComponent({
|
||||||
return <ComponentDocs docs={componentDocs}></ComponentDocs>
|
return <ComponentDocs docs={componentDocs}></ComponentDocs>
|
||||||
}
|
}
|
||||||
|
|
||||||
return <TsDocs docs={child}></TsDocs>
|
return <TSDocs docs={child}></TSDocs>
|
||||||
})}
|
})}
|
||||||
</main>;
|
</main>;
|
||||||
},
|
},
|
|
@ -7,12 +7,12 @@ import {
|
||||||
TypeParameterReflection,
|
TypeParameterReflection,
|
||||||
} from 'typedoc';
|
} from 'typedoc';
|
||||||
|
|
||||||
import './TsDocs.scss';
|
import './TSDocs.scss';
|
||||||
|
|
||||||
const getTypeParamString = (params: TypeParameterReflection[]) => `<${params.map(p => p.name).join(', ')}>`;
|
const getTypeParamString = (params: TypeParameterReflection[]) => `<${params.map(p => p.name).join(', ')}>`;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TsDocs',
|
name: 'TSDocs',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
docs: {
|
docs: {
|
|
@ -5,14 +5,14 @@ import ExampleStandaloneEditor from '../ExampleStandaloneEditor'
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
## Vue Component without wrapper
|
## As a View Component
|
||||||
|
|
||||||
This documentation website already uses Vue under the hood, so Schlechtenburg can just imported as
|
This documentation website already uses Vue under the hood, so Schlechtenburg can just imported as
|
||||||
any other component:
|
any other component:
|
||||||
|
|
||||||
<ExampleEditor></ExampleEditor>
|
<ExampleEditor></ExampleEditor>
|
||||||
|
|
||||||
## Wrapped with Vue
|
## Standalone
|
||||||
|
|
||||||
`@schlechtenburg/standalone` gives you a wrapped version of the editor in case you don't have Vue
|
`@schlechtenburg/standalone` gives you a wrapped version of the editor in case you don't have Vue
|
||||||
already installed in your application
|
already installed in your application
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { defineComponent } from 'vue';
|
|
||||||
|
|
||||||
import './Introduction.scss';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'Introduction',
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
return () => <div class="introduction">Introduction</div>;
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,12 +0,0 @@
|
||||||
export default [
|
|
||||||
{
|
|
||||||
name: 'home',
|
|
||||||
path: '/',
|
|
||||||
component: () => import('./pages/Introduction'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'package',
|
|
||||||
path: '/@schlechtenburg/:package',
|
|
||||||
component: () => import('./pages/Package'),
|
|
||||||
},
|
|
||||||
]
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
defineComponent,
|
defineComponent,
|
||||||
ref,
|
ref,
|
||||||
|
Ref,
|
||||||
PropType,
|
PropType,
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
import {
|
import {
|
||||||
|
@ -9,17 +10,17 @@ import {
|
||||||
SbMain,
|
SbMain,
|
||||||
SbMode,
|
SbMode,
|
||||||
OnUpdateBlockCb,
|
OnUpdateBlockCb,
|
||||||
|
ISbMainProps,
|
||||||
} from '@schlechtenburg/core';
|
} from '@schlechtenburg/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export default function getWrapper({
|
export default function getWrapper() {
|
||||||
block,
|
const refBlock: Ref<IBlockData<any>|null> = ref(null);
|
||||||
mode,
|
const refMode = ref(SbMode.View);
|
||||||
availableBlocks,
|
|
||||||
}) {
|
const SchlechtenburgWrapper = defineComponent({
|
||||||
return defineComponent({
|
|
||||||
name: 'SchlechtenburgWrapper',
|
name: 'SchlechtenburgWrapper',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
@ -47,15 +48,39 @@ export default function getWrapper({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props) {
|
setup(props: ISbMainProps) {
|
||||||
const refBlock = ref({ ...block });
|
refBlock.value = { ...(props.block) };
|
||||||
const refMode = ref({ ...block });
|
refMode.value = props.mode;
|
||||||
|
|
||||||
|
if (!refBlock.value) {
|
||||||
|
return () => <div class="sb-message sb-message_error">An Error occurred</div>;
|
||||||
|
}
|
||||||
|
|
||||||
return () => <SbMain
|
return () => <SbMain
|
||||||
block={refBlock}
|
block={refBlock.value as IBlockData<any>}
|
||||||
availableBlocks={props.availableBlocks}
|
availableBlocks={props.availableBlocks}
|
||||||
mode={mode}
|
mode={refMode.value}
|
||||||
|
onUpdate={(newBlock: IBlockData<any>) => {
|
||||||
|
refBlock.value = { ...newBlock };
|
||||||
|
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
SchlechtenburgWrapper,
|
||||||
|
getBlock() {
|
||||||
|
return refBlock.value;
|
||||||
|
},
|
||||||
|
setBlock(block: IBlockData<any>) {
|
||||||
|
refBlock.value = { ...block };
|
||||||
|
},
|
||||||
|
getMode() {
|
||||||
|
return refMode.value;
|
||||||
|
},
|
||||||
|
setMode(mode: SbMode) {
|
||||||
|
refMode.value = mode;
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import {
|
import { createApp } from 'vue'
|
||||||
createApp,
|
import { ISbMainProps } from '@schlechtenburg/core';
|
||||||
} from 'vue'
|
import getWrapper from './get-wrapper';
|
||||||
import {
|
|
||||||
ISbMainProps,
|
|
||||||
IBlockData,
|
|
||||||
SbMain,
|
|
||||||
} from '@schlechtenburg/core';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -21,19 +16,25 @@ export const startSchlechtenburg = async (
|
||||||
*/
|
*/
|
||||||
props:ISbMainProps,
|
props:ISbMainProps,
|
||||||
) => {
|
) => {
|
||||||
let block = { ...props.block };
|
const {
|
||||||
const app = createApp(SbMain, {
|
SchlechtenburgWrapper,
|
||||||
...props,
|
getBlock,
|
||||||
onUpdate: (update: IBlockData<any>) => {
|
setBlock,
|
||||||
block = update;
|
getMode,
|
||||||
props.onUpdate(update);
|
setMode,
|
||||||
},
|
} = getWrapper();
|
||||||
}as unknown as Record<string, unknown>);
|
|
||||||
|
const app = createApp(
|
||||||
|
SchlechtenburgWrapper,
|
||||||
|
{ ...props, } as unknown as Record<string, unknown>,
|
||||||
|
);
|
||||||
app.mount(el);
|
app.mount(el);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getBlock() {
|
app,
|
||||||
return block;
|
getBlock,
|
||||||
},
|
setBlock,
|
||||||
|
getMode,
|
||||||
|
setMode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue