This commit is contained in:
2025-10-27 01:40:38 +08:00
parent 896390e8eb
commit 0f04bbe1f9
57 changed files with 7576 additions and 870 deletions

View File

@@ -0,0 +1,9 @@
---
import Html from '@/components/html.astro';
---
<Html>
<main>
</main>
</Html>

View File

@@ -0,0 +1,23 @@
---
import { getCollection, render } from 'astro:content';
import Main from '@/layouts/mdx.astro';
// 1. 为每个集合条目生成一个新路径
export async function getStaticPaths() {
const posts = await getCollection('docs');
return posts.map((post) => ({
params: { id: post.id },
props: { post },
}));
}
type Post = {
data: { title: string };
};
// 2. 对于你的模板,你可以直接从 prop 获取条目
const { post } = Astro.props as { post: Post };
const { Content } = await render(post);
---
<Main>
<!-- <h1 slot={'header'}>{post.data.title}</h1> -->
<Content />
</Main>

View File

@@ -0,0 +1,23 @@
---
import { getCollection } from 'astro:content';
const posts = await getCollection('docs');
console.log('post', posts);
import { basename } from '@/modules/basename';
import Blank from '@/layouts/blank.astro';
---
<Blank>
<main class='max-w-3xl mx-auto'>
<h1>My posts</h1>
<ul class='p-2 m-2'>
{
posts.map((post) => (
<li>
{/* <a href={`${basename}/demo/${post.id}`}>{post.data.title}</a> */}
<a href={`/docs/${post.id}/`}>{post.data.title}</a>
</li>
))
}
</ul>
</main>
</Blank>

46
src/pages/index.astro Normal file
View File

@@ -0,0 +1,46 @@
---
console.log('Hello from index.astro');
import '../styles/global.css';
---
<html lang='en'>
<head>
<title>Home</title>
</head>
<body>
<h1 onclick="{onClick}">Welcome to my website!</h1>
<div class='bg-amber-50 w-20 h-20 rounded-full'></div>
<div id='root'></div>
<script type='importmap' data-vite-ignore is:inline>
{
"imports": {
"react": "https://esm.sh/react@19.1.0",
"react-dom": "https://esm.sh/react-dom@19.1.0/client.js",
"react-toastify": "https://esm.sh/react-toastify@11.0.5"
}
}
</script>
<script type='module' data-vite-ignore is:inline>
import { Button, message } from 'https://esm.sh/antd?standalone';
import React from 'react';
import { ToastContainer, toast } from 'react-toastify';
import { createRoot } from 'react-dom';
setTimeout(() => {
toast.loading('Hello from index.astro');
window.toast = toast;
console.log('message', toast);
}, 1000);
console.log('Hello from index.astro', Button);
const root = document.getElementById('root');
const render = createRoot(root);
const App = () => {
const button = React.createElement(Button, null, 'Hello');
const messageEl = React.createElement(ToastContainer, null, 'Hello');
const wrapperMessage = React.createElement('div', null, [button, messageEl]);
return wrapperMessage;
};
// render.render(React.createElement(Button, null, 'Hello'), root);
render.render(App(), root);
</script>
</body>
</html>