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 # 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 ## Testing

View File

@ -89,6 +89,6 @@ export class DocumentsApi {
} }
} }
const file = found.file ?? ['default', ...path].join('/'); 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() { export function createDocumentApiOptions() {
return { return {
documents: readJsonFile( documents: readJsonFile(
join( join(join(__dirname, '../../../nx-dev/public/documentation'), 'map.json')
join(__dirname, '../../../nx-dev/public/documentation'),
'latest',
'map.json'
)
).find((x) => x.id === 'default') as DocumentMetadata, ).find((x) => x.id === 'default') as DocumentMetadata,
publicDocsRoot: join(__dirname, '../../../nx-dev/public/documentation'), publicDocsRoot: join(__dirname, '../../../nx-dev/public/documentation'),
}; };

View File

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

View File

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

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