docs(nxdev): remove subfolder from public (#8419)

This commit is contained in:
Benjamin Cabanes 2022-01-06 16:58:49 -05:00 committed by GitHub
parent 2b73b60ad4
commit 7000b3782b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
341 changed files with 17 additions and 46 deletions

View File

@ -1,8 +1,8 @@
# documentation-api
This library provides the data necessary to display the latest and previous documentation.
This library provides the data necessary to display the documentation.
The [`data`](./src/data) folder contains the version mapping as well as a snapshot of the latest and previous docs.
The [`data`](./src/data) folder contains the version mapping as well as a snapshot of the docs.
## Testing

View File

@ -89,6 +89,6 @@ export class DocumentsApi {
}
}
const file = found.file ?? ['default', ...path].join('/');
return join(this.options.publicDocsRoot, 'latest', `${file}.md`);
return join(this.options.publicDocsRoot, `${file}.md`);
}
}

View File

@ -9,11 +9,7 @@ function readJsonFile(f) {
export function createDocumentApiOptions() {
return {
documents: readJsonFile(
join(
join(__dirname, '../../../nx-dev/public/documentation'),
'latest',
'map.json'
)
join(join(__dirname, '../../../nx-dev/public/documentation'), 'map.json')
).find((x) => x.id === 'default') as DocumentMetadata,
publicDocsRoot: join(__dirname, '../../../nx-dev/public/documentation'),
};

View File

@ -6,46 +6,33 @@ describe('transformImagePath', () => {
document: {
content: '',
excerpt: '',
filePath:
'nx-dev/nx-dev/public/documentation/latest/shared/using-nx/dte.md',
filePath: 'nx-dev/nx-dev/public/documentation/shared/using-nx/dte.md',
data: {},
},
};
const transform = transformImagePath(opts);
expect(transform('./test.png')).toEqual(
'/documentation/latest/shared/using-nx/test.png'
);
expect(transform('../test.png')).toEqual(
'/documentation/latest/shared/test.png'
);
expect(transform('../../test.png')).toEqual(
'/documentation/latest/test.png'
'/documentation/shared/using-nx/test.png'
);
expect(transform('../test.png')).toEqual('/documentation/shared/test.png');
expect(transform('../../test.png')).toEqual('/documentation/test.png');
});
it('should transform absolute paths', () => {
const opts = {
version: {
name: 'Latest',
id: 'latest',
alias: 'l',
release: '12.9.0',
path: 'latest',
default: true,
},
document: {
content: '',
excerpt: '',
filePath:
'nx-dev/nx-dev/public/documentation/latest/angular/generators/workspace-generators.md',
'nx-dev/nx-dev/public/documentation/angular/generators/workspace-generators.md',
data: {},
},
};
const transform = transformImagePath(opts);
expect(transform('/shared/test.png')).toEqual(
'/documentation/latest/shared/test.png'
'/documentation/shared/test.png'
);
});
});

View File

@ -20,7 +20,6 @@ export function transformImagePath({
);
}
// TODO@ben remove `latest` when flattening docs' architecture
return uriTransformer(`/documentation/latest`.concat(src));
return uriTransformer(`/documentation`.concat(src));
};
}

View File

@ -6,13 +6,11 @@ import {
// Imports JSON directly so they can be bundled into the app and functions.
// Also provides some test safety.
import latestDocuments from '../public/documentation/latest/map.json';
import documents from '../public/documentation/map.json';
export const documentsApi = new DocumentsApi({
publicDocsRoot: 'nx-dev/nx-dev/public/documentation',
documents: latestDocuments.find(
(x) => x.id === 'default'
) as DocumentMetadata,
documents: documents.find((x) => x.id === 'default') as DocumentMetadata,
});
export const menuApi = new MenuApi(documentsApi);

Some files were not shown because too many files have changed in this diff Show More