Skip to content

Commit

Permalink
Fetch posts index
Browse files Browse the repository at this point in the history
  • Loading branch information
ifahrentholz committed Feb 2, 2024
1 parent 6277a22 commit b753e63
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/posts/posts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/posts/posts.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/blocks/posts/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,19 @@ const template = () => {
</ul>
</article>`;
};
export default function (block: HTMLElement) {
export default async function (block: HTMLElement) {
block.innerHTML = '';

const req = await fetch(`${window.hlx.codeBasePath}/query-index.json`);
const response = await req.json();
const data = response.data
.filter((item) => {
return item.path.includes('/posts');
})
.map((item) => item.path);

console.log('🚀 ~ data ~ data:', data);

block.style.removeProperty('display');
render(template(), block);
}
2 changes: 1 addition & 1 deletion types/blocks/posts/posts.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function (block: HTMLElement): void;
export default function (block: HTMLElement): Promise<void>;

0 comments on commit b753e63

Please sign in to comment.