From 9fa88dba2a7d37e6f17c267845a97dca1e164aba Mon Sep 17 00:00:00 2001 From: Nitwel Date: Mon, 12 Oct 2020 13:45:54 +0200 Subject: [PATCH 1/3] fix docs navigation --- .../modules/docs/components/navigation.vue | 47 ++++++++++--------- app/src/modules/docs/index.ts | 11 +++-- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/app/src/modules/docs/components/navigation.vue b/app/src/modules/docs/components/navigation.vue index 1c0587d057..cb5dfe92ff 100644 --- a/app/src/modules/docs/components/navigation.vue +++ b/app/src/modules/docs/components/navigation.vue @@ -10,15 +10,15 @@ import NavigationItem from './navigation-item.vue'; import { nav } from '@directus/docs'; function spreadPath(path: string) { - const sections = path.substr(1).split('/') - if(sections.length === 0) return [] + const sections = path.substr(1).split('/'); + if (sections.length === 0) return []; - const paths: string[] = ['/'+sections[0]] + const paths: string[] = ['/' + sections[0]]; - for(let i = 1; i < sections.length; i++) { - paths.push(paths[i - 1] + '/' + sections[i]) + for (let i = 1; i < sections.length; i++) { + paths.push(paths[i - 1] + '/' + sections[i]); } - return paths + return paths; } export default defineComponent({ @@ -26,33 +26,38 @@ export default defineComponent({ props: { path: { type: String, - default: null - } + default: '/docs', + }, }, setup(props) { - const _selection = ref(spreadPath(props.path.replace('/docs',''))) + const _selection = ref(null); - watch(() => props.path, (newPath) => { - _selection.value = spreadPath(newPath.replace('/docs','')) - }) + watch( + () => props.path, + (newPath) => { + if (newPath === null) return; + _selection.value = spreadPath(newPath.replace('/docs', '')); + } + ); const selection = computed({ get() { - return _selection.value + if (_selection.value === null && props.path !== null) + _selection.value = spreadPath(props.path.replace('/docs', '')); + return _selection.value || []; }, set(newSelection: string[]) { - if(newSelection.length === 0) { - _selection.value = [] + if (newSelection.length === 0) { + _selection.value = []; } else { - if(_selection.value.includes(newSelection[0])) { - _selection.value = _selection.value.filter(s => s !== newSelection[0]) + if (_selection.value && _selection.value.includes(newSelection[0])) { + _selection.value = _selection.value.filter((s) => s !== newSelection[0]); } else { - _selection.value = spreadPath(newSelection[0]) + _selection.value = spreadPath(newSelection[0]); } - } - } - }) + }, + }); return { navSections: nav.app, selection }; }, diff --git a/app/src/modules/docs/index.ts b/app/src/modules/docs/index.ts index 4ec6d8547f..400ce4415d 100644 --- a/app/src/modules/docs/index.ts +++ b/app/src/modules/docs/index.ts @@ -31,14 +31,15 @@ export default defineModule(({ i18n }) => { for (const doc of directory.children) { if (doc.type === 'file') { routes.push({ - path: '/' + doc.path.replace('.md', '').replaceAll('\\','/'), + path: '/' + doc.path.replace('.md', '').replaceAll('\\', '/'), component: StaticDocs, }); } else if (doc.type === 'directory') { - routes.push({ - path: '/' + doc.path.replaceAll('\\','/'), - redirect: '/' + doc.children![0].path.replace('.md', '').replaceAll('\\','/'), - }); + if (doc.path && doc.children && doc.children.length > 0) + routes.push({ + path: '/' + doc.path.replaceAll('\\', '/'), + redirect: '/' + doc.children![0].path.replace('.md', '').replaceAll('\\', '/'), + }); routes.push(...parseRoutes(doc)); } From 41170f2584e2905fadf180cbb0868f5709086e6c Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Mon, 12 Oct 2020 10:02:08 -0400 Subject: [PATCH 2/3] Ignore bin/node modules in docs build --- docs/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build.js b/docs/build.js index 297a3db48e..9b610d7293 100644 --- a/docs/build.js +++ b/docs/build.js @@ -15,13 +15,13 @@ async function build() { await rimraf(distPath); - const tree = dirTree('.', { extensions: /\.md/, exclude: /dist/ }); + const tree = dirTree('.', { extensions: /\.md/, exclude: /(dist|node_modules)/ }); await fse.ensureDir(distPath); await fse.writeJSON('./dist/index.json', tree); - await copyfiles(['./**/*.md', distPath]); + await copyfiles(['./**/*.md', distPath], { exclude: './node_modules/**/*.*' }); const yamlFiles = []; const filesInRoot = await fse.readdir(__dirname); From f1186bb06655ba78c031676c0e6cb16e8d1365c7 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Mon, 12 Oct 2020 10:35:06 -0400 Subject: [PATCH 3/3] Fix fetching single o2m column --- api/src/database/run-ast.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/src/database/run-ast.ts b/api/src/database/run-ast.ts index e05fb2b195..7d9e0a79d5 100644 --- a/api/src/database/run-ast.ts +++ b/api/src/database/run-ast.ts @@ -244,10 +244,13 @@ function removeTemporaryFields( const fields = ast.children .filter((child) => child.type === 'field') .map((child) => child.name); + const nestedCollections = ast.children.filter( (child) => child.type === 'collection' ) as NestedCollectionAST[]; + fields.push(...nestedCollections.map((nestedNode) => nestedNode.fieldKey)); + for (const rawItem of rawItems) { if (rawItem === null) return rawItem;