I have build a webpart with SPFx and using following libraries
@microsoft/sp-core-library": "1.6.0 @microsoft/sp-lodash-subset": "1.6.0 @microsoft/sp-office-ui-fabric-core": "1.6.0 @microsoft/sp-webpart-base": "1.6.0 @pnp/common": "^1.2.2 @pnp/logging": "^1.2.2 @pnp/odata": "^1.2.2 @pnp/sp": "^1.2.2* react": "15.6.2
In our solution there will be alot of sitecollection and all collection will have alot of sitepages. The webpart will dynamically feed itself on data depending on the sitecollection name and sitepage name.
For an example if i have a sitecollection called SiteCol1 and it have a sitepage called finance the webpart should feed itself based on the names. When navigating to SiteCol1 -> Finance.aspx the webpart will call an API with parameters SiteCol1 and Finance.
At the current state i have managed to get sitecollection name thru this code
sp.web.get().then((item:any) => { console.log(item.Title) this.setState({ rootweb:item.Title });
Unfortunately its not this simple to get the .aspx sitepage. Does anyone have any good solution to get the current .aspx sitepage name.