diff --git a/README.md b/README.md index ca395c7..15483a6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,64 @@ # astrowind -Vercel's [AstroWind](https://github.com/arthelokyo/astrowind) template — an -Astro + Tailwind CSS marketing site and blog — on **Cloudflare Workers + -Static Assets**, deployed by [Orun](https://github.com/sourceplane/orun) to -stage and prod on every merge, and then packaged as an Orun baseline. - -This commit is the repository's frame: `intent.yaml` (with the placeholder -workspace `ws_CHANGE_ME`, so CI plans nothing until it is linked), the Orun -CI workflow, the shared TypeScript and ESLint configuration, and the spec -index. The work is tracked as an epic under [`specs/epics`](specs/epics/README.md). +Vercel's [AstroWind](https://github.com/arthelokyo/astrowind) template — a +free Astro + Tailwind CSS marketing site and blog: a home page, about, +pricing, services and contact pages, six landing-page and four home-page +demos, and a Markdown/MDX blog with categories, tags, an RSS feed and a +sitemap — running on **Cloudflare Workers + Static Assets**, deployed by +[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge. +Packaging it as an Orun baseline is the next milestone (AW2). + +AstroWind builds fully static, and its own README deploys it to Cloudflare +Workers as static assets with no adapter; that is the port. `astro build` +writes every page, post, feed, sitemap and optimised image to `dist/`, and +one small Worker sits in front of the assets for what matches no file. The +pages, the widgets, the blog and the theme do not change; the site's name +moves into one module, and `vercel.json`'s clean URLs and cache header +become the Worker's asset settings and `public/_headers`. See [`specs/epics/astrowind`](specs/epics/astrowind/README.md) for the +design, the milestones and the as-built status. + +## What is here (the site) + +| Surface | Where | +|---|---| +| The site's name (the header's logo text, every page's title template) | `apps/web/src/site.ts` | +| Site URL, metadata, blog options, analytics | `apps/web/src/config.yaml` | +| Pages, landing and home demos | `apps/web/src/pages` | +| Blog posts | `apps/web/src/data/post` | +| Widgets, layouts, theme | `apps/web/src/components`, `apps/web/src/layouts`, `apps/web/vendor/integration` | +| The Worker in front of the assets, its config, deploy contract | `apps/web/worker/index.ts`, `apps/web/wrangler.jsonc`, `apps/web/public/_headers`, `apps/web/component.yaml` | +| Tests (Astro container API, the Worker) | `apps/web/src/test` | + +## Getting started + +```bash +pnpm install +pnpm typecheck # astro check +pnpm lint # eslint +pnpm test # vitest over the container API +pnpm build # astro build → apps/web/dist +``` + +```bash +pnpm --filter @app/web dev # http://localhost:4321 +pnpm --filter @app/web preview # wrangler dev over the built site and its Worker +``` + +## How it maps to Vercel + +| Vercel | Here | +|---|---| +| Static output (`dist/`) on Vercel's CDN | Workers Static Assets: `dist/` uploaded with the Worker `-web-` (`apps/web/wrangler.jsonc`) | +| `vercel.json` `cleanUrls` + `trailingSlash: false` | `assets.html_handling: drop-trailing-slash` — `/about` serves `about/index.html`, `/about/` redirects to it | +| `vercel.json` `/_astro/*` immutable `Cache-Control` | `public/_headers`, which the assets upload honours | +| Vercel's 404 for an unknown path | the Worker hands it to the assets, which answer `dist/404.html` with a 404 (`not_found_handling: 404-page`) | +| Image optimisation | Unchanged: `astro build` optimises local images with sharp, and remote ones go through Unpic to their CDN | +| `site: https://astrowind.vercel.app` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — so canonical links, the sitemap and the RSS feed name the site where it is served; `src/config.yaml`'s `site:` is a local build's | +| Deploy on push | Orun deploys `-web-{stage,prod}` on merge to `main` (`apps/web/component.yaml`) | +| "Deploy with Vercel" (clone the template) | `orun new --blueprint repo-blueprint.yaml` — a new repository, branded, deployed | + +## CI + +| Workflow | What it runs | Ships to a site | +|---|---|---| +| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment — they do not type-check, lint or run the tests; `baseline.yml`'s e2e tier runs those before each tag, and a site's README asks its developers to run them before a push), except the bootstrap's own landings (`orun/BASE-*`), which are checked in the box before they are pushed (`checks: local`) and whose PR runs `plan` alone; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes | diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..7d1034e --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,3 @@ +# AstroWind reads no environment variable: its site URL, metadata, blog and +# analytics options (Google Analytics id, partytown) are src/config.yaml, and +# its name is src/site.ts. A variable a later change adds is listed here. diff --git a/apps/web/.prettierignore b/apps/web/.prettierignore new file mode 100644 index 0000000..76b517c --- /dev/null +++ b/apps/web/.prettierignore @@ -0,0 +1,4 @@ +dist +node_modules +.github +.changeset \ No newline at end of file diff --git a/apps/web/.prettierrc.mjs b/apps/web/.prettierrc.mjs new file mode 100644 index 0000000..0a7b940 --- /dev/null +++ b/apps/web/.prettierrc.mjs @@ -0,0 +1,13 @@ +/** @type {import('prettier').Config} */ +export default { + printWidth: 120, + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'es5', + useTabs: false, + + plugins: ['prettier-plugin-astro'], + + overrides: [{ files: '*.astro', options: { parser: 'astro' } }], +}; diff --git a/apps/web/LICENSE.md b/apps/web/LICENSE.md new file mode 100644 index 0000000..fa4db58 --- /dev/null +++ b/apps/web/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 onWidget + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/apps/web/README.md b/apps/web/README.md new file mode 100644 index 0000000..fbc1bd8 --- /dev/null +++ b/apps/web/README.md @@ -0,0 +1,31 @@ +# apps/web — the site + +An [AstroWind](https://github.com/arthelokyo/astrowind) site (MIT) — Astro 7 +and Tailwind CSS 4 — built fully static and served as Cloudflare Workers +Static Assets: + +- `/`, `/about`, `/pricing`, `/services`, `/contact`, `/terms`, `/privacy` +- `/homes/*` (SaaS, startup, mobile app, personal) and `/landing/*` (six + landing-page demos) +- the blog: `/blog`, a page per post (`src/data/post/*.md|mdx`), + `/category/*`, `/tag/*`, `/rss.xml`; `/sitemap-index.xml`, `/robots.txt` + +The site's name — the header's logo text and every page's title template — is +`src/site.ts`. Its URL, metadata, blog options and analytics are +`src/config.yaml`; header and footer links are `src/navigation.ts`; colours +and fonts are `src/components/CustomStyles.astro` and `astro.config.ts`. + +```bash +pnpm dev # astro dev on http://localhost:4321 +pnpm test # vitest over Astro's container API (src/test) +pnpm build # astro build → dist/ +pnpm preview # wrangler dev over dist/ and the Worker +``` + +`wrangler.jsonc` is what deploys: the Worker (`worker/index.ts`) and `dist/` +as its assets. A request that matches a file is served from the assets; one +that does not reaches the Worker, which hands it back to the assets for the +site's 404 page. `public/_headers` sets the immutable cache on `/_astro/*`. + +How it is deployed — per environment, on merge to `main` — is the +repository's README and `component.yaml` beside this file. diff --git a/apps/web/astro.config.ts b/apps/web/astro.config.ts new file mode 100644 index 0000000..bd5aff7 --- /dev/null +++ b/apps/web/astro.config.ts @@ -0,0 +1,140 @@ +import path from 'path'; +import { fileURLToPath } from 'url'; + +import { defineConfig, fontProviders } from 'astro/config'; + +import { unified } from '@astrojs/markdown-remark'; + +import sitemap from '@astrojs/sitemap'; +import tailwindcss from '@tailwindcss/vite'; +import mdx from '@astrojs/mdx'; +import partytown from '@astrojs/partytown'; +import icon from 'astro-icon'; +import compress from 'astro-compress'; +import type { AstroIntegration } from 'astro'; + +import theme from './vendor/integration'; + +import { readingTimeRemarkPlugin, responsiveTablesRehypePlugin } from './src/utils/frontmatter'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +const hasExternalScripts = false; +const whenExternalScripts = (items: (() => AstroIntegration) | (() => AstroIntegration)[] = []) => + hasExternalScripts ? (Array.isArray(items) ? items.map((item) => item()) : [items()]) : []; + +export default defineConfig({ + output: 'static', + + // Prefetch links as they enter the viewport for snappier navigations + // (works together with , which enables prefetch by default). + prefetch: { + prefetchAll: true, + defaultStrategy: 'viewport', + }, + + // Native Fonts API: self-hosts + subsets + preloads Inter and generates + // metric-adjusted fallbacks. Injected via in Layout.astro and + // consumed through the `--font-inter` CSS variable in CustomStyles.astro. + fonts: [ + { + provider: fontProviders.fontsource(), + name: 'Inter', + cssVariable: '--font-inter', + weights: ['100 900'], + styles: ['normal'], + subsets: ['latin'], + fallbacks: ['sans-serif'], + }, + ], + + integrations: [ + sitemap(), + mdx(), + icon({ + // Local SVG icons (used as ) live next to the other assets. + iconDir: 'src/assets/icons', + include: { + tabler: ['*'], + 'flat-color-icons': [ + 'template', + 'gallery', + 'approval', + 'document', + 'advertising', + 'currency-exchange', + 'voice-presentation', + 'business-contact', + 'database', + ], + }, + }), + + ...whenExternalScripts(() => + partytown({ + config: { forward: ['dataLayer.push'] }, + }) + ), + + compress({ + // csso off on purpose: its parser doesn't understand the media range + // syntax Tailwind v4 emits for breakpoints (`@media (width>=48rem)`) and + // silently drops every one of those blocks — the site then renders as if + // all `md:`/`lg:` classes were missing. lightningcss parses it correctly. + CSS: { csso: false, lightningcss: { minify: true } }, + HTML: { + 'html-minifier-terser': { + removeAttributeQuotes: false, + }, + }, + Image: false, + JavaScript: true, + SVG: false, + Logger: 1, + }), + + theme({ + config: './src/config.yaml', + }), + ], + + image: { + // Astro's default Sharp service handles local images. + // + // Most remote CDN images (Unsplash, Cloudinary, Imgix…) are routed by + // src/components/common/Image.astro through `unpic`, which rewrites the + // URL with CDN-side query parameters and serves it straight from the + // provider — Astro never downloads it, so they don't need to be listed. + // + // `domains` only matters for remote URLs that fall through to Astro's + // native (i.e. providers Unpic can't detect, like Pixabay). + // Listed entries are authorized to be processed by Sharp. + // Unsplash is listed so post covers can be rendered as real 1200×626 Open Graph images. + domains: ['cdn.pixabay.com', 'images.unsplash.com'], + + // Emit responsive styles for the native used by + // src/components/common/Image.astro (local images). Utility classes on + // each usage still win, since these styles use low-specificity selectors. + responsiveStyles: true, + }, + + markdown: { + processor: unified({ + remarkPlugins: [readingTimeRemarkPlugin], + rehypePlugins: [responsiveTablesRehypePlugin], + }), + shikiConfig: { + // Code blocks follow the site theme; see the `.astro-code` rules in tailwind.css. + themes: { light: 'github-light', dark: 'github-dark' }, + }, + }, + + vite: { + plugins: [tailwindcss()], + resolve: { + alias: { + '~': path.resolve(__dirname, './src'), + }, + }, + }, +}); diff --git a/apps/web/component.yaml b/apps/web/component.yaml new file mode 100644 index 0000000..cb4f066 --- /dev/null +++ b/apps/web/component.yaml @@ -0,0 +1,89 @@ +apiVersion: sourceplane.io/v1 +kind: Component +metadata: + name: web + description: The AstroWind site (a static Astro + Tailwind CSS build on Cloudflare Workers + Static Assets, per environment) +spec: + type: cloudflare-workers-assets-turbo + lifecycle: production + owner: platform + # Its pages, attached to it in the workspace's catalog: what the Docs + # library shows for it, and what the catalog's docs and runbook checks read. + # Generated from what this manifest and its sources declare. + docs: + overview: docs/overview.md + pages: + - { path: docs/architecture.md, role: architecture, title: Architecture } + - { path: docs/runbook.md, role: runbook, title: Runbook } + # `app`, not `web`: a domain and a component share one name space in the + # catalog, and a domain called `web` hid this component from it. + domain: app + path: apps/web + # Its own lane per environment: the site's build is the longest job in the + # plan, and a shared lane would wait on it. + lane: isolated + subscribe: + environments: + - name: dev + profile: verify + - name: stage + profile: verify + profileRules: + - profile: deploy + when: + triggerRef: github-push-main + - name: prod + profile: verify + profileRules: + - profile: deploy + when: + triggerRef: github-push-main + parameters: + nodeVersion: "22" + pnpmVersion: "10.12.1" + + workspaceDir: ../.. + appDir: . + + turboFilter: "@app/web" + # The config the dry run and the deploy hand to wrangler: the Worker + # (worker/index.ts) and the static build in dist/ as its assets. + # AstroWind builds fully static, so there is no adapter and no generated + # config — this committed file is the one wrangler deploys. + wranglerConfig: wrangler.jsonc + + # `astro build` (output: 'static') writes every page, feed, sitemap and + # optimised image to dist/. The Worker is a source file wrangler bundles + # at deploy; the lane checks it exists after the build like any entry. + workerEntrypoint: worker/index.ts + assetsDir: dist + + # Per-env worker name: astrowind-web-{dev,stage,prod}. + workerName: astrowind-web + environmentAwareWorkerName: true + + # The account's workers.dev subdomain; exported to the smoke step as + # ${WORKERS_DEV_SUBDOMAIN} and used to build ${DEPLOYED_URL}. + workersDevSubdomain: your-workers-subdomain + + installCommand: pnpm install --frozen-lockfile + # The site's public origin (canonical links, the sitemap and the RSS feed + # are absolute): the environment's SITE_URL when intent.yaml sets one (a + # custom domain), else its workers.dev URL. The subdomain is written out + # rather than read from ${WORKERS_DEV_SUBDOMAIN}, which the composition + # exports to the smoke step only. ${ORUN_ENVIRONMENT} the runner sets for + # every step. The theme's config builder reads PUBLIC_SITE_URL over + # src/config.yaml's `site:`. + buildCommand: PUBLIC_SITE_URL="${SITE_URL:-https://astrowind-web-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" pnpm exec turbo run build --filter=@app/web + + # Smoke: the home page carries the template's hero ("Free template for"), + # the blog index lists posts, and an unknown path answers the site's own + # 404 page with a 404 status (served by the assets through the Worker). + # Each response is buffered before grep so an early match cannot SIGPIPE + # curl. + smokeCommand: "html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'Free template for' && blog=$(curl -sfL \"${DEPLOYED_URL}/blog\") && echo \"${blog}\" | grep -q '/get-started-website-with-astro-tailwind-css' && test \"$(curl -s -o /dev/null -w '%{http_code}' \"${DEPLOYED_URL}/no-such-page\")\" = 404" + labels: + team: platform + layer: delivery + surface: web + runtime: cloudflare diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..14115db --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,16 @@ +# web — architecture + +Built by the turbo pipeline from `apps/web` and deployed with wrangler. + +| | | +| ------------------- | ----------------------------------------------- | +| Worker config | `apps/web/wrangler.jsonc` | +| Entry | `./worker/index.ts` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | + +## Bindings + +| Binding | Kind | Source | +| -------- | ------------- | -------- | +| `ASSETS` | Static assets | `./dist` | diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..04847d7 --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,20 @@ +# web + +The AstroWind site (a static Astro + Tailwind CSS build on Cloudflare Workers + Static Assets, per environment) + +A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. + +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | +| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..7e65d98 --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,38 @@ +# web — runbook + +## How it runs + +Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web dev +pnpm --filter @app/web build +pnpm --filter @app/web test +pnpm --filter @app/web typecheck +pnpm --filter @app/web lint +pnpm --filter @app/web preview +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -q 'Free template for' && blog=$(curl -sfL "${DEPLOYED_URL}/blog") && echo "${blog}" | grep -q '/get-started-website-with-astro-tailwind-css' && test "$(curl -s -o /dev/null -w '%{http_code}' "${DEPLOYED_URL}/no-such-page")" = 404 +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **The smoke fails right after a first deploy**: a new workers.dev route can + answer 4xx for a few seconds and the lane retries. A failure that persists + is a regression in the deployed code. diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js new file mode 100644 index 0000000..6499427 --- /dev/null +++ b/apps/web/eslint.config.js @@ -0,0 +1,66 @@ +import * as astroEslintParser from 'astro-eslint-parser'; +import eslintPluginAstro from 'eslint-plugin-astro'; +import globals from 'globals'; +import js from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import typescriptParser from '@typescript-eslint/parser'; + +export default [ + js.configs.recommended, + ...eslintPluginAstro.configs['flat/recommended'], + ...tseslint.configs.recommended, + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, + }, + { + files: ['**/*.astro'], + languageOptions: { + parser: astroEslintParser, + parserOptions: { + parser: '@typescript-eslint/parser', + extraFileExtensions: ['.astro'], + }, + }, + }, + { + files: ['**/*.{js,jsx,astro}'], + rules: { + 'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'], + }, + }, + { + // Define the configuration for ` + + + + + + diff --git a/apps/web/public/robots.txt b/apps/web/public/robots.txt new file mode 100644 index 0000000..6f27bb6 --- /dev/null +++ b/apps/web/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: \ No newline at end of file diff --git a/apps/web/src/assets/favicons/apple-touch-icon.png b/apps/web/src/assets/favicons/apple-touch-icon.png new file mode 100644 index 0000000..6262d06 Binary files /dev/null and b/apps/web/src/assets/favicons/apple-touch-icon.png differ diff --git a/apps/web/src/assets/favicons/favicon.ico b/apps/web/src/assets/favicons/favicon.ico new file mode 100644 index 0000000..9f9502a Binary files /dev/null and b/apps/web/src/assets/favicons/favicon.ico differ diff --git a/apps/web/src/assets/favicons/favicon.svg b/apps/web/src/assets/favicons/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/apps/web/src/assets/favicons/favicon.svg @@ -0,0 +1,9 @@ + + + + diff --git a/apps/web/src/assets/icons/README.md b/apps/web/src/assets/icons/README.md new file mode 100644 index 0000000..19f3a93 --- /dev/null +++ b/apps/web/src/assets/icons/README.md @@ -0,0 +1,4 @@ +# Local SVG icons + +Drop `.svg` files here and use them as `` (`astro-icon`, `iconDir` in `astro.config.ts`). +The directory must exist, otherwise astro-icon warns on every build. diff --git a/apps/web/src/assets/images/app-store.png b/apps/web/src/assets/images/app-store.png new file mode 100644 index 0000000..8d634c0 Binary files /dev/null and b/apps/web/src/assets/images/app-store.png differ diff --git a/apps/web/src/assets/images/default.png b/apps/web/src/assets/images/default.png new file mode 100644 index 0000000..62899e6 Binary files /dev/null and b/apps/web/src/assets/images/default.png differ diff --git a/apps/web/src/assets/images/google-play.png b/apps/web/src/assets/images/google-play.png new file mode 100644 index 0000000..179f1ff Binary files /dev/null and b/apps/web/src/assets/images/google-play.png differ diff --git a/apps/web/src/assets/images/hero-image.png b/apps/web/src/assets/images/hero-image.png new file mode 100644 index 0000000..5509924 Binary files /dev/null and b/apps/web/src/assets/images/hero-image.png differ diff --git a/apps/web/src/assets/styles/shadcn.css b/apps/web/src/assets/styles/shadcn.css new file mode 100644 index 0000000..2ac19b8 --- /dev/null +++ b/apps/web/src/assets/styles/shadcn.css @@ -0,0 +1,107 @@ +/* + * shadcn/ui-compatible design tokens. + * + * shadcn/ui components (and libraries that follow its convention) style + * themselves with semantic CSS variables such as `--background`, + * `--foreground`, `--card`, `--border` or `--ring`, exposed to Tailwind as + * `bg-background`, `text-foreground`, `border-border`, `ring-ring`, etc. + * + * This file derives those variables from AstroWind's own `--aw-*` tokens + * (see `src/components/CustomStyles.astro`), so re-theming AstroWind also + * re-themes any shadcn-style component you drop in. Dark mode works through + * the same `.dark` class AstroWind already toggles. + * + * Three names collide with existing AstroWind tokens and keep AstroWind's + * meaning: `primary`, `secondary` and `accent` are brand colours here (in + * shadcn `secondary`/`accent` are subtle surfaces), and `muted` is a text + * colour (`text-muted`) rather than a surface. Their `-foreground` pairs are + * provided so `bg-primary text-primary-foreground` and friends work. + */ + +:root, +.dark { + --background: var(--aw-color-bg-page); + --foreground: var(--aw-color-text-default); + + --card: var(--aw-color-bg-page); + --card-foreground: var(--aw-color-text-default); + --popover: var(--aw-color-bg-page); + --popover-foreground: var(--aw-color-text-default); + + --primary: var(--aw-color-primary); + --primary-foreground: #fff; + --secondary: var(--aw-color-secondary); + --secondary-foreground: #fff; + --accent: var(--aw-color-accent); + --accent-foreground: #fff; + + --muted: color-mix(in oklab, var(--aw-color-text-default) 6%, var(--aw-color-bg-page)); + --muted-foreground: var(--aw-color-text-muted); + + --destructive: oklch(57.7% 0.245 27.325); + --destructive-foreground: #fff; + + --border: color-mix(in oklab, var(--aw-color-text-default) 15%, var(--aw-color-bg-page)); + --input: color-mix(in oklab, var(--aw-color-text-default) 15%, var(--aw-color-bg-page)); + --ring: var(--aw-color-primary); + + --radius: 0.625rem; + + --chart-1: var(--aw-color-primary); + --chart-2: var(--aw-color-accent); + --chart-3: var(--aw-color-secondary); + --chart-4: color-mix(in oklab, var(--aw-color-primary) 55%, var(--aw-color-bg-page)); + --chart-5: color-mix(in oklab, var(--aw-color-accent) 55%, var(--aw-color-bg-page)); + + --sidebar: var(--aw-color-bg-page); + --sidebar-foreground: var(--aw-color-text-default); + --sidebar-primary: var(--aw-color-primary); + --sidebar-primary-foreground: #fff; + --sidebar-accent: color-mix(in oklab, var(--aw-color-text-default) 6%, var(--aw-color-bg-page)); + --sidebar-accent-foreground: var(--aw-color-text-default); + --sidebar-border: color-mix(in oklab, var(--aw-color-text-default) 15%, var(--aw-color-bg-page)); + --sidebar-ring: var(--aw-color-primary); +} + +/* + * Expose the variables as Tailwind theme tokens. `primary`, `secondary`, + * `accent` and `muted` are intentionally omitted: AstroWind already defines + * them in `tailwind.css`. + */ +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --color-card: var(--card); + --color-card-foreground: var(--card-foreground); + --color-popover: var(--popover); + --color-popover-foreground: var(--popover-foreground); + --color-primary-foreground: var(--primary-foreground); + --color-secondary-foreground: var(--secondary-foreground); + --color-accent-foreground: var(--accent-foreground); + --color-muted-foreground: var(--muted-foreground); + --color-destructive: var(--destructive); + --color-destructive-foreground: var(--destructive-foreground); + --color-border: var(--border); + --color-input: var(--input); + --color-ring: var(--ring); + --color-chart-1: var(--chart-1); + --color-chart-2: var(--chart-2); + --color-chart-3: var(--chart-3); + --color-chart-4: var(--chart-4); + --color-chart-5: var(--chart-5); + --color-sidebar: var(--sidebar); + --color-sidebar-foreground: var(--sidebar-foreground); + --color-sidebar-primary: var(--sidebar-primary); + --color-sidebar-primary-foreground: var(--sidebar-primary-foreground); + --color-sidebar-accent: var(--sidebar-accent); + --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); + --color-sidebar-border: var(--sidebar-border); + --color-sidebar-ring: var(--sidebar-ring); +} + +/* + * shadcn's `--radius` scale is NOT mapped onto Tailwind's `rounded-*` scale on + * purpose: doing so would change the radius of every existing AstroWind + * component. `--radius` is still defined above for components that read it + * directly. + */ diff --git a/apps/web/src/assets/styles/tailwind.css b/apps/web/src/assets/styles/tailwind.css new file mode 100644 index 0000000..0010579 --- /dev/null +++ b/apps/web/src/assets/styles/tailwind.css @@ -0,0 +1,152 @@ +@import 'tailwindcss'; + +@plugin "@tailwindcss/typography"; + +/* shadcn/ui-compatible tokens derived from the --aw-* variables. */ +@import './shadcn.css'; + +@variant dark (&:where(.dark, .dark *)); + +@custom-variant intersect (&:not([no-intersect])); + +@theme { + --color-primary: var(--aw-color-primary); + --color-secondary: var(--aw-color-secondary); + --color-accent: var(--aw-color-accent); + --color-heading: var(--aw-color-text-heading); + --color-default: var(--aw-color-text-default); + --color-muted: var(--aw-color-text-muted); + --color-link: var(--aw-color-link, var(--aw-color-primary)); + + --font-sans: + var(--aw-font-sans, ui-sans-serif), ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', + 'Segoe UI Symbol', 'Noto Color Emoji'; + --font-serif: var(--aw-font-serif, ui-serif), ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif; + --font-heading: var(--aw-font-heading, ui-sans-serif), ui-sans-serif, system-ui, sans-serif; + + --animate-fade: fadeInUp 0.5s both; + + @keyframes fadeInUp { + 0% { + opacity: 0; + transform: translateY(0.75rem); + } + 100% { + opacity: 1; + transform: translateY(0); + } + } +} + +@utility bg-page { + background-color: var(--aw-color-bg-page); +} + +@utility bg-dark { + background-color: var(--aw-color-bg-page-dark); +} + +@utility text-page { + color: var(--aw-color-text-default); +} + +@utility text-muted { + color: var(--aw-color-text-muted); +} + +@utility btn { + @apply inline-flex items-center justify-center rounded-full border-gray-400 border bg-transparent font-medium text-center text-base text-page leading-snug transition py-3.5 px-6 md:px-8 ease-in duration-200 focus:ring-blue-500 focus:ring-offset-blue-200 focus:ring-2 focus:ring-offset-2 hover:bg-gray-100 hover:border-gray-600 dark:text-slate-300 dark:border-slate-500 dark:hover:bg-slate-800 dark:hover:border-slate-800 cursor-pointer; +} + +@utility btn-primary { + @apply btn font-semibold bg-primary text-white border-primary hover:bg-secondary hover:border-secondary hover:text-white dark:text-white dark:bg-primary dark:border-primary dark:hover:border-secondary dark:hover:bg-secondary; +} + +@utility btn-secondary { + @apply btn; +} + +@utility btn-tertiary { + @apply btn border-none shadow-none text-muted hover:text-gray-900 dark:text-gray-400 dark:hover:text-white; +} + +/* Sticky header: solid page background on phones, translucent page background with blur on desktop. */ +#header.scroll > div:first-child { + @apply bg-page lg:backdrop-blur-md; + box-shadow: 0 0.375rem 1.5rem 0 rgb(140 152 164 / 13%); +} +@media (width >= 64rem) { + #header.scroll > div:first-child { + background-color: color-mix(in srgb, var(--aw-color-bg-page) 90%, transparent); + } +} +.dark #header.scroll > div:first-child, +#header.scroll.dark > div:first-child { + @apply border-b border-gray-500/20; + box-shadow: none; +} + +#header.expanded nav { + position: fixed; + top: 70px; + left: 0; + right: 0; + bottom: 70px !important; + padding: 0 5px; +} + +.dropdown:focus .dropdown-menu, +.dropdown:focus-within .dropdown-menu, +.dropdown:hover .dropdown-menu { + display: block; +} + +[astro-icon].icon-light > * { + stroke-width: 1.2; +} + +[astro-icon].icon-bold > * { + stroke-width: 2.4; +} + +[data-aw-toggle-menu] path { + @apply transition; +} +[data-aw-toggle-menu].expanded g > path:first-child { + @apply -rotate-45 translate-y-[15px] translate-x-[-3px]; +} +[data-aw-toggle-menu].expanded g > path:last-child { + @apply rotate-45 translate-y-[-8px] translate-x-[14px]; +} + +/* Current page in the header navigation (set server-side in Header.astro and + kept in sync on client-side navigations). Override --aw-color-link in + CustomStyles.astro to change the colour. */ +#header nav .aw-link-active { + @apply text-link; +} + +.dd *:first-child { + margin-top: 0; +} + +/* Blog prose: inline code without the typography plugin's backticks, and + code blocks that follow the light/dark theme (Shiki dual themes). */ +.prose :where(code):not(:where(pre *)) { + background-color: color-mix(in oklab, var(--aw-color-text-default) 8%, transparent); + border-radius: 0.25rem; + padding: 0.125rem 0.375rem; + font-weight: 500; +} +.prose :where(code):not(:where(pre *))::before, +.prose :where(code):not(:where(pre *))::after { + content: none; +} +.prose :where(pre.astro-code) { + border: 1px solid color-mix(in oklab, var(--aw-color-text-default) 12%, transparent); +} +.dark .astro-code, +.dark .astro-code span { + color: var(--shiki-dark) !important; + background-color: var(--shiki-dark-bg) !important; +} diff --git a/apps/web/src/components/CustomStyles.astro b/apps/web/src/components/CustomStyles.astro new file mode 100644 index 0000000..3a78fdd --- /dev/null +++ b/apps/web/src/components/CustomStyles.astro @@ -0,0 +1,48 @@ +--- +// Font family is provided by Astro's native Fonts API (see `fonts` in +// astro.config.ts and in Layout.astro), exposed as `--font-inter`. +// To switch typefaces, change the `fonts` entry and repoint `--aw-font-*` below. +--- + + diff --git a/apps/web/src/components/Favicons.astro b/apps/web/src/components/Favicons.astro new file mode 100644 index 0000000..fed6696 --- /dev/null +++ b/apps/web/src/components/Favicons.astro @@ -0,0 +1,10 @@ +--- +import favIcon from '~/assets/favicons/favicon.ico'; +import favIconSvg from '~/assets/favicons/favicon.svg'; +import appleTouchIcon from '~/assets/favicons/apple-touch-icon.png'; +--- + + + + + diff --git a/apps/web/src/components/Logo.astro b/apps/web/src/components/Logo.astro new file mode 100644 index 0000000..89a3a2d --- /dev/null +++ b/apps/web/src/components/Logo.astro @@ -0,0 +1,9 @@ +--- +import { SITE } from 'theme:config'; +--- + + + 🚀 {SITE?.name} + diff --git a/apps/web/src/components/blog/Grid.astro b/apps/web/src/components/blog/Grid.astro new file mode 100644 index 0000000..1b62be4 --- /dev/null +++ b/apps/web/src/components/blog/Grid.astro @@ -0,0 +1,14 @@ +--- +import Item from '~/components/blog/GridItem.astro'; +import type { Post } from '~/types'; + +export interface Props { + posts: Array; +} + +const { posts } = Astro.props; +--- + +
+ {posts.map((post) => )} +
diff --git a/apps/web/src/components/blog/GridItem.astro b/apps/web/src/components/blog/GridItem.astro new file mode 100644 index 0000000..5e0c855 --- /dev/null +++ b/apps/web/src/components/blog/GridItem.astro @@ -0,0 +1,71 @@ +--- +import { APP_BLOG } from 'theme:config'; +import type { Post } from '~/types'; + +import Image from '~/components/common/Image.astro'; + +import { findImage } from '~/utils/images'; +import { getPermalink } from '~/utils/permalinks'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; +const image = await findImage(post.image); + +const link = APP_BLOG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : ''; +--- + +
+
+ { + image && + (link ? ( + + {post.title} + + ) : ( + {post.title} + )) + } +
+ +

