瀏覽代碼

added deployment adapter and disabled cms for production

liontix 9 月之前
父節點
當前提交
604730ed7a

+ 4 - 0
.dockerignore

@@ -0,0 +1,4 @@
+dist
+.vscode
+Dockerfile
+node.Dockerfile

+ 30 - 0
Dockerfile

@@ -0,0 +1,30 @@
+# Use Node.js base image for build stage
+FROM node:20.12.2 AS build
+
+# Set working directory
+WORKDIR /app
+
+# Copy package.json and yarn.lock files
+COPY package.json ./
+
+# Install dependencies using Yarn
+RUN npm i
+
+# Copy the rest of the application code
+COPY . .
+
+# Build the application
+RUN npm run build
+
+# Use Nginx base image for final stage
+FROM nginx:alpine
+
+# Copy the static files from the SvelteKit app's build output directory into the Nginx server directory
+COPY --from=build /app/dist/client /usr/share/nginx/html
+COPY nginx.conf /etc/nginx/conf.d/default.conf
+
+# Expose port 80
+EXPOSE 80
+
+# Start Nginx server
+CMD ["nginx", "-g", "daemon off;"]

+ 6 - 16
README.md

@@ -1,16 +1,10 @@
-# Astro Starter Kit: Basics
+# About me
+This project is a web app used to represent my persona on the internet. It lists some facts about me, personal projects and blogs.
 
-```sh
-npm create astro@latest -- --template basics
-```
-
-[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
-[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
-[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)
-
-> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
-
-![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)
+## Tech stack
+- astrojs (web framework)
+- tailwindcss with flowbite (css frameworks)
+- keystatic (content management system)
 
 ## 🚀 Project Structure
 
@@ -42,7 +36,3 @@ All commands are run from the root of the project, from a terminal:
 | `npm run preview`         | Preview your build locally, before deploying     |
 | `npm run astro ...`       | Run CLI commands like `astro add`, `astro check` |
 | `npm run astro -- --help` | Get help using the Astro CLI                     |
-
-## 👀 Want to learn more?
-
-Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).

+ 11 - 3
astro.config.mjs

@@ -6,6 +6,7 @@ import svelte from '@astrojs/svelte';
 import react from '@astrojs/react';
 import markdoc from '@astrojs/markdoc';
 import keystatic from '@keystatic/astro';
+import node from '@astrojs/node';
 
 // https://astro.build/config
 export default defineConfig({
@@ -17,6 +18,13 @@ export default defineConfig({
     svelte({ extensions: ['.svelte'] }),
     react(),
     markdoc(),
-    keystatic()
-  ]
-});
+    ...(process.env.SKIP_KEYSTATIC ? [] : [keystatic()])
+  ],
+
+  output: 'server',
+  adapter: node({
+    mode: 'standalone',
+  }),
+});
+
+

+ 13 - 0
keystatic.config.ts

@@ -46,5 +46,18 @@ export default config({
         }),
       },
     }),
+    contact: collection({
+      label: 'Contact',
+      slugField: 'title',
+      path: 'src/content/contact/*',
+      format: { contentField: 'content' },
+      schema: {
+        title: fields.slug({ name: { label: 'Title' } }),
+        email: fields.text({ label: "E-Mail" }),
+        content: fields.markdoc({
+          label: 'Content',
+        }),
+      },
+    }),
   },
 });

+ 11 - 0
nginx.conf

@@ -0,0 +1,11 @@
+server {
+    listen 80;
+    server_name localhost;
+
+    root /usr/share/nginx/html;
+    index index.html;
+
+    location / {
+        try_files $uri $uri/ /index.html;
+    }
+}

+ 28 - 0
node.Dockerfile

@@ -0,0 +1,28 @@
+# Use Node.js base image for build stage
+FROM node:20.12.2 AS build
+
+# Set working directory
+WORKDIR /app
+
+# Copy package.json and yarn.lock files
+COPY package.json ./
+
+# Install dependencies using Yarn
+RUN npm i
+
+# Copy the rest of the application code
+COPY . .
+
+ENV SKIP_KEYSTATIC=true
+
+# Build the application
+RUN npm run build
+
+# Expose port 80
+EXPOSE 4321
+
+ENV HOST=0.0.0.0 
+ENV PORT=4321
+
+# Start Nginx server
+CMD ["node", "dist/server/entry.mjs"]

+ 5 - 0
package.json

