init repository
This commit is contained in:
6
src/config/content.ts
Normal file
6
src/config/content.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export const collectionNames = ["website"] as const;
|
||||
export type SiteCollection = (typeof collectionNames)[number];
|
||||
|
||||
export function isSiteCollection(value: string): value is SiteCollection {
|
||||
return collectionNames.includes(value as SiteCollection);
|
||||
}
|
||||
17
src/content.config.ts
Normal file
17
src/content.config.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineCollection } from "astro/content/config";
|
||||
import { glob } from "astro/loaders";
|
||||
import { z } from "astro/zod";
|
||||
|
||||
const articleSchema = z.object({
|
||||
title: z.string(),
|
||||
description: z.string()
|
||||
});
|
||||
|
||||
const website = defineCollection({
|
||||
loader: glob({ base: './src/content/website', pattern: '**/*.{md,mdx}' }),
|
||||
schema: articleSchema
|
||||
});
|
||||
|
||||
export const collections = {
|
||||
website
|
||||
};
|
||||
10
src/content/website/index.mdx
Normal file
10
src/content/website/index.mdx
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
title: Website
|
||||
description: Learn about the Radium website
|
||||
---
|
||||
# Website
|
||||
The Radium website is the central hub for all things Radium. It includes the following sections:
|
||||
- [Home](https://radium.live/): The main landing page for Radium, where you can learn about the project and its features.
|
||||
- [Documentation](https://docs.radium.live/): The official documentation for Radium, which includes guides, API references, and tutorials.
|
||||
- [Community Forum](https://forum.radium.live/): A place to ask questions, share ideas, and connect with other Radium users.
|
||||
- [Blog](https://blog.radium.live/): A collection of articles and updates about Radium, including release notes, feature announcements, and community highlights.
|
||||
9
src/content/website/registration.mdx
Normal file
9
src/content/website/registration.mdx
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: Registration
|
||||
description: Learn how to register for Radium
|
||||
---
|
||||
# Registration
|
||||
To register for Radium, follow these steps:
|
||||
1. Go to the [Radium website](https://radium.live/).
|
||||
2. Click on the "Sign Up" button in the top right corner of the homepage.
|
||||
3. Fill out the registration form with your email address, username, and password.
|
||||
35
src/pages/[collection]/[...slug].astro
Normal file
35
src/pages/[collection]/[...slug].astro
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
import { getCollection, render } from "astro:content";
|
||||
import { collectionNames, isSiteCollection } from "../../config/content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const paths = [];
|
||||
|
||||
for (const collection of collectionNames) {
|
||||
const entries = await getCollection(collection);
|
||||
|
||||
for (const entry of entries) {
|
||||
paths.push({
|
||||
params: {
|
||||
collection,
|
||||
slug: entry.id === "index" ? undefined : entry.id,
|
||||
},
|
||||
props: { collection, entry },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
const { collection } = Astro.params;
|
||||
|
||||
if (!collection || !isSiteCollection(collection)) {
|
||||
throw new Error("Invalid collection");
|
||||
}
|
||||
|
||||
const { entry } = Astro.props;
|
||||
const { Content } = await render(entry);
|
||||
---
|
||||
|
||||
<Content />
|
||||
43
src/pages/index.astro
Normal file
43
src/pages/index.astro
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import { collectionNames } from "../config/content";
|
||||
|
||||
const sections = await Promise.all(
|
||||
collectionNames.map(async (name) => {
|
||||
const entries = (await getCollection(name)).sort((a, b) =>
|
||||
a.data.title.localeCompare(b.data.title)
|
||||
);
|
||||
|
||||
const indexEntry = entries.find((entry) => entry.id === "index");
|
||||
const articles = entries.filter((entry) => entry.id !== "index");
|
||||
|
||||
return {
|
||||
name,
|
||||
indexEntry,
|
||||
articles,
|
||||
};
|
||||
})
|
||||
);
|
||||
---
|
||||
|
||||
<ul>
|
||||
{sections.map((section) => (
|
||||
<li>
|
||||
{section.indexEntry ? (
|
||||
<a href={`/${section.name}`}>{section.indexEntry.data.title}</a>
|
||||
) : (
|
||||
section.name
|
||||
)}
|
||||
|
||||
{section.articles.length > 0 && (
|
||||
<ul>
|
||||
{section.articles.map((entry) => (
|
||||
<li>
|
||||
<a href={`/${section.name}/${entry.id}`}>{entry.data.title}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
1
src/styles/global.css
Normal file
1
src/styles/global.css
Normal file
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
Reference in New Issue
Block a user