Drop inline rendering of docs (#17434)

This commit is contained in:
Rijk van Zanten
2023-02-07 13:52:53 -05:00
committed by GitHub
parent 78bda5c763
commit 2fa46e18f5
10 changed files with 4 additions and 305 deletions

View File

@@ -31,7 +31,6 @@
"devDependencies": {
"@babel/core": "7.20.12",
"@babel/preset-env": "7.20.2",
"@directus/docs": "9.22.3",
"@directus/extensions-sdk": "workspace:*",
"@directus/format-title": "10.0.0",
"@directus/shared": "workspace:*",

View File

@@ -60,9 +60,12 @@ export const MODULE_BAR_DEFAULT = [
enabled: true,
},
{
type: 'module',
type: 'link',
id: 'docs',
enabled: true,
name: '$t:documentation',
icon: 'help_outline',
url: 'https://docs.directus.io',
},
{
type: 'module',

View File

@@ -1,39 +0,0 @@
- name: App Overview
to: '/app/overview'
icon: school
- name: Collection Page
to: '/app/content/collections'
icon: list_alt
- name: Item Page
to: '/app/content/items'
icon: edit_note
- name: User Directory
to: '/app/user-directory'
icon: people_alt
- name: File Library
to: '/app/file-library'
icon: folder
- name: Insights
to: '/app/insights'
icon: insights
- name: Documentation
to: '/app/documentation'
icon: help_outline
- name: Settings
to: '/app/settings'
icon: settings
- name: Backing Directus
to: '/getting-started/backing-directus'
icon: card_giftcard
- name: Glossary
to: '/getting-started/glossary'
icon: menu_book

View File

@@ -1,45 +0,0 @@
<template>
<v-divider v-if="section.divider" />
<v-list-group
v-else-if="section.children"
scope="docs-navigation"
:dense="dense"
:multiple="false"
:value="section.to"
>
<template #activator>
<v-list-item-icon v-if="section.icon !== undefined"><v-icon :name="section.icon" /></v-list-item-icon>
<v-list-item-content>
<v-text-overflow :text="section.name" />
</v-list-item-content>
</template>
<navigation-list-item v-for="(child, index) in section.children" :key="index" :section="child" dense />
</v-list-group>
<v-list-item v-else scope="docs-navigation" :to="`/docs${section.to}`" :dense="dense" :value="section.to">
<v-list-item-icon v-if="section.icon !== undefined"><v-icon :name="section.icon" /></v-list-item-icon>
<v-list-item-content>
<v-text-overflow :text="section.name" />
</v-list-item-content>
</v-list-item>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { Link, Group } from '@directus/docs';
export default defineComponent({
name: 'NavigationListItem',
props: {
section: {
type: Object as PropType<Link | Group>,
default: null,
},
dense: {
type: Boolean,
default: false,
},
},
});
</script>

View File

@@ -1,52 +0,0 @@
<template>
<v-list v-model="selection" nav :mandatory="false" scope="docs-navigation">
<navigation-item v-for="item in navSections" :key="item.name" :section="item" />
</v-list>
</template>
<script lang="ts">
import { defineComponent, watch, ref } from 'vue';
import NavigationItem from './navigation-item.vue';
import navLinks from './links.yaml';
function spreadPath(path: string) {
const sections = path.slice(1).split('/');
if (sections.length === 0) return [];
const paths: string[] = ['/' + sections[0]];
for (let i = 1; i < sections.length; i++) {
paths.push(paths[i - 1] + '/' + sections[i]);
}
if (paths[0] === '/reference' && paths[1] === '/reference/api') {
paths.shift();
}
return paths;
}
export default defineComponent({
components: { NavigationItem },
props: {
path: {
type: String,
default: '/docs',
},
},
setup(props) {
const selection = ref<string[] | null>(null);
watch(
() => props.path,
(newPath) => {
if (newPath === null) return;
selection.value = [...(selection.value || []), ...spreadPath(newPath.replace('/docs', ''))];
},
{ immediate: true }
);
return { navSections: navLinks, selection };
},
});
</script>

View File

@@ -1,53 +0,0 @@
import { defineModule } from '@directus/shared/utils';
import docs, { DocsRoutes } from '@directus/docs';
import { RouteRecordRaw } from 'vue-router';
import NotFound from './routes/not-found.vue';
import StaticDocs from './routes/static.vue';
export default defineModule({
id: 'docs',
name: '$t:documentation',
icon: 'help_outline',
routes: [
{
name: 'docs-routes',
path: '',
component: StaticDocs,
children: [
{
name: 'docs-app-overview-redirect',
path: '',
redirect: '/docs/app/overview',
},
...getRoutes(docs),
],
},
{
path: ':_(.+)+',
component: NotFound,
},
],
});
function getRoutes(routes: DocsRoutes): RouteRecordRaw[] {
const updatedRoutes: RouteRecordRaw[] = [];
for (const route of routes) {
if (!('children' in route)) {
updatedRoutes.push({
name: `docs-${route.path.replace('/', '-')}`,
path: route.path,
component: route.import,
});
} else {
updatedRoutes.push({
path: route.path,
redirect: `/docs/${route.children[0].path}`,
});
updatedRoutes.push(...getRoutes(route.children));
}
}
return updatedRoutes;
}

View File

@@ -1,41 +0,0 @@
<template>
<private-view :title="t('page_not_found')">
<template #navigation>
<docs-navigation :path="route.path" />
</template>
<div class="not-found">
<v-info :title="t('page_not_found')" icon="not_interested">
{{ t('page_not_found_body') }}
</v-info>
</div>
</private-view>
</template>
<script lang="ts">
import { useI18n } from 'vue-i18n';
import { defineComponent } from 'vue';
import { useRoute } from 'vue-router';
import DocsNavigation from '../components/navigation.vue';
export default defineComponent({
name: 'NotFound',
components: { DocsNavigation },
setup() {
const { t } = useI18n();
const route = useRoute();
return { t, route };
},
});
</script>
<style lang="scss" scoped>
.not-found {
display: flex;
align-items: center;
justify-content: center;
padding: 20vh 0;
}
</style>

View File

@@ -1,64 +0,0 @@
<template>
<private-view :title="title">
<template #title-outer:prepend>
<v-button rounded disabled icon>
<v-icon name="info" />
</v-button>
</template>
<template #title>
<h1 class="type-title">{{ title }}</h1>
<v-chip v-if="modularExtension" disabled small>Modular Extension</v-chip>
</template>
<template #navigation>
<docs-navigation :path="route.path" />
</template>
<div class="docs-content selectable">
<router-view @update:title="title = $event" @update:modular-extension="modularExtension = $event" />
</div>
<template #sidebar>
<sidebar-detail icon="info_outline" :title="t('information')" close>
<div v-md="t('page_help_docs_global')" class="page-description" />
</sidebar-detail>
</template>
</private-view>
</template>
<script lang="ts">
import { useI18n } from 'vue-i18n';
import { defineComponent, ref } from 'vue';
import { useRoute } from 'vue-router';
import DocsNavigation from '../components/navigation.vue';
export default defineComponent({
name: 'StaticDocs',
components: { DocsNavigation },
setup() {
const { t } = useI18n();
const route = useRoute();
const title = ref('Test');
const modularExtension = ref(false);
return { t, route, title, modularExtension };
},
});
</script>
<style lang="scss" scoped>
.docs-content {
padding: 0 var(--content-padding) var(--content-padding-bottom);
}
.v-chip {
--v-chip-background-color: var(--v-chip-background-color-hover);
--v-chip-color: var(--v-chip-color-hover);
margin-left: 12px;
cursor: default !important;
}
</style>

View File

@@ -130,9 +130,6 @@ export default defineConfig({
},
}),
],
optimizeDeps: {
exclude: ['@directus/docs'],
},
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },

6
pnpm-lock.yaml generated
View File

@@ -370,7 +370,6 @@ importers:
specifiers:
'@babel/core': 7.20.12
'@babel/preset-env': 7.20.2
'@directus/docs': 9.22.3
'@directus/extensions-sdk': workspace:*
'@directus/format-title': 10.0.0
'@directus/shared': workspace:*
@@ -479,7 +478,6 @@ importers:
devDependencies:
'@babel/core': 7.20.12
'@babel/preset-env': 7.20.2_@babel+core@7.20.12
'@directus/docs': 9.22.3
'@directus/extensions-sdk': link:../packages/extensions-sdk
'@directus/format-title': 10.0.0
'@directus/shared': link:../packages/shared
@@ -3692,10 +3690,6 @@ packages:
'@jridgewell/trace-mapping': 0.3.9
dev: true
/@directus/docs/9.22.3:
resolution: {integrity: sha512-zuL1iK9xDgGSG/0xW7QJdU7mt5k3FGoxnuN1EYoGeaMXn6KAAnME3R1kZijf3FhCt8cw8GLj2yX453bZK+SmlA==}
dev: true
/@directus/format-title/10.0.0:
resolution: {integrity: sha512-iMXP8yQb0UKAMGRHAY7IkNXEGdUqQDvlu1aAkPARYah4lMhEU8E5KgkXdOCPQaxt6Wy0gXb7DPMjeSlKyBKCxg==}
engines: {node: '>=6.0.0'}