diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0bf17bf --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "tabWidth": 2, + "singleQuote": true, + "semi": false, + "trailingComma": "es5" +} diff --git a/README.md b/README.md deleted file mode 100644 index ff19a3e..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Astro Starter Kit: Basics - -```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) - -## 🚀 Project Structure - -Inside of your Astro project, you'll see the following folders and files: - -```text -/ -├── public/ -│ └── favicon.svg -├── src/ -│ ├── layouts/ -│ │ └── Layout.astro -│ └── pages/ -│ └── index.astro -└── package.json -``` - -To learn more about the folder structure of an Astro project, refer to [our guide on project structure](https://docs.astro.build/en/basics/project-structure/). - -## 🧞 Commands - -All commands are run from the root of the project, from a terminal: - -| Command | Action | -| :------------------------ | :----------------------------------------------- | -| `npm install` | Installs dependencies | -| `npm run dev` | Starts local dev server at `localhost:4321` | -| `npm run build` | Build your production site to `./dist/` | -| `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). diff --git a/astro.config.mjs b/astro.config.mjs index 06c991c..a840024 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,12 +1,14 @@ // @ts-check -import { defineConfig } from 'astro/config'; +import { defineConfig } from 'astro/config' -import tailwind from '@astrojs/tailwind'; +import tailwind from '@astrojs/tailwind' -import icon from 'astro-icon'; +import icon from 'astro-icon' + +import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - integrations: [tailwind(), icon()], - prefetch: true -}); \ No newline at end of file + integrations: [tailwind(), icon(), mdx()], + prefetch: true, +}) \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 53b138a..55ccbbf 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 2d6ee92..6559a2a 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,18 @@ "astro": "astro" }, "dependencies": { + "@astrojs/mdx": "^4.0.2", "@astrojs/tailwind": "^5.1.3", "@iconify-json/material-symbols": "^1.2.10", "astro": "^5.0.5", "astro-icon": "^1.1.4", + "marked": "^15.0.4", + "sanitize-html": "^2.13.1", "tailwindcss": "^3.4.16" }, "devDependencies": { "@tailwindcss/typography": "^0.5.15", + "@types/sanitize-html": "^2.13.0", "daisyui": "^4.12.22" } -} \ No newline at end of file +} diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b02d1a1..7cfd9e3 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -2,6 +2,12 @@ import { Image } from "astro:assets"; import CompanyLogo from "../assets/images/company-logo.png"; + +interface Props { + title?: string; +} + +const { title } = Astro.props; --- @@ -10,7 +16,7 @@ import CompanyLogo from "../assets/images/company-logo.png"; - Solsynth LLC + {title ? `${title} | Solsynth LLC` : "Solsynth LLC"} - + Learn more about Solar Network diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro new file mode 100644 index 0000000..ae60666 --- /dev/null +++ b/src/pages/posts/[...slug].astro @@ -0,0 +1,108 @@ +--- +export const prerender = false + +import sanitizeHtml from 'sanitize-html' +import { Icon } from 'astro-icon/components' +import { marked } from 'marked' + +import Layout from '../../layouts/Layout.astro' +import { getAttachmentUrl, fetchAttachmentMeta } from '../../scripts/attachment' + +const { slug } = Astro.params + +const baseUrl = import.meta.env.PUBLIC_SOLAR_NETWORK_URL +const resp = await fetch(`${baseUrl}/cgi/co/posts/${slug}`) + +if (resp.status !== 200) { + return new Response(null, { status: 404 }) +} + +const data = await resp.json() + +const rawContent = await marked(data.body.content as string, { + breaks: data.type == 'story', +}) +const content = sanitizeHtml(rawContent) + +const attachments = await fetchAttachmentMeta(data.body.attachments) +--- + + + + +
+
+
+
+ avatar +
+
+
+ + {data.publisher.nick} + @{data.publisher.name} + + {data.publisher.description} +
+
+ + { + data.repost_id && ( + + ) + } + +
+ + { + attachments && ( +
+ {attachments.map((attachment) => ( +
+ + {attachment.alt} + +
+ ))} +
+ ) + } +
+
diff --git a/src/pages/products/solar-network.astro b/src/pages/products/solar-network.astro new file mode 100644 index 0000000..642e6f9 --- /dev/null +++ b/src/pages/products/solar-network.astro @@ -0,0 +1,7 @@ +--- +import Layout from "../../layouts/Layout.astro"; +--- + + + + \ No newline at end of file diff --git a/src/scripts/attachment.ts b/src/scripts/attachment.ts new file mode 100644 index 0000000..9d3d255 --- /dev/null +++ b/src/scripts/attachment.ts @@ -0,0 +1,23 @@ +export function getAttachmentUrl(identifier: string): string { + if (identifier.startsWith('http')) { + return identifier + } + const baseUrl = import.meta.env.PUBLIC_SOLAR_NETWORK_URL + return `${baseUrl}/cgi/uc/attachments/${identifier}` +} + +export async function fetchAttachmentMeta( + identifiers: string[] +): Promise { + if (!identifiers) return [] + + const baseUrl = import.meta.env.PUBLIC_SOLAR_NETWORK_URL + const resp = await fetch( + `${baseUrl}/cgi/uc/attachments?take=${identifiers.length}&id=${identifiers.join(',')}` + ) + if (resp.status !== 200) { + throw new Error(`Failed to fetch attachment meta: ${await resp.text()}`) + } + const out = await resp.json() + return out['data'] +} diff --git a/tailwind.config.mjs b/tailwind.config.mjs index 302834c..1176c3b 100644 --- a/tailwind.config.mjs +++ b/tailwind.config.mjs @@ -1,38 +1,38 @@ /** @type {import('tailwindcss').Config} */ export default { - content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"], + content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], theme: { extend: {}, }, - plugins: [require("@tailwindcss/typography"), require("daisyui")], + plugins: [require('@tailwindcss/typography'), require('daisyui')], daisyui: { themes: [ { - dark: { - primary: "#3f51b5", - secondary: "#4ba6ee", - accent: "#03a9f4", - neutral: "#1f2937", - "base-100": "#000011", - info: "#4994ec", - success: "#67ad5b", - warning: "#f5c344", - error: "#e15241", + light: { + primary: '#3f51b5', + secondary: '#4ba6ee', + accent: '#03a9f4', + neutral: '#4b5563', + 'base-100': '#ffffff', + info: '#4994ec', + success: '#67ad5b', + warning: '#f5c344', + error: '#e15241', }, }, { - light: { - primary: "#3f51b5", - secondary: "#4ba6ee", - accent: "#03a9f4", - neutral: "#4b5563", - "base-100": "#ffffff", - info: "#4994ec", - success: "#67ad5b", - warning: "#f5c344", - error: "#e15241", + dark: { + primary: '#3f51b5', + secondary: '#4ba6ee', + accent: '#03a9f4', + neutral: '#1f2937', + 'base-100': '#000011', + info: '#4994ec', + success: '#67ad5b', + warning: '#f5c344', + error: '#e15241', }, }, ], }, -}; +}