Signed-off-by: Max Schmidt <max.schmidt@outlook.de>
This commit is contained in:
Max Schmidt
2023-05-13 19:10:37 +02:00
parent 43fc0a402c
commit 0dfad4431f
14 changed files with 136 additions and 52 deletions

21
astro/Dockerfile Normal file
View File

@ -0,0 +1,21 @@
FROM node:lts-alpine as base
WORKDIR /base
COPY ./package.json ./package.json
RUN yarn install
COPY ./ ./
FROM base AS dev
ENV NODE_ENV=development
EXPOSE 3000
CMD ["yarn","dev"]
FROM base AS build
ENV NODE_ENV=production
WORKDIR /build
COPY --from=base /base ./
ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
RUN yarn build
FROM nginx:stable AS prod
COPY --from=build /build/dist /usr/share/nginx/html
EXPOSE 80

View File

@ -3,13 +3,10 @@
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"dev": "astro dev --host",
"build": "astro build"
},
"dependencies": {
"astro": "^2.4.1"
}
}
}

View File

@ -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
View 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;
}