diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 25bf17fc..00000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18 \ No newline at end of file diff --git a/astro.config.mjs b/astro.config.mjs index 4890b6f0..0123017f 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,4 +1,8 @@ -import { defineConfig } from 'astro/config' +import { defineConfig } from 'astro/config'; + +import react from "@astrojs/react"; // https://astro.build/config -export default defineConfig({}) +export default defineConfig({ + integrations: [react()] +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5162535c..09afa886 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,7 +73,7 @@ "typescript-plugin-css-modules": "^5.0.1" }, "engines": { - "node": "18" + "node": ">=16" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 5b801786..97f96ce7 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "typescript-plugin-css-modules": "^5.0.1" }, "engines": { - "node": "18" + "node": ">=16" }, "repository": { "type": "git", diff --git a/src/content/config.ts b/src/content/config.ts new file mode 100644 index 00000000..ec98904b --- /dev/null +++ b/src/content/config.ts @@ -0,0 +1,22 @@ +import { defineCollection, z } from 'astro:content' + +const articles = defineCollection({ + type: 'content', // v2.5.0 and later + // Type-check frontmatter using a schema + schema: z.object({ + title: z.string(), + description: z.string(), + // Transform string to Date object + date: z + .string() + .or(z.date()) + .transform((val) => new Date(val)), + updated: z + .string() + .optional() + .transform((str) => (str ? new Date(str) : undefined)), + image: z.string().optional() + }) +}) + +export const collections = { articles } diff --git a/src/pages/404.tsx b/src/pages/404/404.tsx similarity index 84% rename from src/pages/404.tsx rename to src/pages/404/404.tsx index 492eae56..779556dd 100644 --- a/src/pages/404.tsx +++ b/src/pages/404/404.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from 'react' import { Link, PageProps } from 'gatsby' -import HeadMeta, { HeadMetaProps } from '../components/atoms/HeadMeta' -import Page from '../components/templates/Page' +import HeadMeta, { HeadMetaProps } from '../../components/atoms/HeadMeta' +import Page from '../../components/templates/Page' import * as styles from './404.module.css' const meta: Partial = { diff --git a/src/pages/404.module.css b/src/pages/404/_404.module.css similarity index 100% rename from src/pages/404.module.css rename to src/pages/404/_404.module.css diff --git a/src/pages/404/index.astro b/src/pages/404/index.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro new file mode 100644 index 00000000..a20cd712 --- /dev/null +++ b/src/pages/[...slug].astro @@ -0,0 +1,18 @@ +--- +import { getCollection } from 'astro:content'; + +// 1. Generate a new path for every collection entry +export async function getStaticPaths() { + const articles = await getCollection('articles'); + return articles.map(entry => ({ + params: { slug: entry.slug }, props: { entry }, + })); +} + +// 2. For your template, you can get the entry directly from the prop +const { entry } = Astro.props; +const { Content } = await entry.render(); +--- + +

{entry.data.title}

+ \ No newline at end of file diff --git a/src/pages/__tests__/404.test.tsx b/src/pages/__tests__/404.test.tsx index 76abce49..3b9d2dc7 100644 --- a/src/pages/__tests__/404.test.tsx +++ b/src/pages/__tests__/404.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import { render } from '@testing-library/react' -import NotFound from '../404' +import NotFound from '../404/404' describe('/404', () => { it('renders without crashing', () => { diff --git a/src/pages/__tests__/tags.test.tsx b/src/pages/__tests__/tags.test.tsx index ba96d768..1878146f 100644 --- a/src/pages/__tests__/tags.test.tsx +++ b/src/pages/__tests__/tags.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import { render } from '@testing-library/react' -import Tags from '../tags' +import Tags from '../tags/tags' describe('/tags', () => { const data = { diff --git a/src/pages/archive.astro b/src/pages/archive.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/photos/index.astro b/src/pages/photos/index.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/tags.module.css b/src/pages/tags/_tags.module.css similarity index 100% rename from src/pages/tags.module.css rename to src/pages/tags/_tags.module.css diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/tags.tsx b/src/pages/tags/tags.tsx similarity index 87% rename from src/pages/tags.tsx rename to src/pages/tags/tags.tsx index 9be2b256..84b05902 100644 --- a/src/pages/tags.tsx +++ b/src/pages/tags/tags.tsx @@ -1,8 +1,8 @@ import React, { ReactElement } from 'react' import { PageProps, graphql } from 'gatsby' -import HeadMeta, { HeadMetaProps } from '../components/atoms/HeadMeta' -import Tag from '../components/atoms/Tag' -import Page from '../components/templates/Page' +import HeadMeta, { HeadMetaProps } from '../../components/atoms/HeadMeta' +import Tag from '../../components/atoms/Tag' +import Page from '../../components/templates/Page' import * as styles from './tags.module.css' const meta: Partial = { diff --git a/src/pages/thanks.module.css b/src/pages/thanks/_thanks.module.css similarity index 100% rename from src/pages/thanks.module.css rename to src/pages/thanks/_thanks.module.css diff --git a/src/pages/thanks/index.astro b/src/pages/thanks/index.astro new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/thanks.tsx b/src/pages/thanks/thanks.tsx similarity index 85% rename from src/pages/thanks.tsx rename to src/pages/thanks/thanks.tsx index 16710cac..c2a133a2 100644 --- a/src/pages/thanks.tsx +++ b/src/pages/thanks/thanks.tsx @@ -2,11 +2,11 @@ import React, { ReactElement } from 'react' import { HeadProps } from 'gatsby' import { WagmiConfig } from 'wagmi' import { RainbowKitProvider } from '@rainbow-me/rainbowkit' -import { chains, theme, wagmiConfig } from '../helpers/rainbowkit' -import Copy from '../components/atoms/Copy' -import Meta, { HeadMetaProps } from '../components/atoms/HeadMeta' -import Icon from '../components/atoms/Icon' -import { useSiteMetadata } from '../hooks/useSiteMetadata' +import { chains, theme, wagmiConfig } from '../../helpers/rainbowkit' +import Copy from '../../components/atoms/Copy' +import Meta, { HeadMetaProps } from '../../components/atoms/HeadMeta' +import Icon from '../../components/atoms/Icon' +import { useSiteMetadata } from '../../hooks/useSiteMetadata' import * as styles from './thanks.module.css' const meta: Partial = { @@ -14,7 +14,7 @@ const meta: Partial = { } const Web3Donation = React.lazy( - () => import('../components/molecules/Web3Donation') + () => import('../../components/molecules/Web3Donation') ) function Coin({ address, title }: { address: string; title: string }) { diff --git a/tsconfig.json b/tsconfig.json index 8a1124d3..75ce86a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,13 @@ { "extends": "astro/tsconfigs/strict", "compilerOptions": { - "jsx": "react", - "plugins": [{ "name": "typescript-plugin-css-modules" }] + "jsx": "react-jsx", + "plugins": [ + { + "name": "typescript-plugin-css-modules" + } + ], + "jsxImportSource": "react" }, "exclude": ["node_modules", "public", "dist", "*.js"], "include": ["./*.ts", "./src/**/*", "./scripts/*.ts", "./.jest/**/*"]