@ -1,14 +1,20 @@
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import Card from '../components/Card.astro';
|
||||
import type { Post } from '../../../types';
|
||||
import type { Post } from '../types';
|
||||
|
||||
const posts: Post[] = (await(await fetch("http://localhost:3001/api/posts")).json()).docs;
|
||||
const posts: Post[] = (await(await fetch("http://payload:3001/api/posts")).json()).docs;
|
||||
posts.forEach(post=> console.log(post.title));
|
||||
---
|
||||
|
||||
<Layout title="Welcome to Astro.">
|
||||
<main>
|
||||
{posts.reverse().map(post => (
|
||||
<article>
|
||||
<h2>{post.title}</h2>
|
||||
<p>{post.updatedAt}</p>
|
||||
</article>
|
||||
))}
|
||||
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
|
||||
<p class="instructions">
|
||||
To get started, open the directory <code>src/pages</code> in your project.<br />
|
||||
|
50
astro/src/types.ts
Executable file
50
astro/src/types.ts
Executable file
@ -0,0 +1,50 @@
|
||||
/* tslint:disable */
|
||||
/**
|
||||
* This file was automatically generated by Payload CMS.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
|
||||
* and re-run `payload generate:types` to regenerate this file.
|
||||
*/
|
||||
|
||||
export interface Config {
|
||||
collections: {
|
||||
categories: Category;
|
||||
posts: Post;
|
||||
tags: Tag;
|
||||
users: User;
|
||||
};
|
||||
globals: {};
|
||||
}
|
||||
export interface Category {
|
||||
id: string;
|
||||
name?: string;
|
||||
}
|
||||
export interface Post {
|
||||
id: string;
|
||||
title?: string;
|
||||
author?: string | User;
|
||||
publishedDate?: string;
|
||||
category?: string | Category;
|
||||
tags?: string[] | Tag[];
|
||||
content?: {
|
||||
[k: string]: unknown;
|
||||
}[];
|
||||
status?: 'draft' | 'published';
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
export interface User {
|
||||
id: string;
|
||||
name?: string;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
email?: string;
|
||||
resetPasswordToken?: string;
|
||||
resetPasswordExpiration?: string;
|
||||
loginAttempts?: number;
|
||||
lockUntil?: string;
|
||||
password?: string;
|
||||
}
|
||||
export interface Tag {
|
||||
id: string;
|
||||
name?: string;
|
||||
}
|
Reference in New Issue
Block a user