+ { + link ? ( + + {post.title} + + ) : ( + post.title + ) + } +

+ +

{post.excerpt}

+
diff --git a/apps/web/src/components/blog/Headline.astro b/apps/web/src/components/blog/Headline.astro new file mode 100644 index 0000000..5d3ccc6 --- /dev/null +++ b/apps/web/src/components/blog/Headline.astro @@ -0,0 +1,12 @@ +--- +const { title = await Astro.slots.render('default'), subtitle = await Astro.slots.render('subtitle') } = Astro.props; +--- + +
+

+ { + subtitle && ( +
+ ) + } +

diff --git a/apps/web/src/components/blog/List.astro b/apps/web/src/components/blog/List.astro new file mode 100644 index 0000000..6a80ae3 --- /dev/null +++ b/apps/web/src/components/blog/List.astro @@ -0,0 +1,20 @@ +--- +import Item from '~/components/blog/ListItem.astro'; +import type { Post } from '~/types'; + +export interface Props { + posts: Array; +} + +const { posts } = Astro.props; +--- + +
    + { + posts.map((post) => ( +
  • + +
  • + )) + } +
diff --git a/apps/web/src/components/blog/ListItem.astro b/apps/web/src/components/blog/ListItem.astro new file mode 100644 index 0000000..6df606d --- /dev/null +++ b/apps/web/src/components/blog/ListItem.astro @@ -0,0 +1,124 @@ +--- +import type { ImageMetadata } from 'astro'; +import { Icon } from 'astro-icon/components'; +import Image from '~/components/common/Image.astro'; +import PostTags from '~/components/blog/Tags.astro'; + +import { APP_BLOG } from 'theme:config'; +import type { Post } from '~/types'; + +import { getPermalink } from '~/utils/permalinks'; +import { findImage } from '~/utils/images'; +import { getFormattedDate } from '~/utils/utils'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; +const image = (await findImage(post.image)) as ImageMetadata | undefined; + +const link = APP_BLOG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : ''; +--- + +
+ { + image && + (link ? ( + + + + ) : ( + + )) + } +
+
+
+ + + + { + post.author && ( + <> + {' '} + · + {post.author.replaceAll('-', ' ')} + + ) + } + { + post.category && ( + <> + {' '} + ·{' '} + + {post.category.title} + + + ) + } + +
+

