Pnpjs: How to get pages from multilingual folders

Created on 15 Jan 2021  路  5Comments  路  Source: pnp/pnpjs

Category

  • [ ] Enhancement
  • [ ] Bug
  • [x] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [ 2.0.13 ]

Please specify what version(s) of SharePoint you are targeting: [ Online ]

I want to retrieve pages documents from the site pages library based on the language. right now I have the english documents on the root folder of site pages and spanish documents in es folder. I had my code working with this: await sp.web.lists.getByTitle("Site Pages").items.....getPaged() however now I want to make it dynamic based on the language, so I wrote this:
await sp.web.getFolderByServerRelativeUrl("/sites/mysite1/sitepages/es").files
but now i am unable to do getPaged like when we do with items

is this even the right way to query pages from multilingual folders?

code question

Most helpful comment

@koltyakov I ended up doing it like here: https://github.com/pnp/pnpjs/issues/1533 by adding a filter to the folder name for that specific language "es". thanks @koltyakov

All 5 comments

Maybe renderListDataAsStream could be helpful?

Its RootFolder can be combined with pageToken.

Alternatively, a filter on FileDirRef and get paged method, thought throttling issues might be expected with too many pages in a library.

Haven't tried this so will have to experiment. I do know from looking at adding pages to folders the undocumented API we use doesn't support creating pages in folders (or we haven't been able to figure out how).

@koltyakov is there an example on using pageToken with renderListDataAsStream? isn't there a way to cast the files returned by getFolderByServerRelativeUrl to Items so then I can carry on with .filter .order .getPaged the same I do with items?

is there an example on using pageToken with renderListDataAsStream

Second link in the my previous comment.

@koltyakov I ended up doing it like here: https://github.com/pnp/pnpjs/issues/1533 by adding a filter to the folder name for that specific language "es". thanks @koltyakov

Was this page helpful?
0 / 5 - 0 ratings