An instance method that provides data about the pages you’ve created within Makeswift
1
and 100
.id
cursor of the last page entry that was fetched."en-US"
).'title'
, 'path'
, 'description'
, 'createdAt'
, 'updatedAt'
.'asc'
or 'desc'
.Live
or Working
getPages
are paginated. A paginated request will only
retrieve a portion of the total pages per request. If you have a large number of
pages, you may need to paginate through the results to retrieve all of them.
To make this easier, the returned value of getPages
is an extension of a
Promise
and an AsyncIterable
. This abstraction enables you to consume the
pages in multiple ways, allowing you to easily retrieve all pages without
worrying about the implementation details of pagination:
getPages
includes the following methods:
toArray(): Promise<T[]>
: Consumes all pages in the iterable and returns them as an array.
map(callback: (item: T) => U)
: Maps over each page in the iterable to yield a new data
type. Returns another async iterable.
filter(predicate: (item: T) => Boolean)
: Selectively yields pages based on a
predicate function. Returns another async iterable.
.map
and .filter
return another iterable, you can chain these
methods together:
id
of a page to the after
option to retrieve the next set of pages after
that page. This can be used to manually implement paginating through all pages:
getPages
will return data reflecting the state of published
Makeswift pages. To specify which variant of your pages you want to retrieve,
you can pass a value to the siteVersion
option. If your site is using pages
router, use the getSiteVersion
method to
retrieve the current site version. If your site is using app router, use the
getSiteVersion
function.
Note that the publishedAt
field of a page will always be null
when
retrieving non-live versions of the site. This is because the page data has not
been published yet.
Similarly, if you need to retrieve information on pages that are not currently
online (even if they have been published), you can pass includeOffline: true
to the getPages
method. By default, offline pages are excluded from results.
/blog/
. You can use the pathPrefix
option to
retrieve all pages that start with /blog/
:
getStaticPaths
on your catch-all page:
generateStaticParams
on your dynamically routed page:
getPages
can be used to generate a sitemap.xml
file for your
site, allowing search engines to index your pages.
Here’s an example of how to use getPages
with the next-sitemap
library to
generate a sitemap:
getPages
to retrieve pages and map them to the format expected by Next.js:
getPages
will return pages that are excluded from search. You
can filter these pages out while constructing your sitemap based on the
excludedFromSearch
property.
getPages
will return the path of the page, which is relative to the root of
the site. Depending on whether your host is using path-based or domain-based
routing for localization, you may need to prepend the domain or locale to the
path.
sitemapPriority
or sitemapFrequency
for a
page in the Makeswift builder, these attributes will be null
in the
response. You can specify default values for these fields in your sitemap
generation logic.
locale
option to the
getPages
method. Each returned page will include any of its localized
alternates in the localizedVariants
field.
locale
option, pages from your site’s default locale will
be returned. Each page will include any of its localized alternates in the
localizedVariants
field.
For an example of how to use getPages
with localization to statically generate
paths in Next.js app router, see
here.
Version | Changes |
---|---|
v0.19.0 | Adds pagination, sorting, path filtering, and new data fields to getPages response. getPages now returns an async iterable with toArray , .map , and filter methods. |
v0.13.0 | getPages can retrieve either live or working pages (live by default) |
v0.9.0 | getPages only returns live pages |
v0.2.0 | Released getPages |