+ { + link ? ( + + {post.title} + + ) : ( + post.title + ) + } +

+
+ + {post.excerpt &&

{post.excerpt}

} + { + post.tags && Array.isArray(post.tags) ? ( +
+ +
+ ) : ( + + ) + } +
+
diff --git a/apps/web/src/components/blog/Pagination.astro b/apps/web/src/components/blog/Pagination.astro new file mode 100644 index 0000000..4991400 --- /dev/null +++ b/apps/web/src/components/blog/Pagination.astro @@ -0,0 +1,34 @@ +--- +import { Icon } from 'astro-icon/components'; +import Button from '~/components/ui/Button.astro'; + +export interface Props { + prevUrl?: string; + nextUrl?: string; + prevText?: string; + nextText?: string; +} + +// `prevUrl`/`nextUrl` come from Astro's `page.url` and already include `base` +// and honour `trailingSlash`, so they must not go through `getPermalink()` +// (that would prefix `base` a second time, see #629). +const { prevUrl, nextUrl, prevText = 'Newer posts', nextText = 'Older posts' } = Astro.props; +--- + +{ + (prevUrl || nextUrl) && ( +
+
+ + + +
+
+ ) +} diff --git a/apps/web/src/components/blog/RelatedPosts.astro b/apps/web/src/components/blog/RelatedPosts.astro new file mode 100644 index 0000000..c807fb8 --- /dev/null +++ b/apps/web/src/components/blog/RelatedPosts.astro @@ -0,0 +1,31 @@ +--- +import { APP_BLOG } from 'theme:config'; + +import { getRelatedPosts } from '~/utils/blog'; +import BlogHighlightedPosts from '~/components/widgets/BlogHighlightedPosts.astro'; +import type { Post } from '~/types'; +import { getBlogPermalink } from '~/utils/permalinks'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; + +const relatedPosts = post.tags ? await getRelatedPosts(post, 4) : []; +--- + +{ + APP_BLOG.isRelatedPostsEnabled ? ( + post.id)} + /> + ) : null +} diff --git a/apps/web/src/components/blog/SinglePost.astro b/apps/web/src/components/blog/SinglePost.astro new file mode 100644 index 0000000..4c69a93 --- /dev/null +++ b/apps/web/src/components/blog/SinglePost.astro @@ -0,0 +1,113 @@ +--- +import { Icon } from 'astro-icon/components'; + +import Image from '~/components/common/Image.astro'; +import PostTags from '~/components/blog/Tags.astro'; +import SocialShare from '~/components/common/SocialShare.astro'; + +import { getPermalink } from '~/utils/permalinks'; +import { getFormattedDate } from '~/utils/utils'; + +import type { Post } from '~/types'; + +export interface Props { + post: Post; + url: string | URL; +} + +const { post, url } = Astro.props; +--- + +
+
+
+
+

