-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): new composable documentation (#1246)
* feat: sidebar menu * feat: dynamic pages * feat: dynamic content building * feat: new composables structure * feat: update vitepress * feat: dynamic categories * feat: categories list * feat: category link * feat(vue-demo): update categories * feat(vue-demo): lock conflict resolve * feat(vue-demo): tags style * feat(vue-demo): update pnpm lock file * feat(composables): fix test * feat(docs): changes after cr
- Loading branch information
1 parent
6111185
commit 04e1b87
Showing
110 changed files
with
17,749 additions
and
10,552 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { defineLoader } from "vitepress"; | ||
import { resolve } from "path"; | ||
import { extract } from "ts-dox"; | ||
import { readdirSync } from "fs"; | ||
export interface Data { | ||
composablesList: { text: string; link: string; category: string }[]; | ||
} | ||
|
||
declare const data: Data; | ||
export { data }; | ||
|
||
export default defineLoader({ | ||
async load(): Promise<Data> { | ||
const composablesList = readdirSync("../../packages/composables/src/", { | ||
withFileTypes: true, | ||
}) | ||
.filter( | ||
(element) => element.isDirectory() && element.name.startsWith("use"), | ||
) | ||
.map((element) => { | ||
const file = extract( | ||
resolve( | ||
`../../packages/composables/src/${element.name}/${element.name}.ts`, | ||
), | ||
); | ||
return { | ||
text: element.name, | ||
link: `/packages/composables/${element.name}`, | ||
category: | ||
(file?.functions[element.name]?.docs.category || | ||
file?.functions[`${element.name}Function`]?.docs.category) ?? | ||
"", | ||
}; | ||
}); | ||
|
||
return { | ||
composablesList, | ||
}; | ||
}, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div | ||
v-for="(category, index) in categoryTreeData" | ||
:id="`${index}${new Date().getTime()}`" | ||
> | ||
<h3 class="!mb-2" :id="normalizeAnchorText(index.toString())" tabindex="-1"> | ||
{{ index }} | ||
<a | ||
class="header-anchor !top-0" | ||
:href="`#${normalizeAnchorText(index.toString())}`" | ||
aria-label='Permalink to "Test"' | ||
></a> | ||
</h3> | ||
<ul class="flex flex-wrap gap-3 !p-0 !m-0"> | ||
<li | ||
v-for="(composable, index) in category" | ||
:key="`${composable + new Date().getTime()}`" | ||
class="list-none !m-0 bg-gray-100 rounded-sm leading-4" | ||
> | ||
<a | ||
:href="`/packages/composables/${composable}`" | ||
class="text-sm p-2 !no-underline !text-gray-800" | ||
>{{ composable }}</a | ||
> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { data } from "../../data/composables.data"; | ||
import { normalizeAnchorText } from "../typer/utils"; | ||
const categoryTreeData = computed(() => { | ||
const categoryTree: { [key: string]: string[] } = {}; | ||
data.composablesList.forEach((composable) => { | ||
const categories = composable.category.split(","); | ||
categories.forEach((category) => { | ||
if (!categoryTree[category]) { | ||
categoryTree[category] = []; | ||
} | ||
categoryTree[category].push(composable.text); | ||
}); | ||
}); | ||
return categoryTree; | ||
}); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<slot /> | ||
</template> |
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,24 @@ | ||
// import './styles/index.css' | ||
import { h, App } from "vue"; | ||
import { VPTheme } from "vitepress-shopware-docs"; | ||
import { App } from "vue"; | ||
import { SWAGTheme } from "vitepress-shopware-docs"; | ||
import PageRef from "./components/PageRef.vue"; | ||
import DemoBlock from "./components/DemoBlock.vue"; | ||
import ComposablesList from "./components/ComposablesList.vue"; | ||
// Ai component | ||
// import AI from "./components/AI.vue"; | ||
import "./custom.css"; | ||
|
||
export default Object.assign({}, VPTheme, { | ||
Layout: () => { | ||
// @ts-ignore | ||
return h(VPTheme.Layout, null, { | ||
// banner: () => h(Banner), | ||
// "content-top": () => h("h1", "We have important Announcement!"), | ||
// 'sidebar-top': () => h(PreferenceSwitch), | ||
// 'aside-mid': () => h(SponsorsAside), | ||
// 'aside-bottom': () => h(VueJobs) | ||
}); | ||
export default Object.assign( | ||
{ | ||
...SWAGTheme(), | ||
}, | ||
enhanceApp({ app }: { app: App }) { | ||
app.component("PageRef", PageRef); | ||
// app.component("AI", AI); | ||
// app.provide('some-injection-key-if-needed', VALUE) | ||
{ | ||
enhanceApp({ app }: { app: App }) { | ||
app.component("PageRef", PageRef); | ||
app.component("DemoBlock", DemoBlock); | ||
app.component("ComposablesList", ComposablesList); | ||
// app.component("AI", AI); | ||
// app.provide('some-injection-key-if-needed', VALUE) | ||
}, | ||
}, | ||
}); | ||
); |
Oops, something went wrong.