@@ -9,7 +9,9 @@
     "astro": "astro"
   },
   "dependencies": {
+    "@astrojs/check": "^0.9.4",
     "@astrojs/markdoc": "^0.12.10",
+    "@astrojs/node": "^9.1.2",
     "@astrojs/react": "^4.2.1",
     "@astrojs/svelte": "^7.0.5",
     "@keystatic/astro": "^5.0.6",
@@ -24,5 +26,8 @@
     "svelte": "^5.20.5",
     "tailwindcss": "^4.0.9",
     "typescript": "^5.8.2"
+  },
+  "devDependencies": {
+    "@types/node": "^22.13.9"
   }
 }

文件差異過大導致無法顯示
+ 0 - 0
src/assets/astro.svg


+ 0 - 1
src/assets/background.svg

@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="1024" fill="none"><path fill="url(#a)" fill-rule="evenodd" d="M-217.58 475.75c91.82-72.02 225.52-29.38 341.2-44.74C240 415.56 372.33 315.14 466.77 384.9c102.9 76.02 44.74 246.76 90.31 366.31 29.83 78.24 90.48 136.14 129.48 210.23 57.92 109.99 169.67 208.23 155.9 331.77-13.52 121.26-103.42 264.33-224.23 281.37-141.96 20.03-232.72-220.96-374.06-196.99-151.7 25.73-172.68 330.24-325.85 315.72-128.6-12.2-110.9-230.73-128.15-358.76-12.16-90.14 65.87-176.25 44.1-264.57-26.42-107.2-167.12-163.46-176.72-273.45-10.15-116.29 33.01-248.75 124.87-320.79Z" clip-rule="evenodd" style="opacity:.154"/><path fill="url(#b)" fill-rule="evenodd" d="M1103.43 115.43c146.42-19.45 275.33-155.84 413.5-103.59 188.09 71.13 409 212.64 407.06 413.88-1.94 201.25-259.28 278.6-414.96 405.96-130 106.35-240.24 294.39-405.6 265.3-163.7-28.8-161.93-274.12-284.34-386.66-134.95-124.06-436-101.46-445.82-284.6-9.68-180.38 247.41-246.3 413.54-316.9 101.01-42.93 207.83 21.06 316.62 6.61Z" clip-rule="evenodd" style="opacity:.154"/><defs><linearGradient id="b" x1="373" x2="1995.44" y1="1100" y2="118.03" gradientUnits="userSpaceOnUse"><stop stop-color="#D83333"/><stop offset="1" stop-color="#F041FF"/></linearGradient><linearGradient id="a" x1="107.37" x2="1130.66" y1="1993.35" y2="1026.31" gradientUnits="userSpaceOnUse"><stop stop-color="#3245FF"/><stop offset="1" stop-color="#BC52EE"/></linearGradient></defs></svg>

+ 25 - 28
src/components/About.astro

@@ -1,9 +1,9 @@
 ---
-import { getCollection } from "astro:content";
+import { getCollection, getEntry } from "astro:content";
 import type { AboutEntry } from "../types/about";
 import "../styles/global.css";
 
-const about: AboutEntry[] = await getCollection("about");
+const about: AboutEntry = await getEntry("about", "oliver");
 ---
 
 <div class="grid justify-center">
@@ -11,33 +11,30 @@ const about: AboutEntry[] = await getCollection("about");
         class="max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-blue-700 dark:border-gray-500"
     >
         <div class="p-5">
-            
-            {
-                about.map((element) => (
-                    <a href="#">
-                        <h5
-                            class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"
-                        >
-                            {element.data.name}
-                        </h5>
-                    </a>
-                    <div class="grid auto-cols-max grid-flow-col">
-                        <svg
-                            xmlns="http://www.w3.org/2000/svg"
-                            height="24px"
-                            viewBox="0 -960 960 960"
-                            width="24px"
-                            fill="#e8eaed"
-                        >
-                            <path d="M480-480q33 0 56.5-23.5T560-560q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 33 23.5 56.5T480-480Zm0 294q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Zm0-480Z" />
-                        </svg>
+            <a href="#">
+                <h5
+                    class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"
+                >
+                    {about.data.name}
+                </h5>
+            </a>
+            <div class="grid auto-cols-max grid-flow-col">
+                <svg
+                    xmlns="http://www.w3.org/2000/svg"
+                    height="24px"
+                    viewBox="0 -960 960 960"
+                    width="24px"
+                    fill="#e8eaed"
+                >
+                    <path
+                        d="M480-480q33 0 56.5-23.5T560-560q0-33-23.5-56.5T480-640q-33 0-56.5 23.5T400-560q0 33 23.5 56.5T480-480Zm0 294q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Zm0-480Z"
+                    ></path>
+                </svg>
 
-                        <p class="mb-3 font-normal text-gray-700 dark:text-white">
-                            {element.data.location}
-                        </p>
-                    </div>
-                ))
-            }
+                <p class="mb-3 font-normal text-gray-700 dark:text-white">
+                    {about.data.location}
+                </p>
+            </div>
 
             <p class="mb-3 font-normal text-gray-700 dark:text-white">
                 Interests

