PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
extendify / src / Agent / lib / linkable-pages.js

linkable-pages.js in Extendify 3.2.2, at src/Agent/lib/linkable-pages.js

23 lines 588 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import apiFetch from '@wordpress/api-fetch';
2 import { decodeEntities } from '@wordpress/html-entities';
3
4 // Root-relative, like the menu links a launched site starts with.
5 const pathOf = (link) => {
6 const { pathname, search } = new URL(link);
7 return pathname + search;
8 };
9
10 export const fetchLinkablePages = () =>
11 apiFetch({
12 path: '/wp/v2/pages?status=publish&per_page=100&_fields=id,title,link',
13 })
14 .then((pages) =>
15 pages.map(({ id, title, link }) => ({
16 id,
17 title: decodeEntities(title?.rendered ?? ''),
18 url: pathOf(link),
19 link,
20 })),
21 )
22 .catch(() => []);
23