aboutsummaryrefslogtreecommitdiff
path: root/apps/website
diff options
context:
space:
mode:
Diffstat (limited to 'apps/website')
-rw-r--r--apps/website/astro.config.ts10
-rw-r--r--apps/website/package.json11
-rw-r--r--apps/website/src/components/base/FormattedDate.astro17
-rw-r--r--apps/website/src/content/blog/first.md16
-rw-r--r--apps/website/src/content/config.ts13
-rw-r--r--apps/website/src/env.d.ts1
-rw-r--r--apps/website/src/layouts/BlogPost.astro36
-rw-r--r--apps/website/src/layouts/Layout.astro4
-rw-r--r--apps/website/src/pages/blog/[...slug].astro25
-rw-r--r--apps/website/src/pages/blog/index.astro30
-rw-r--r--apps/website/src/pages/rss.xml.js16
-rw-r--r--apps/website/src/styles/blog.css37
-rw-r--r--apps/website/src/styles/global.css3
-rw-r--r--apps/website/tailwind.config.ts (renamed from apps/website/tailwind.config.cjs)9
-rw-r--r--apps/website/tsconfig.json5
-rw-r--r--apps/website/vitest.config.ts10
16 files changed, 233 insertions, 10 deletions
diff --git a/apps/website/astro.config.ts b/apps/website/astro.config.ts
index 2e8c40c..4f394a1 100644
--- a/apps/website/astro.config.ts
+++ b/apps/website/astro.config.ts
@@ -1,10 +1,18 @@
import tailwind from '@astrojs/tailwind';
+import mdx from '@astrojs/mdx';
+import sitemap from '@astrojs/sitemap';
+
import { defineConfig } from 'astro/config';
import postcssNesting from 'tailwindcss/nesting';
// https://astro.build/config
export default defineConfig({
- integrations: [tailwind()],
+ site: 'https://polyfrost.org',
+ integrations: [
+ tailwind(),
+ mdx(),
+ sitemap(),
+ ],
vite: {
css: {
postcss: {
diff --git a/apps/website/package.json b/apps/website/package.json
index fe9b603..87d5b95 100644
--- a/apps/website/package.json
+++ b/apps/website/package.json
@@ -6,15 +6,20 @@
"dev": "astro dev",
"start": "astro start",
"build": "astro build",
- "preview": "astro preview"
+ "preview": "astro preview",
+ "test": "vitest"
},
"dependencies": {
+ "@astrojs/mdx": "^1.1.5",
+ "@astrojs/rss": "^3.0.0",
+ "@astrojs/sitemap": "^3.0.3",
"@astrojs/tailwind": "^5.0.2",
"astro": "^3.6.0",
- "tailwindcss": "^3.3.5"
+ "tailwindcss": "^3.3.5",
+ "vitest": "^0.34.6"
},
"devDependencies": {
- "@polyfrost/config": "../../packages/config",
+ "@polyfrost/config": "workspace:*",
"@types/node": "~20.10.0",
"node-html-parser": "^6.1.11",
"typescript": "^5.3.2"
diff --git a/apps/website/src/components/base/FormattedDate.astro b/apps/website/src/components/base/FormattedDate.astro
new file mode 100644
index 0000000..1bcce73
--- /dev/null
+++ b/apps/website/src/components/base/FormattedDate.astro
@@ -0,0 +1,17 @@
+---
+interface Props {
+ date: Date;
+}
+
+const { date } = Astro.props;
+---
+
+<time datetime={date.toISOString()}>
+ {
+ date.toLocaleDateString('en-us', {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ })
+ }
+</time>
diff --git a/apps/website/src/content/blog/first.md b/apps/website/src/content/blog/first.md
new file mode 100644
index 0000000..3066715
--- /dev/null
+++ b/apps/website/src/content/blog/first.md
@@ -0,0 +1,16 @@
+---
+title: 'First post'
+description: 'Lorem ipsum dolor sit amet'
+pubDate: 'Jul 08 2022'
+heroImage: '/blog-placeholder-3.jpg'
+---
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet.
+
+Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendisse in est ante in nibh mauris. Sed tempus urna et pharetra pharetra massa massa ultricies mi.
+
+Mollis nunc sed id semper risus in. Convallis a cras semper auctor neque. Diam sit amet nisl suscipit. Lacus viverra vitae congue eu consequat ac felis donec. Egestas integer eget aliquet nibh praesent tristique magna sit amet. Eget magna fermentum iaculis eu non diam. In vitae turpis massa sed elementum. Tristique et egestas quis ipsum suspendisse ultrices. Eget lorem dolor sed viverra ipsum. Vel turpis nunc eget lorem dolor sed viverra. Posuere ac ut consequat semper viverra nam. Laoreet suspendisse interdum consectetur libero id faucibus. Diam phasellus vestibulum lorem sed risus ultricies tristique. Rhoncus dolor purus non enim praesent elementum facilisis. Ultrices tincidunt arcu non sodales neque. Tempus egestas sed sed risus pretium quam vulputate. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Fringilla urna porttitor rhoncus dolor purus non. Amet dictum sit amet justo donec enim.
+
+Mattis ullamcorper velit sed ullamcorper morbi tincidunt. Tortor posuere ac ut consequat semper viverra. Tellus mauris a diam maecenas sed enim ut sem viverra. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Arcu ac tortor dignissim convallis aenean et tortor at. Curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Egestas tellus rutrum tellus pellentesque eu. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Id donec ultrices tincidunt arcu. Id cursus metus aliquam eleifend mi.
+
+Tempus quam pellentesque nec nam aliquam sem. Risus at ultrices mi tempus imperdiet. Id porta nibh venenatis cras sed felis eget velit. Ipsum a arcu cursus vitae. Facilisis magna etiam tempor orci eu lobortis elementum. Tincidunt dui ut ornare lectus sit. Quisque non tellus orci ac. Blandit libero volutpat sed cras. Nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida. Egestas integer eget aliquet nibh praesent tristique magna.
diff --git a/apps/website/src/content/config.ts b/apps/website/src/content/config.ts
new file mode 100644
index 0000000..8d68c0e
--- /dev/null
+++ b/apps/website/src/content/config.ts
@@ -0,0 +1,13 @@
+import { defineCollection, z } from 'astro:content';
+
+const blog = defineCollection({
+ schema: z.object({
+ title: z.string(),
+ description: z.string(),
+ pubDate: z.coerce.date(),
+ updatedDate: z.coerce.date().optional(),
+ heroImage: z.string().optional(),
+ }),
+});
+
+export const collections = { blog };
diff --git a/apps/website/src/env.d.ts b/apps/website/src/env.d.ts
index f964fe0..acef35f 100644
--- a/apps/website/src/env.d.ts
+++ b/apps/website/src/env.d.ts
@@ -1 +1,2 @@
+/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
diff --git a/apps/website/src/layouts/BlogPost.astro b/apps/website/src/layouts/BlogPost.astro
new file mode 100644
index 0000000..ed2a3c3
--- /dev/null
+++ b/apps/website/src/layouts/BlogPost.astro
@@ -0,0 +1,36 @@
+---
+import type { CollectionEntry } from 'astro:content';
+import Layout from './Layout.astro';
+
+import '@styles/blog.css';
+import FormattedDate from '@components/base/FormattedDate.astro';
+
+type Props = CollectionEntry<'blog'>['data'];
+
+const { title, description, pubDate, updatedDate, heroImage } = Astro.props;
+---
+
+<Layout title={title} description={description}>
+ <article>
+ <div class='hero-image'>
+ {heroImage && <img width={1020} height={510} src={heroImage} alt="Hero Image" />}
+ </div>
+ <div class="prose">
+ <div class="title">
+ <div class="date">
+ <FormattedDate date={pubDate} />
+ {
+ updatedDate && (
+ <div class="last-updated-on">
+ Last updated on <FormattedDate date={updatedDate} />
+ </div>
+ )
+ }
+ </div>
+ <h1>{title}</h1>
+ <hr />
+ </div>
+ <slot />
+ </div>
+ </article>
+</Layout>
diff --git a/apps/website/src/layouts/Layout.astro b/apps/website/src/layouts/Layout.astro
index c4a2ff4..4acc407 100644
--- a/apps/website/src/layouts/Layout.astro
+++ b/apps/website/src/layouts/Layout.astro
@@ -6,11 +6,13 @@ import Favicon from '/media/polyfrost/minimal_bg.svg?url';
interface Props {
title?: string
+ description?: string
favicon?: string
}
const {
title = 'Polyfrost',
+ description = 'Official website for Polyfrost.',
favicon = Favicon,
} = Astro.props;
---
@@ -19,7 +21,7 @@ const {
<html lang="en">
<head>
<meta charset="UTF-8" />
- <meta name="description" content="Official website for Polyfrost." />
+ <meta name="description" content={description} />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href={favicon} />
<meta name="generator" content={Astro.generator} />
diff --git a/apps/website/src/pages/blog/[...slug].astro b/apps/website/src/pages/blog/[...slug].astro
new file mode 100644
index 0000000..d9995e7
--- /dev/null
+++ b/apps/website/src/pages/blog/[...slug].astro
@@ -0,0 +1,25 @@
+---
+// i hate u astro vscode extensi on/j
+/// <reference types="../../env.d.ts" />
+import { type CollectionEntry, getCollection } from 'astro:content';
+import BlogPost from '../../layouts/BlogPost.astro';
+
+export async function getStaticPaths() {
+ const posts = await getCollection('blog');
+ return posts.map(post => ({
+ params: { slug: post.slug },
+ props: post,
+ }));
+}
+
+type Props = CollectionEntry<'blog'>;
+
+const post = Astro.props;
+const { Content } = await post.render();
+---
+
+<BlogPost {...post.data}>
+ <Content />
+</BlogPost>
+
+
diff --git a/apps/website/src/pages/blog/index.astro b/apps/website/src/pages/blog/index.astro
new file mode 100644
index 0000000..c8f8203
--- /dev/null
+++ b/apps/website/src/pages/blog/index.astro
@@ -0,0 +1,30 @@
+---
+/// <reference types="../../env.d.ts" />
+import Layout from '../../layouts/Layout.astro';
+import FormattedDate from '../../components/base/FormattedDate.astro'
+import { getCollection } from 'astro:content';
+
+const posts = (await getCollection('blog')).sort(
+ (a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf()
+);
+---
+
+<Layout title='Polyfrost Blog' description='Recieve Polyfrost updates here'>
+ <section>
+ <ul>
+ {
+ posts.map(post => (
+ <li>
+ <a href={`blog/${post.slug}/`}>
+ <img width={720} height={360} src={post.data.heroImage} alt="" />
+ <h4 class="title">{post.data.title}</h4>
+ <p class="date">
+ <FormattedDate date={post.data.pubDate} />
+ </p>
+ </a>
+ </li>
+ ))
+ }
+ </ul>
+ </section>
+</Layout>
diff --git a/apps/website/src/pages/rss.xml.js b/apps/website/src/pages/rss.xml.js
new file mode 100644
index 0000000..fe05755
--- /dev/null
+++ b/apps/website/src/pages/rss.xml.js
@@ -0,0 +1,16 @@
+import rss from '@astrojs/rss';
+import { getCollection } from 'astro:content';
+
+export async function GET(context) {
+ const posts = await getCollection('blog');
+
+ return rss({
+ title: 'Polyfrost Blog',
+ description: 'Recieve Polyfrost updates here',
+ site: context.site,
+ items: posts.map(post => ({
+ ...post.data,
+ link: `/blog/${post.slug}/`,
+ })),
+ });
+}
diff --git a/apps/website/src/styles/blog.css b/apps/website/src/styles/blog.css
new file mode 100644
index 0000000..9cfe3fa
--- /dev/null
+++ b/apps/website/src/styles/blog.css
@@ -0,0 +1,37 @@
+main {
+ width: calc(100% - 2em);
+ max-width: 100%;
+ margin: 0;
+}
+.hero-image {
+ width: 100%;
+}
+.hero-image img {
+ display: block;
+ margin: 0 auto;
+ border-radius: 12px;
+ box-shadow: var(--box-shadow);
+}
+.prose {
+ width: 720px;
+ max-width: calc(100% - 2em);
+ margin: auto;
+ padding: 1em;
+ color: rgb(var(--gray-dark));
+}
+.title {
+ margin-bottom: 1em;
+ padding: 1em 0;
+ text-align: center;
+ line-height: 1;
+}
+.title h1 {
+ margin: 0 0 0.5em 0;
+}
+.date {
+ margin-bottom: 0.5em;
+ color: rgb(var(--gray));
+}
+.last-updated-on {
+ font-style: italic;
+}
diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css
index e21cf89..8d36787 100644
--- a/apps/website/src/styles/global.css
+++ b/apps/website/src/styles/global.css
@@ -1,4 +1,7 @@
@tailwind base;
+@tailwind components;
+@tailwind utilities;
+@tailwind variants;
* {
font-family: 'Poppins', sans-serif;
diff --git a/apps/website/tailwind.config.cjs b/apps/website/tailwind.config.ts
index 1cfea3a..fa26c99 100644
--- a/apps/website/tailwind.config.cjs
+++ b/apps/website/tailwind.config.ts
@@ -1,5 +1,6 @@
-/** @type {import('tailwindcss').Config} */
-module.exports = {
+import type { Config } from 'tailwindcss';
+
+const config: Config = {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
colors: {
@@ -65,9 +66,11 @@ module.exports = {
'body-lg': '1.063rem', // 17px
},
fontFamily: {
- 'mono': ['"Roboto Mono"', 'monospace'],
+ mono: ['"Roboto Mono"', 'monospace'],
},
extend: {},
},
plugins: [],
};
+
+export default config;
diff --git a/apps/website/tsconfig.json b/apps/website/tsconfig.json
index 4608724..139b7e0 100644
--- a/apps/website/tsconfig.json
+++ b/apps/website/tsconfig.json
@@ -1,7 +1,7 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
- "composite": true,
+ "composite": false,
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
@@ -9,7 +9,8 @@
"@webtypes/*": ["src/types/*"],
"@lib/*": ["src/lib/*"],
"@public/*": ["public/*"],
- "@config": ["config.ts"]
+ "@config": ["config.ts"],
+ "@styles/*": ["src/styles/*"]
}
}
}
diff --git a/apps/website/vitest.config.ts b/apps/website/vitest.config.ts
new file mode 100644
index 0000000..85a3538
--- /dev/null
+++ b/apps/website/vitest.config.ts
@@ -0,0 +1,10 @@
+/// <reference types="vitest" />
+import { getViteConfig } from 'astro/config';
+
+export default getViteConfig({
+ // @ts-expect-error astro moment
+ test: {
+ globals: true,
+ reporters: ['dot'],
+ },
+});