File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed
blocks/library/latest-posts Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Returns a Promise with the latest posts or an error on failure.
3+ *
4+ * @param {Number } postsToShow
5+ * @returns {Object }
6+ */
7+ export function getLatestPosts ( postsToShow = 5 ) {
8+ const postsCollection = new wp . api . collections . Posts ( ) ;
9+
10+ const posts = postsCollection . fetch ( {
11+ data : {
12+ per_page : postsToShow
13+ }
14+ } ) ;
15+
16+ return posts ;
17+ }
18+
Original file line number Diff line number Diff line change @@ -7,18 +7,7 @@ import Placeholder from 'components/placeholder';
77 * Internal dependencies
88 */
99import { registerBlock } from '../../api' ;
10-
11- function getLatestPosts ( postsToShow = 5 ) {
12- const postsCollection = new wp . api . collections . Posts ( ) ;
13-
14- const posts = postsCollection . fetch ( {
15- data : {
16- per_page : postsToShow
17- }
18- } ) ;
19-
20- return posts ;
21- }
10+ import { getLatestPosts } from './data.js' ;
2211
2312function renderList ( latestPosts ) {
2413 return (
You can’t perform that action at this time.
0 commit comments