Skip to content

Commit

Permalink
fix(plugin-pages): fix minor issue in child page input concatenation …
Browse files Browse the repository at this point in the history
…with `null` source
  • Loading branch information
GerkinDev committed Aug 4, 2022
1 parent eda79d3 commit 24628e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,6 @@ describe( 'Simple tree', () => {
] } ),
] );
} );
it( 'should map page to workspace with children with pages in module', () => {
addChildModule( 'SUB' );
const targetModule = addChildModule( 'SUB2' );
setVirtualFs( {
SUB2: {
'appendix.md': 'APPENDIX',
'bar.md': 'Bar content',
'baz.md': 'Baz content',
},
} );
const out = pageTreeBuilder.buildPagesTree( project, opts( [ { name: 'SUB2', moduleRoot: true, source: 'appendix.md', children: [
{ name: 'Bar', source: 'bar.md' },
{ name: 'Baz', source: 'baz.md' },
] } ] ) );
expect( out.childrenNodes ).toEqual( [
matchReflection( PageReflection, { name: 'SUB2', depth: 0, module: targetModule, sourceFilePath: 'SUB2/appendix.md', childrenNodes: [
matchReflection( PageReflection, { name: 'Bar', depth: 1, module: targetModule, sourceFilePath: 'SUB2/bar.md', content: 'Bar content', url: 'SUB2/bar.html' } ),
matchReflection( PageReflection, { name: 'Baz', depth: 1, module: targetModule, sourceFilePath: 'SUB2/baz.md', content: 'Baz content', url: 'SUB2/baz.html' } ),
] } ),
] );
} );
} );
describe( 'Mixed', () => {
it( 'should map appendixes to workspace and root', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class PageTreeBuilder implements IPluginComponent<PagesPlugin> {
* @returns the node reflections.
*/
private _mapNodeToReflection( node: PageNode, parent: ANodeReflection.Parent, io: IIOPath ): NodeReflection[] {
const childrenIO: IIOPath = isModuleRoot( node ) ? { ...io } : {
const childrenIO: IIOPath = {
...io,
input: join( io.input, getDir( node, 'source' ) ),
output: join( io.output, getDir( node, 'output' ) ),
Expand All @@ -181,11 +181,13 @@ export class PageTreeBuilder implements IPluginComponent<PagesPlugin> {
[];
}
const nodeReflection = this._getNodeReflection( node, parent, io );
if( !( nodeReflection.module instanceof ProjectReflection ) && nodeReflection.isModuleAppendix ){
// If the node is attached to a new module, skip changes in the input tree (stay at root of `pages` in module)
if( nodeReflection.isModuleAppendix ){
childrenIO.input = io.input;
// Output is now like `pkg-a/pages/...`
childrenIO.output = `${nodeReflection.name.replace( /[^a-z0-9]/gi, '_' )}/${io.output ?? ''}`;
childrenIO.output = io.output;
if( !( nodeReflection.module instanceof ProjectReflection ) ){
// Output is now like `pkg-a/pages/...`
childrenIO.output = `${nodeReflection.name.replace( /[^a-z0-9]/gi, '_' )}/${io.output ?? ''}`;
}
}
const children = node.children ?
this._mapNodesToReflectionsTree(
Expand Down

0 comments on commit 24628e5

Please sign in to comment.