Merge branch 'main' into relational-updates

This commit is contained in:
Nitwel
2020-10-12 17:14:58 +02:00
4 changed files with 37 additions and 28 deletions

View File

@@ -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;

View File

@@ -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<string[]>(spreadPath(props.path.replace('/docs','')))
const _selection = ref<string[] | null>(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 };
},

View File

@@ -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));
}

View File

@@ -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);