+ + + { + post.updateDate && post.updateDate.getTime() !== post.publishDate.getTime() && ( + <> + {' '} + ·{' '} + + Updated + + + ) + } + { + post.author && ( + <> + {' '} + · + {post.author} + + ) + } + { + post.category && ( + <> + {' '} + ·{' '} + + {post.category.title} + + + ) + } + { + post.readingTime && ( + <> +  · {post.readingTime} min read + + ) + } +

+
+ +

+ {post.title} +

+

+ {post.excerpt} +

+ + { + post.image ? ( + {post.imageAlt + ) : ( +
+
+
+ ) + } +
+
+ +
+
+ + +
+
+
diff --git a/apps/web/src/components/blog/Tags.astro b/apps/web/src/components/blog/Tags.astro new file mode 100644 index 0000000..54d7f96 --- /dev/null +++ b/apps/web/src/components/blog/Tags.astro @@ -0,0 +1,43 @@ +--- +import { getPermalink } from '~/utils/permalinks'; + +import { APP_BLOG } from 'theme:config'; +import type { Post } from '~/types'; + +export interface Props { + tags: Post['tags']; + class?: string; + title?: string | undefined; + isCategory?: boolean; +} + +const { tags, class: className = 'text-sm', title = undefined, isCategory = false } = Astro.props; +--- + +{ + tags && Array.isArray(tags) && ( + <> + {title !== undefined && ( + + {title} + + )} +
    + {tags.map((tag) => ( +
  • + {!APP_BLOG?.tag?.isEnabled ? ( + tag.title + ) : ( + + {tag.title} + + )} +
  • + ))} +
+ + ) +} diff --git a/apps/web/src/components/blog/ToBlogLink.astro b/apps/web/src/components/blog/ToBlogLink.astro new file mode 100644 index 0000000..79edc36 --- /dev/null +++ b/apps/web/src/components/blog/ToBlogLink.astro @@ -0,0 +1,20 @@ +--- +import { Icon } from 'astro-icon/components'; +import { getBlogPermalink } from '~/utils/permalinks'; +import { I18N } from 'theme:config'; +import Button from '~/components/ui/Button.astro'; + +const { textDirection } = I18N; +--- + +
+ +
diff --git a/apps/web/src/components/common/Analytics.astro b/apps/web/src/components/common/Analytics.astro new file mode 100644 index 0000000..85aa8bc --- /dev/null +++ b/apps/web/src/components/common/Analytics.astro @@ -0,0 +1,21 @@ +--- +import { ANALYTICS } from 'theme:config'; + +const id = ANALYTICS?.vendors?.googleAnalytics?.id ? String(ANALYTICS.vendors.googleAnalytics.id) : ''; +const partytown = !!ANALYTICS?.vendors?.googleAnalytics?.partytown; +const scriptType = partytown ? 'text/partytown' : undefined; +--- + +{id && diff --git a/apps/web/src/components/common/ApplyColorMode.astro b/apps/web/src/components/common/ApplyColorMode.astro new file mode 100644 index 0000000..f6236a3 --- /dev/null +++ b/apps/web/src/components/common/ApplyColorMode.astro @@ -0,0 +1,35 @@ +--- +import { UI } from 'theme:config'; +--- + + diff --git a/apps/web/src/components/common/Breadcrumbs.astro b/apps/web/src/components/common/Breadcrumbs.astro new file mode 100644 index 0000000..f26d7cd --- /dev/null +++ b/apps/web/src/components/common/Breadcrumbs.astro @@ -0,0 +1,68 @@ +--- +import { Icon } from 'astro-icon/components'; +import { getCanonical } from '~/utils/permalinks'; + +// Breadcrumb trail with matching BreadcrumbList structured data. The last +// item is the current page, rendered without a link; with `hideCurrent` it is +// kept for assistive technology and the JSON-LD but not shown, so a post's +// trail reads Home › Blog › Category without repeating the title. + +export interface Props { + /** `icon` replaces the visible text (the text stays for screen readers and structured data). */ + items: Array<{ text: string; href?: string; icon?: string }>; + /** Render inside a band under the header, aligned with the header's container and logo. */ + bar?: boolean; + /** Keep the current page out of sight (it stays for assistive technology and the JSON-LD). */ + hideCurrent?: boolean; + class?: string; +} + +const { items, bar = false, hideCurrent = false, class: className = '' } = Astro.props; + +const schema = { + '@context': 'https://schema.org', + '@type': 'BreadcrumbList', + itemListElement: items.map(({ text, href }, index) => ({ + '@type': 'ListItem', + position: index + 1, + name: text, + ...(href ? { item: String(getCanonical(href)) } : {}), + })), +}; +--- + + + + diff --git a/apps/web/src/components/common/Metadata.astro b/apps/web/src/components/common/Metadata.astro new file mode 100644 index 0000000..e3908c9 --- /dev/null +++ b/apps/web/src/components/common/Metadata.astro @@ -0,0 +1,114 @@ +--- +import merge from 'lodash.merge'; +import { SEO } from 'astro-seo'; + +import type { SEOProps } from 'astro-seo'; + +import { SITE, METADATA, I18N } from 'theme:config'; +import type { MetaData, MetaDataOpenGraph } from '~/types'; +import { getCanonical } from '~/utils/permalinks'; + +import { adaptOpenGraphImages } from '~/utils/images'; + +export interface Props extends MetaData { + dontUseTitleTemplate?: boolean; +} + +const { + title, + ignoreTitleTemplate = false, + canonical = String(getCanonical(String(Astro.url.pathname))), + robots = {}, + description, + openGraph = {}, + twitter = {}, +} = Astro.props; + +const mergedOg: MetaDataOpenGraph = merge( + { + url: canonical, + siteName: SITE?.name, + images: [], + locale: I18N?.language || 'en', + type: 'website', + }, + METADATA?.openGraph, + { url: canonical, ...openGraph } +); + +const adaptedOg = await adaptOpenGraphImages(mergedOg, Astro.site); + +const firstImage = adaptedOg?.images?.[0]; + +function buildOpenGraph(og: MetaDataOpenGraph): SEOProps['openGraph'] | undefined { + if (!og) return undefined; + + const imageUrl = firstImage?.url || ''; + if (!imageUrl) return undefined; + + return { + basic: { + title: title || METADATA?.title?.default || '', + type: og.type || 'website', + image: imageUrl, + url: og.url, + }, + optional: { + description: description || METADATA?.description, + locale: og.locale, + siteName: og.siteName, + }, + image: { + url: imageUrl, + width: firstImage?.width, + height: firstImage?.height, + alt: title || METADATA?.title?.default || '', + }, + ...(og.type === 'article' && og.article ? { article: og.article } : {}), + }; +} + +const mergedTwitter = merge( + { + card: (adaptedOg?.images?.length ? 'summary_large_image' : 'summary') as 'summary_large_image' | 'summary', + }, + METADATA?.twitter + ? { + card: METADATA.twitter.cardType as 'summary_large_image' | 'summary' | undefined, + site: METADATA.twitter.site, + creator: METADATA.twitter.handle, + } + : {}, + twitter + ? { + card: twitter.cardType as 'summary_large_image' | 'summary' | undefined, + site: twitter.site, + creator: twitter.handle, + } + : {} +); + +const seoProps: SEOProps = { + title: title || METADATA?.title?.default || '', + titleTemplate: ignoreTitleTemplate ? '%s' : METADATA?.title?.template || '%s', + canonical: canonical, + noindex: + typeof robots?.index !== 'undefined' + ? !robots.index + : typeof METADATA?.robots?.index !== 'undefined' + ? !METADATA.robots.index + : true, + nofollow: + typeof robots?.follow !== 'undefined' + ? !robots.follow + : typeof METADATA?.robots?.follow !== 'undefined' + ? !METADATA.robots.follow + : true, + description: description || METADATA?.description, + openGraph: buildOpenGraph(adaptedOg), + twitter: mergedTwitter, + surpressWarnings: true, +}; +--- + + diff --git a/apps/web/src/components/common/SiteVerification.astro b/apps/web/src/components/common/SiteVerification.astro new file mode 100644 index 0000000..dd4948c --- /dev/null +++ b/apps/web/src/components/common/SiteVerification.astro @@ -0,0 +1,5 @@ +--- +import { SITE } from 'theme:config'; +--- + +{SITE.googleSiteVerificationId && } diff --git a/apps/web/src/components/common/SocialShare.astro b/apps/web/src/components/common/SocialShare.astro new file mode 100644 index 0000000..ff8ce3d --- /dev/null +++ b/apps/web/src/components/common/SocialShare.astro @@ -0,0 +1,119 @@ +--- +import { Icon } from 'astro-icon/components'; + +export interface Props { + text: string; + url: string | URL; + class?: string; +} + +const { text, url, class: className = 'inline-block' } = Astro.props; +--- + + + Share: + + + + + + + + + + diff --git a/apps/web/src/components/common/StructuredData.astro b/apps/web/src/components/common/StructuredData.astro new file mode 100644 index 0000000..c1ce277 --- /dev/null +++ b/apps/web/src/components/common/StructuredData.astro @@ -0,0 +1,13 @@ +--- +// Emits one or more Schema.org objects as JSON-LD. Use it through the layout's +// `head` slot: . Blog posts get +// BlogPosting and BreadcrumbList automatically; the FAQs widget emits FAQPage. + +export interface Props { + schema: Record | Array>; +} + +const { schema } = Astro.props; +--- + + diff --git a/apps/web/src/components/ui/Button.astro b/apps/web/src/components/ui/Button.astro new file mode 100644 index 0000000..d3c2398 --- /dev/null +++ b/apps/web/src/components/ui/Button.astro @@ -0,0 +1,40 @@ +--- +import { Icon } from 'astro-icon/components'; +import { twMerge } from 'tailwind-merge'; +import type { CallToAction as Props } from '~/types'; + +const { + variant = 'secondary', + target, + text = Astro.slots.render('default'), + icon = '', + class: className = '', + type, + ...rest +} = Astro.props; + +const variants = { + primary: 'btn-primary', + secondary: 'btn-secondary', + tertiary: 'btn btn-tertiary', + link: 'cursor-pointer hover:text-primary', +}; +--- + +{ + type === 'button' || type === 'submit' || type === 'reset' ? ( + + ) : ( + + + {icon && } + + ) +} diff --git a/apps/web/src/components/ui/Form.astro b/apps/web/src/components/ui/Form.astro new file mode 100644 index 0000000..276b39f --- /dev/null +++ b/apps/web/src/components/ui/Form.astro @@ -0,0 +1,87 @@ +--- +import type { Form as Props } from '~/types'; +import Button from '~/components/ui/Button.astro'; + +const { inputs, textarea, disclaimer, button = 'Contact us', description = '' } = Astro.props; +--- + +
+ { + inputs && + inputs.map( + ({ type = 'text', name, label = '', autocomplete = 'on', placeholder = '' }) => + name && ( +
+ {label && ( + + )} + +
+ ) + ) + } + + { + textarea && ( +
+ +