From 91e4ce4b2a959f5acb079edaf3e0dd99b788dd1e Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Tue, 18 Jul 2023 01:43:55 +0900 Subject: [PATCH] (add) docs: iroiro --- assets/js/misc/index.ts | 19 ++++++++++++++++++- components/content/ApiPermissions.vue | 22 ++++++++++++++++++++++ components/docs/PrevNext.vue | 6 ++++-- pages/docs/[...slug].vue | 23 ++++++++++++++++------- pages/docs/index.vue | 4 ++-- 5 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 components/content/ApiPermissions.vue diff --git a/assets/js/misc/index.ts b/assets/js/misc/index.ts index 8cf5c7af..94a49671 100644 --- a/assets/js/misc/index.ts +++ b/assets/js/misc/index.ts @@ -38,4 +38,21 @@ export function isLocalPath(link: string, base?: string): boolean { } } -} \ No newline at end of file +} + +export const findDeepObject = (obj: Record, condition: (v: any) => boolean): Record | null => { + if (condition(obj)) { + return obj; + } + + if (obj?.children && obj.children.length > 0) { + for (let i = 0; i < obj.children.length; i++) { + const result = findDeepObject(obj.children[i], condition); + if (result) { + return result; + } + } + } + + return null; +}; diff --git a/components/content/ApiPermissions.vue b/components/content/ApiPermissions.vue new file mode 100644 index 00000000..829ba6f2 --- /dev/null +++ b/components/content/ApiPermissions.vue @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/components/docs/PrevNext.vue b/components/docs/PrevNext.vue index c4b5e29a..a8a4d4e2 100644 --- a/components/docs/PrevNext.vue +++ b/components/docs/PrevNext.vue @@ -29,14 +29,16 @@ const { locale } = useI18n(); const route = useRoute(); const slugs = (route.params.slug as string[]).filter((v) => v !== ''); -withDefaults(defineProps<{ +const props = withDefaults(defineProps<{ ignoreDirBasedNav?: boolean; + isDir?: boolean; }>(), { ignoreDirBasedNav: false, + isDir: false }); const currentPath = `/${locale.value}/docs/${slugs.join('/')}`; -const currentDirectory = `/${locale.value}/docs/${slugs.slice(0, -1).join('/')}`; +const currentDirectory = props.isDir ? `/${locale.value}/docs/${slugs.join('/')}` : `/${locale.value}/docs/${slugs.slice(0, -1).join('/')}`; const [prev, next] = await queryContent().only(['_path', 'title']).where({ _path: { $contains: 'docs' }, _partial: false }).findSurround(currentPath); diff --git a/pages/docs/[...slug].vue b/pages/docs/[...slug].vue index f82c3442..46c74bcc 100644 --- a/pages/docs/[...slug].vue +++ b/pages/docs/[...slug].vue @@ -1,6 +1,6 @@