+ 10 - 11
src/components/ContactCard.astro

@@ -1,14 +1,15 @@
+---
+import { getCollection, getEntries, getEntry } from "astro:content";
+import type { ContactEntry } from "../types/contact";
+import "../styles/global.css";
+
+const contact: ContactEntry = await getEntry("contact", "about");
+---
+
 <div class="grid justify-center">
     <div
         class="max-w-sm bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-700"
     >
-        <a href="#">
-            <img
-                class="rounded-t-lg"
-                src="/docs/images/blog/image-1.jpg"
-                alt=""
-            />
-        </a>
         <div class="p-5">
             <a href="#">
                 <h5
@@ -19,7 +20,7 @@
             </a>
             <!-- replace email -->
             <a
-                href="mailto:youremail@example.com"
+                href={"mailto:" + contact.data.email}
                 class="flex items-center bg-blue-600 mt-3 hover:bg-blue-700 text-white py-2 px-4 rounded"
                 ><svg
                     xmlns="http://www.w3.org/2000/svg"
@@ -37,8 +38,6 @@
         </div>
 
         <!-- replace qr code -->
-        <img class="h-auto max-w-lg rounded-lg" src="/public/vCard.png" alt="image description">
-
-
+        <img class="h-auto max-w-lg rounded-lg" src="/vCard.png" alt="image description">
     </div>
 </div>

+ 5 - 0
src/content/contact/about.mdoc

@@ -0,0 +1,5 @@
+---
+title: about
+email: oliver.deutsch731@gmail.com
+---
+test

+ 8 - 0
src/content/posts/quick-guide-using-local-documents-with-ll-ms-for-technical-tasks-gpt-4-all-example.mdoc

@@ -0,0 +1,8 @@
+---
+title: >-
+  Quick Guide: Using Local Documents with LLMs for Technical Tasks — GPT4All
+  Example
+link: >-
+  https://medium.com/@zilione/quick-guide-using-local-documents-with-llms-for-technical-tasks-gpt4all-example-abc345c70847
+---
+Have you ever wondered why ChatGPT couldn’t properly analyze your code or fix errors when using a niche library?

+ 0 - 5
src/content/posts/test.mdoc

@@ -1,5 +0,0 @@
----
-title: test
-link: http://localhost:4321/projects
----
-test2

+ 2 - 2
src/layouts/Layout.astro

@@ -1,5 +1,6 @@
 ---
 import "../styles/global.css";
+export const prerender = true;
 ---
 
 <!doctype html>
@@ -7,9 +8,8 @@ import "../styles/global.css";
 	<head>
 		<meta charset="UTF-8" />
 		<meta name="viewport" content="width=device-width" />
-		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
 		<meta name="generator" content={Astro.generator} />
-		<title>Astro Basics</title>
+		<title>About</title>
 	</head>
 	<body class="dark:bg-gray-800">
 		<slot />

+ 2 - 0
src/pages/contact.astro

@@ -2,6 +2,8 @@
 import Layout from "../layouts/Layout.astro";
 import Navbar from "../components/Navbar.astro";
 import ContactCard from "../components/ContactCard.astro";
+
+export const prerender = true;
 ---
 
 <Layout>

+ 2 - 0
src/pages/index.astro

@@ -4,6 +4,8 @@ import ProjectList from '../components/ProjectList.astro';
 import BlogList from '../components/BlogList.astro';
 import About from '../components/About.astro';
 import Navbar from '../components/Navbar.astro';
+
+export const prerender = true;
 ---
 
 <Layout>

+ 14 - 0
src/types/contact.ts

@@ -0,0 +1,14 @@
+export interface ContactEntry {
+    data: {
+      title: string;
+      email: string;
+    };
+    body: string;
+    filePath: string;
+    digest: string;
+    deferredRender: boolean;
+    collection: string;
+    slug: string;
+    render: (render: any) => void;
+  }
+  

部分文件因文件數量過多而無法顯示