diff --git a/.vscode/astro-paper.code-snippets b/.vscode/astro-paper.code-snippets new file mode 100644 index 0000000..983912f --- /dev/null +++ b/.vscode/astro-paper.code-snippets @@ -0,0 +1,34 @@ +{ + "Frontmatter": { + "scope": "markdown", + "prefix": "frontmatter", + "body": [ + "---", + "author: $1", + "pubDatetime: $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND.000$CURRENT_TIMEZONE_OFFSET", + "modDatetime: $3", + "title: $4", + "featured: ${5|false,true|}", + "draft: ${6|true,false|}", + "tags:", + " - $7", + "description: $8", + "---", + ], + "description": "Adds the frontmatter block for a blog post", + }, + "Blog Template": { + "scope": "markdown", + "prefix": "template", + "body": [ + "${1:frontmatter}", + "", + "${2: Introductory Sentence}", + "", + "## Table of contents", + "", + "## ${3: heading 1}", + ], + "description": "Adds the template for a blog post. You will need to trigger the snippet modal on the 'frontmatter' line to insert the other snipper.", + }, +} diff --git a/README.md b/README.md index bedcb03..78f8a9b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,70 @@ # astro-paper -[Vercel's AstroPaper template](https://github.com/satnaing/astro-paper) on -**Cloudflare Workers**, 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 [AstroPaper](https://github.com/satnaing/astro-paper) template — a +minimal, responsive, accessible and SEO-friendly Astro blog theme: posts in +Markdown and MDX with tags, archives and pagination, full-text search with +Pagefind, a dynamic Open Graph image for the site and for every post, light +and dark mode, 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 (AP2). + +AstroPaper builds fully static: `astro build` writes every page, post, tag +page, feed, sitemap and Open Graph image (satori and sharp, at build time) to +`dist/`, and Pagefind indexes the built pages into `dist/pagefind`. That +folder is uploaded as Workers Static Assets with one small Worker in front +for what matches no file; no adapter and no server code. The pages, the +posts, the search and the theme do not change; the site's name moves into +one module, and each deploy builds for its own origin. +See [`specs/epics/astro-paper`](specs/epics/astro-paper/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, every page's title, the OG image, the feed) | `apps/web/src/site.ts` | +| The theme's configuration (description, author, features, socials, share links) | `apps/web/astro-paper.config.ts` | +| Posts and the about page | `apps/web/src/content/posts`, `apps/web/src/content/pages` | +| Pages, layouts, components, the OG image routes | `apps/web/src/pages`, `apps/web/src/layouts`, `apps/web/src/components` | +| The Worker in front of the assets, its config, deploy contract | `apps/web/worker/index.ts`, `apps/web/wrangler.jsonc`, `apps/web/component.yaml` | +| Tests (the name seam, the origin, the Worker) | `apps/web/src/test` | + +## Getting started + +```bash +pnpm install +pnpm typecheck # astro check +pnpm lint # eslint +pnpm test # vitest over Astro's container API +pnpm build # astro build + pagefind → apps/web/dist +``` + +```bash +pnpm --filter @app/web dev # http://localhost:4321 (search needs one build first) +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`) | +| The template's build (`astro check && astro build && pagefind --site dist`) | Unchanged but for `astro check`, which runs as the `typecheck` step: `astro build`, then Pagefind into `dist/pagefind`, then the index copied to `public/` for `astro dev` | +| Open Graph images rendered by satori + sharp at build time | Unchanged: `/og.png` and each post's `index.png` are files in `dist/` | +| Directory URLs (`/posts//`), as the theme's own Cloudflare Pages demo serves them | `assets.html_handling: auto-trailing-slash` — `/about/` serves `about/index.html`, `/about` redirects to it | +| The host'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`) | +| `site.url: https://astro-paper.pages.dev/` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — so canonical and Open Graph links, the sitemap, robots.txt and the RSS feed name the site where it is served; `astro-paper.config.ts`'s `site.url` 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 | + +## Credits + +The site is [satnaing/astro-paper](https://github.com/satnaing/astro-paper) +by Sat Naing (MIT — `apps/web/LICENSE`), at `35cfa7f` (v6.1.0 and one fix). diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..35c2eb2 --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,6 @@ +# The site reads one optional variable: PUBLIC_GOOGLE_SITE_VERIFICATION, the +# Google Search Console verification code (astro.config.ts's env schema; or +# set `site.googleVerification` in astro-paper.config.ts). Its name is +# src/site.ts, and everything else it is configured with is +# astro-paper.config.ts. A deploy sets PUBLIC_SITE_URL itself (component.yaml). +# PUBLIC_GOOGLE_SITE_VERIFICATION= diff --git a/apps/web/.prettierignore b/apps/web/.prettierignore new file mode 100644 index 0000000..add50ff --- /dev/null +++ b/apps/web/.prettierignore @@ -0,0 +1,17 @@ +# Ignore everything +/* + +# Except these files & folders +!/src +!/public +!/.github +!tsconfig.json +!astro.config.ts +!package.json +!.prettierrc +!eslint.config.js +!README.md +!.vscode + +# Ignore MDX files +*.mdx \ No newline at end of file diff --git a/apps/web/.prettierrc b/apps/web/.prettierrc new file mode 100644 index 0000000..5d921d9 --- /dev/null +++ b/apps/web/.prettierrc @@ -0,0 +1,20 @@ +{ + "arrowParens": "avoid", + "semi": true, + "tabWidth": 2, + "printWidth": 80, + "singleQuote": false, + "jsxSingleQuote": false, + "trailingComma": "es5", + "bracketSpacing": true, + "endOfLine": "lf", + "plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"], + "overrides": [ + { + "files": "*.astro", + "options": { + "parser": "astro" + } + } + ] +} diff --git a/apps/web/LICENSE b/apps/web/LICENSE new file mode 100644 index 0000000..fa7c791 --- /dev/null +++ b/apps/web/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Sat Naing + +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..5f3210d --- /dev/null +++ b/apps/web/README.md @@ -0,0 +1,33 @@ +# apps/web — the site + +A blog on Sat Naing's Astro theme +([satnaing/astro-paper](https://github.com/satnaing/astro-paper), MIT) — +Astro 7 and Tailwind CSS 4 — built fully static and served as Cloudflare +Workers Static Assets: + +- `/` (the featured and recent posts), `/about/`, `/archives/`, `/search/` +- the posts: `/posts/` (paginated: `/posts/2/` …), a page per post + (`src/content/posts/**/*.md|mdx`) with its own Open Graph image + (`/posts//index.png`), `/tags/` and `/tags//` +- `/rss.xml`, `/sitemap-index.xml`, `/robots.txt`, the site's Open Graph + image `/og.png`, and the Pagefind search index under `/pagefind/` + +The site's name — the header, every page's title, the Open Graph image and +the feed — is `src/site.ts`. Its description, author, timezone, features, +socials and share links are `astro-paper.config.ts`; the about page is +`src/content/pages/about.md`; colours and typography are `src/styles/`. + +```bash +pnpm dev # astro dev on http://localhost:4321 (search needs one build first) +pnpm test # vitest over Astro's container API (src/test) +pnpm build # astro build + pagefind → dist/ (and the index copied to public/ for dev) +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. Pages are directories: `/about` redirects to `/about/`. + +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-paper.config.ts b/apps/web/astro-paper.config.ts new file mode 100644 index 0000000..161357f --- /dev/null +++ b/apps/web/astro-paper.config.ts @@ -0,0 +1,49 @@ +import { defineAstroPaperConfig } from "./src/types/config"; +import { SITE_NAME } from "./src/site"; + +export default defineAstroPaperConfig({ + site: { + // The origin a local build links to. A deploy builds for its own + // environment's origin instead: astro.config.ts takes PUBLIC_SITE_URL + // over this, and the rest of the site reads Astro's resolved `site`. + url: "https://astro-paper.example.com/", + title: SITE_NAME, + description: "A minimal, responsive and SEO-friendly Astro blog theme.", + author: "Sat Naing", + profile: "https://satna.ing", + ogImage: "default-og.jpg", + lang: "en", + timezone: "Asia/Bangkok", + dir: "ltr", + }, + posts: { + perPage: 4, + perIndex: 4, + scheduledPostMargin: 15 * 60 * 1000, + }, + features: { + lightAndDarkMode: true, + dynamicOgImage: true, + showArchives: true, + showBackButton: true, + editPost: { + enabled: true, + url: "https://github.com/sourceplane/astro-paper/edit/main/apps/web/", + }, + search: "pagefind", + }, + socials: [ + { name: "github", url: "https://github.com/sourceplane/astro-paper" }, + { name: "x", url: "https://x.com/username" }, + { name: "linkedin", url: "https://www.linkedin.com/in/username/" }, + { name: "mail", url: "mailto:yourmail@gmail.com" }, + ], + shareLinks: [ + { name: "whatsapp", url: "https://wa.me/?text=" }, + { name: "facebook", url: "https://www.facebook.com/sharer.php?u=" }, + { name: "x", url: "https://x.com/intent/post?url=" }, + { name: "telegram", url: "https://t.me/share/url?url=" }, + { name: "pinterest", url: "https://pinterest.com/pin/create/button/?url=" }, + { name: "mail", url: "mailto:?subject=See%20this%20post&body=" }, + ], +}); \ No newline at end of file diff --git a/apps/web/astro.config.ts b/apps/web/astro.config.ts new file mode 100644 index 0000000..f312681 --- /dev/null +++ b/apps/web/astro.config.ts @@ -0,0 +1,89 @@ +import { + defineConfig, + envField, + fontProviders, + svgoOptimizer, +} from "astro/config"; +import tailwindcss from "@tailwindcss/vite"; +import mdx from "@astrojs/mdx"; +import sitemap from "@astrojs/sitemap"; +import { unified } from "@astrojs/markdown-remark"; +import remarkToc from "remark-toc"; +import remarkCollapse from "remark-collapse"; +import rehypeCallouts from "rehype-callouts"; +import { + transformerNotationDiff, + transformerNotationHighlight, + transformerNotationWordHighlight, +} from "@shikijs/transformers"; +import { transformerFileName } from "./src/utils/transformers/fileName"; +import config from "./astro-paper.config"; + +export default defineConfig({ + // The site's public origin — canonical and Open Graph links, the sitemap and + // the RSS feed are absolute. A deploy sets PUBLIC_SITE_URL to its + // environment's (its SITE_URL, else its workers.dev URL); a local build + // uses astro-paper.config.ts's. src/config.ts reads the result back as + // `import.meta.env.SITE`. + site: process.env.PUBLIC_SITE_URL || config.site.url, + integrations: [ + mdx(), + sitemap({ + filter: page => + config.features?.showArchives !== false || !page.endsWith("/archives/"), + }), + ], + i18n: { + locales: ["en"], + defaultLocale: "en", + routing: { + prefixDefaultLocale: false, + }, + }, + markdown: { + processor: unified({ + remarkPlugins: [ + remarkToc, + [remarkCollapse, { test: "Table of contents" }], + ], + rehypePlugins: [rehypeCallouts], + }), + shikiConfig: { + themes: { light: "min-light", dark: "night-owl" }, + defaultColor: false, + wrap: false, + transformers: [ + transformerFileName({ style: "v2", hideDot: false }), + transformerNotationHighlight(), + transformerNotationWordHighlight(), + transformerNotationDiff({ matchAlgorithm: "v3" }), + ], + }, + }, + vite: { + plugins: [tailwindcss()], + }, + fonts: [ + { + name: "Google Sans Code", + cssVariable: "--font-google-sans-code", + provider: fontProviders.google(), + fallbacks: ["monospace"], + weights: [300, 400, 500, 600, 700], + styles: ["normal", "italic"], + formats: ["woff", "ttf"], + }, + ], + env: { + schema: { + PUBLIC_GOOGLE_SITE_VERIFICATION: envField.string({ + access: "public", + context: "client", + optional: true, + }), + }, + }, + experimental: { + svgOptimizer: svgoOptimizer(), + }, +}); diff --git a/apps/web/component.yaml b/apps/web/component.yaml new file mode 100644 index 0000000..d676c89 --- /dev/null +++ b/apps/web/component.yaml @@ -0,0 +1,93 @@ +apiVersion: sourceplane.io/v1 +kind: Component +metadata: + name: web + description: The blog (a static Astro + Tailwind CSS build with Pagefind search, 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. + # The blog 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, post, feed, sitemap + # and Open Graph image to dist/, and Pagefind its search index to + # dist/pagefind. 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: astro-paper-web-{dev,stage,prod}. + workerName: astro-paper-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 and Open Graph links, the sitemap, + # robots.txt 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. + # astro.config.ts reads PUBLIC_SITE_URL over astro-paper.config.ts's + # `site.url`. + buildCommand: PUBLIC_SITE_URL="${SITE_URL:-https://astro-paper-web-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" pnpm exec turbo run build --filter=@app/web + + # Smoke: the home page carries the theme's introduction ("minimal, + # responsive, accessible"), the posts index lists the theme's + # configuration post, the Pagefind search index is served, and an unknown + # path answers the site's own 404 page with a 404 status (served by the + # assets through the Worker). `-L` follows the directory redirect + # (/posts → /posts/). Each response is buffered before grep so an early + # match cannot SIGPIPE curl. + smokeCommand: "html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'minimal, responsive, accessible' && posts=$(curl -sfL \"${DEPLOYED_URL}/posts\") && echo \"${posts}\" | grep -q '/posts/how-to-configure-astropaper-theme/' && curl -sf -o /dev/null \"${DEPLOYED_URL}/pagefind/pagefind.js\" && 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..b1574f5 --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,20 @@ +# web + +The blog (a static Astro + Tailwind CSS build with Pagefind search, 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..593c699 --- /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 'minimal, responsive, accessible' && posts=$(curl -sfL "${DEPLOYED_URL}/posts") && echo "${posts}" | grep -q '/posts/how-to-configure-astropaper-theme/' && curl -sf -o /dev/null "${DEPLOYED_URL}/pagefind/pagefind.js" && 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..ac6c06b --- /dev/null +++ b/apps/web/eslint.config.js @@ -0,0 +1,22 @@ +import eslintPluginAstro from "eslint-plugin-astro"; +import tsParser from "@typescript-eslint/parser"; + +export default [ + ...eslintPluginAstro.configs.recommended, + { + files: ["**/*.astro"], + languageOptions: { + parserOptions: { + parser: tsParser, + }, + }, + }, + { + files: ["**/*.ts", "**/*.tsx"], + languageOptions: { + parser: tsParser, + }, + }, + { rules: { "no-console": "error" } }, + { ignores: ["dist/**", ".astro/**", "public/pagefind/**", ".wrangler/**"] }, +]; diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 0000000..4f99c45 --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,53 @@ +{ + "name": "@app/web", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "astro dev", + "build": "astro build && pagefind --site dist && cp -r dist/pagefind public/", + "preview": "wrangler dev", + "sync": "astro sync", + "astro": "astro", + "typecheck": "astro check", + "lint": "eslint .", + "format:check": "prettier --check .", + "format": "prettier --write .", + "test": "vitest run" + }, + "dependencies": { + "@astrojs/markdown-remark": "^7.2.0", + "@astrojs/mdx": "^7.0.0", + "@astrojs/rss": "^4.0.19", + "@astrojs/sitemap": "^3.7.3", + "@tailwindcss/vite": "^4.3.2", + "astro": "7.3.8", + "dayjs": "^1.11.21", + "lodash.kebabcase": "^4.1.1", + "rehype-callouts": "^2.2.0", + "remark-collapse": "^0.1.2", + "remark-toc": "^9.0.0", + "satori": "^0.26.0", + "sharp": "^0.35.2", + "slugify": "^1.6.9", + "tailwindcss": "^4.3.2" + }, + "devDependencies": { + "@astrojs/check": "^0.9.9", + "@pagefind/default-ui": "^1.5.2", + "@shikijs/transformers": "^4.3.0", + "@tailwindcss/typography": "^0.5.20", + "@types/lodash.kebabcase": "^4.1.9", + "@types/node": "^22.19.0", + "@typescript-eslint/parser": "^8.62.0", + "eslint": "^10.6.0", + "eslint-plugin-astro": "^2.1.1", + "pagefind": "^1.5.2", + "prettier": "3.9.3", + "prettier-plugin-astro": "0.14.1", + "prettier-plugin-tailwindcss": "^0.8.0", + "typescript": "^6.0.3", + "vitest": "^3.2.4", + "wrangler": "^4.151.0" + } +} diff --git a/apps/web/public/default-og.jpg b/apps/web/public/default-og.jpg new file mode 100644 index 0000000..3b351f9 Binary files /dev/null and b/apps/web/public/default-og.jpg differ diff --git a/apps/web/public/favicon.svg b/apps/web/public/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/apps/web/public/favicon.svg @@ -0,0 +1,9 @@ + + + + diff --git a/apps/web/src/assets/icons/IconArchive.svg b/apps/web/src/assets/icons/IconArchive.svg new file mode 100644 index 0000000..e7e53af --- /dev/null +++ b/apps/web/src/assets/icons/IconArchive.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconArrowLeft.svg b/apps/web/src/assets/icons/IconArrowLeft.svg new file mode 100644 index 0000000..6bb4b11 --- /dev/null +++ b/apps/web/src/assets/icons/IconArrowLeft.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconArrowNarrowUp.svg b/apps/web/src/assets/icons/IconArrowNarrowUp.svg new file mode 100644 index 0000000..ce54fda --- /dev/null +++ b/apps/web/src/assets/icons/IconArrowNarrowUp.svg @@ -0,0 +1 @@ + diff --git a/apps/web/src/assets/icons/IconArrowRight.svg b/apps/web/src/assets/icons/IconArrowRight.svg new file mode 100644 index 0000000..a0f23ae --- /dev/null +++ b/apps/web/src/assets/icons/IconArrowRight.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconCalendar.svg b/apps/web/src/assets/icons/IconCalendar.svg new file mode 100644 index 0000000..5f0be65 --- /dev/null +++ b/apps/web/src/assets/icons/IconCalendar.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconChevronLeft.svg b/apps/web/src/assets/icons/IconChevronLeft.svg new file mode 100644 index 0000000..e54e8fb --- /dev/null +++ b/apps/web/src/assets/icons/IconChevronLeft.svg @@ -0,0 +1 @@ + diff --git a/apps/web/src/assets/icons/IconEdit.svg b/apps/web/src/assets/icons/IconEdit.svg new file mode 100644 index 0000000..f351386 --- /dev/null +++ b/apps/web/src/assets/icons/IconEdit.svg @@ -0,0 +1 @@ + diff --git a/apps/web/src/assets/icons/IconHash.svg b/apps/web/src/assets/icons/IconHash.svg new file mode 100644 index 0000000..6bb6496 --- /dev/null +++ b/apps/web/src/assets/icons/IconHash.svg @@ -0,0 +1 @@ + diff --git a/apps/web/src/assets/icons/IconMenuDeep.svg b/apps/web/src/assets/icons/IconMenuDeep.svg new file mode 100644 index 0000000..5d951a7 --- /dev/null +++ b/apps/web/src/assets/icons/IconMenuDeep.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconMoon.svg b/apps/web/src/assets/icons/IconMoon.svg new file mode 100644 index 0000000..ec6ba71 --- /dev/null +++ b/apps/web/src/assets/icons/IconMoon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconRss.svg b/apps/web/src/assets/icons/IconRss.svg new file mode 100644 index 0000000..7751556 --- /dev/null +++ b/apps/web/src/assets/icons/IconRss.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconSearch.svg b/apps/web/src/assets/icons/IconSearch.svg new file mode 100644 index 0000000..0f6d821 --- /dev/null +++ b/apps/web/src/assets/icons/IconSearch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconSunHigh.svg b/apps/web/src/assets/icons/IconSunHigh.svg new file mode 100644 index 0000000..9902622 --- /dev/null +++ b/apps/web/src/assets/icons/IconSunHigh.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/IconUnderline.svg b/apps/web/src/assets/icons/IconUnderline.svg new file mode 100644 index 0000000..383f8a4 --- /dev/null +++ b/apps/web/src/assets/icons/IconUnderline.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/web/src/assets/icons/IconX.svg b/apps/web/src/assets/icons/IconX.svg new file mode 100644 index 0000000..79f489b --- /dev/null +++ b/apps/web/src/assets/icons/IconX.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/facebook.svg b/apps/web/src/assets/icons/socials/facebook.svg new file mode 100644 index 0000000..47ad743 --- /dev/null +++ b/apps/web/src/assets/icons/socials/facebook.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/github.svg b/apps/web/src/assets/icons/socials/github.svg new file mode 100644 index 0000000..ad12afd --- /dev/null +++ b/apps/web/src/assets/icons/socials/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/linkedin.svg b/apps/web/src/assets/icons/socials/linkedin.svg new file mode 100644 index 0000000..a98e151 --- /dev/null +++ b/apps/web/src/assets/icons/socials/linkedin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/mail.svg b/apps/web/src/assets/icons/socials/mail.svg new file mode 100644 index 0000000..cecc719 --- /dev/null +++ b/apps/web/src/assets/icons/socials/mail.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/pinterest.svg b/apps/web/src/assets/icons/socials/pinterest.svg new file mode 100644 index 0000000..a398d34 --- /dev/null +++ b/apps/web/src/assets/icons/socials/pinterest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/telegram.svg b/apps/web/src/assets/icons/socials/telegram.svg new file mode 100644 index 0000000..113242f --- /dev/null +++ b/apps/web/src/assets/icons/socials/telegram.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/whatsapp.svg b/apps/web/src/assets/icons/socials/whatsapp.svg new file mode 100644 index 0000000..2e2de46 --- /dev/null +++ b/apps/web/src/assets/icons/socials/whatsapp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/icons/socials/x.svg b/apps/web/src/assets/icons/socials/x.svg new file mode 100644 index 0000000..0feee2b --- /dev/null +++ b/apps/web/src/assets/icons/socials/x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/assets/images/AstroPaper-v3.png b/apps/web/src/assets/images/AstroPaper-v3.png new file mode 100644 index 0000000..7b96741 Binary files /dev/null and b/apps/web/src/assets/images/AstroPaper-v3.png differ diff --git a/apps/web/src/assets/images/AstroPaper-v4.png b/apps/web/src/assets/images/AstroPaper-v4.png new file mode 100644 index 0000000..b4de557 Binary files /dev/null and b/apps/web/src/assets/images/AstroPaper-v4.png differ diff --git a/apps/web/src/assets/images/AstroPaper-v5.png b/apps/web/src/assets/images/AstroPaper-v5.png new file mode 100644 index 0000000..8fb4985 Binary files /dev/null and b/apps/web/src/assets/images/AstroPaper-v5.png differ diff --git a/apps/web/src/assets/images/astropaper-og.jpg b/apps/web/src/assets/images/astropaper-og.jpg new file mode 100644 index 0000000..3b351f9 Binary files /dev/null and b/apps/web/src/assets/images/astropaper-og.jpg differ diff --git a/apps/web/src/assets/images/forrest-gump-quote.png b/apps/web/src/assets/images/forrest-gump-quote.png new file mode 100644 index 0000000..37bdb35 Binary files /dev/null and b/apps/web/src/assets/images/forrest-gump-quote.png differ diff --git a/apps/web/src/components/Breadcrumb.astro b/apps/web/src/components/Breadcrumb.astro new file mode 100644 index 0000000..633f7c9 --- /dev/null +++ b/apps/web/src/components/Breadcrumb.astro @@ -0,0 +1,98 @@ +--- +import { getRelativeLocaleUrl } from "astro:i18n"; +import { stripBase, stripLocale } from "@/utils/withBase"; +import { useTranslations } from "@/i18n"; +import config from "@/config"; + +const locale = Astro.currentLocale ?? config.site.lang; +const t = useTranslations(locale); + +// Strip base prefix and trailing slash, then locale prefix so segments +// reflect the logical page path only. +const pathWithoutBase = stripBase(Astro.url.pathname).replace(/\/+$/, ""); +const currentUrlPath = stripLocale(pathWithoutBase, locale); + +// Get url array from path +// eg: /tags/tailwindcss => ['tags', 'tailwindcss'] +const breadcrumbList = currentUrlPath.split("/").slice(1).filter(Boolean); + +const decodeSegment = (value: string) => { + try { + return decodeURIComponent(value); + } catch { + return value; + } +}; + +const navLabels: Record = { + posts: t.nav.posts, + tags: t.nav.tags, + about: t.nav.about, + archives: t.nav.archives, + search: t.nav.search, +}; + +// if breadcrumb is Home > Posts > [page] +// replace Posts with localized "Posts (page number)" +if (breadcrumbList[0] === "posts") { + breadcrumbList.splice( + 0, + 2, + `${t.nav.posts} (${t.pagination.page.toLowerCase()} ${breadcrumbList[1] || 1})` + ); +} + +// if breadcrumb is Home > Tags > [tag] > [page] +// replace [tag] > [page] with localized [tag] (page number) +if (breadcrumbList[0] === "tags" && !isNaN(Number(breadcrumbList[2]))) { + breadcrumbList.splice( + 1, + 3, + `${decodeSegment(breadcrumbList[1])} ${ + Number(breadcrumbList[2]) === 1 + ? "" + : `(${t.pagination.page.toLowerCase()} ${breadcrumbList[2]})` + }` + ); +} +--- + + diff --git a/apps/web/src/components/Card.astro b/apps/web/src/components/Card.astro new file mode 100644 index 0000000..323757e --- /dev/null +++ b/apps/web/src/components/Card.astro @@ -0,0 +1,31 @@ +--- +import type { CollectionEntry } from "astro:content"; +import { getPostUrl } from "@/utils/getPostPaths"; +import { toTransitionName } from "@/utils/toTransitionName"; +import Datetime from "./Datetime.astro"; + +type Props = { + variant?: "h2" | "h3"; +} & CollectionEntry<"posts">; + +const { variant: Heading = "h2", id, data, filePath } = Astro.props; + +const { title, description, ...props } = data; +--- + +
  • + + + {title} + + + +

    {description}

    +
  • diff --git a/apps/web/src/components/Datetime.astro b/apps/web/src/components/Datetime.astro new file mode 100644 index 0000000..dfbedf0 --- /dev/null +++ b/apps/web/src/components/Datetime.astro @@ -0,0 +1,61 @@ +--- +import dayjs from "dayjs"; +import utc from "dayjs/plugin/utc"; +import timezone from "dayjs/plugin/timezone"; +import IconCalendar from "@/assets/icons/IconCalendar.svg"; +import config from "@/config"; +import { useTranslations } from "@/i18n"; + +dayjs.extend(utc); +dayjs.extend(timezone); + +type Props = { + class?: string; + size?: "sm" | "lg"; + pubDatetime: string | Date; + timezone?: string; + modDatetime?: string | Date | null; +}; + +const { + pubDatetime, + modDatetime, + size = "sm", + class: className = "", + timezone: postTimezone, +} = Astro.props; + +const t = useTranslations(Astro.currentLocale); + +const isModified = modDatetime && modDatetime > pubDatetime; + +const datetime = dayjs(isModified ? modDatetime : pubDatetime).tz( + postTimezone ?? config.site.timezone +); + +const date = datetime.format("D MMM, YYYY"); +--- + +
    + + { + isModified && ( + + {t.post.updatedAt}: + + ) + } + +
    diff --git a/apps/web/src/components/Footer.astro b/apps/web/src/components/Footer.astro new file mode 100644 index 0000000..9f4f3d6 --- /dev/null +++ b/apps/web/src/components/Footer.astro @@ -0,0 +1,30 @@ +--- +import type { HTMLAttributes } from "astro/types"; +import Socials from "./Socials.astro"; +import { useTranslations } from "@/i18n"; + +type Props = { + noMarginTop?: boolean; +} & HTMLAttributes<"footer">; + +const { noMarginTop = false, class: className, ...attrs } = Astro.props; + +const t = useTranslations(Astro.currentLocale); +const currentYear = new Date().getFullYear(); +--- + +
    +
    + +
    + {t.footer.copyright} © {currentYear} + + {t.footer.allRightsReserved} +
    +
    +
    diff --git a/apps/web/src/components/Header.astro b/apps/web/src/components/Header.astro new file mode 100644 index 0000000..9b494d3 --- /dev/null +++ b/apps/web/src/components/Header.astro @@ -0,0 +1,226 @@ +--- +import { getRelativeLocaleUrl } from "astro:i18n"; +import IconUnderline from "@/assets/icons/IconUnderline.svg"; +import IconMenuDeep from "@/assets/icons/IconMenuDeep.svg"; +import IconArchive from "@/assets/icons/IconArchive.svg"; +import IconSunHigh from "@/assets/icons/IconSunHigh.svg"; +import IconSearch from "@/assets/icons/IconSearch.svg"; +import IconMoon from "@/assets/icons/IconMoon.svg"; +import IconX from "@/assets/icons/IconX.svg"; +import LinkButton from "./LinkButton.astro"; +import { stripBase, stripLocale } from "@/utils/withBase"; +import { useTranslations } from "@/i18n"; +import config from "@/config"; + +const { site, features } = config; + +const locale = Astro.currentLocale ?? config.site.lang; +const t = useTranslations(locale); + +// Strip the base prefix so isActive comparisons work regardless of deploy subdirectory. +// e.g. with base "/blog": "/blog/posts/slug" → "/posts/slug" +const relativePath = stripBase(Astro.url.pathname); +const pathWithoutTrailingSlash = + relativePath.endsWith("/") && relativePath !== "/" + ? relativePath.slice(0, -1) + : relativePath; + +const currentPath = stripLocale(pathWithoutTrailingSlash, locale); + +const isActive = (path: string) => { + const currentPathArray = currentPath.split("/").filter(p => p.trim()); + const pathArray = path.split("/").filter(p => p.trim()); + return currentPath === path || currentPathArray[0] === pathArray[0]; +}; +--- + + + {t.a11y.skipToContent} + + +
    +
    + + {site.title} + + +
    +
    + + diff --git a/apps/web/src/components/LinkButton.astro b/apps/web/src/components/LinkButton.astro new file mode 100644 index 0000000..cfcc113 --- /dev/null +++ b/apps/web/src/components/LinkButton.astro @@ -0,0 +1,21 @@ +--- +import type { HTMLAttributes } from "astro/types"; + +type Props = { disabled?: boolean } & HTMLAttributes<"a">; + +const { disabled, class: className, ...attrs } = Astro.props; + +const Button = disabled ? "span" : "a"; +--- + + diff --git a/apps/web/src/components/Main.astro b/apps/web/src/components/Main.astro new file mode 100644 index 0000000..af65898 --- /dev/null +++ b/apps/web/src/components/Main.astro @@ -0,0 +1,38 @@ +--- +import { getRelativeLocaleUrl } from "astro:i18n"; +import config from "@/config"; + +type Props = { + pageTitle: string | [string, string]; + pageDesc?: string; + class?: string; +}; + +const { pageTitle, pageDesc, class: className } = Astro.props; + +const locale = Astro.currentLocale ?? config.site.lang; +const backUrl = config.features.showBackButton + ? Astro.url.pathname + : getRelativeLocaleUrl(locale, ""); +--- + +
    +

    {pageTitle}

    +

    {pageDesc}

    + +
    + + diff --git a/apps/web/src/components/Pagination.astro b/apps/web/src/components/Pagination.astro new file mode 100644 index 0000000..810825d --- /dev/null +++ b/apps/web/src/components/Pagination.astro @@ -0,0 +1,46 @@ +--- +import type { Page } from "astro"; +import type { CollectionEntry } from "astro:content"; +import IconArrowLeft from "@/assets/icons/IconArrowLeft.svg"; +import IconArrowRight from "@/assets/icons/IconArrowRight.svg"; +import LinkButton from "./LinkButton.astro"; +import { useTranslations } from "@/i18n"; + +type Props = { + page: Page>; +}; + +const { page } = Astro.props; + +const t = useTranslations(Astro.currentLocale); +--- + +{ + page.lastPage > 1 && ( + + ) +} diff --git a/apps/web/src/components/ResponsiveTable.astro b/apps/web/src/components/ResponsiveTable.astro new file mode 100644 index 0000000..c22ec25 --- /dev/null +++ b/apps/web/src/components/ResponsiveTable.astro @@ -0,0 +1,35 @@ +--- +type Props = { + class?: string; + variant?: + /** No borders */ + | "minimal" + /** 1st, 3rd, 5th … body rows tinted — classic zebra. */ + | "striped" + /** 1st, 3rd, 5th … body rows tinted + no borders. */ + | "striped-minimal"; +}; + +const { class: className, variant } = Astro.props; + +const variantClasses = { + minimal: "[&_td]:border-0 [&_th]:border-0", + striped: "[&_tbody_tr]:odd:bg-muted/25", +}; +--- + +
    +
    + +
    +
    diff --git a/apps/web/src/components/Socials.astro b/apps/web/src/components/Socials.astro new file mode 100644 index 0000000..8278330 --- /dev/null +++ b/apps/web/src/components/Socials.astro @@ -0,0 +1,36 @@ +--- +import config from "@/config"; +import LinkButton from "./LinkButton.astro"; + +const { site, socials } = config; + +const icons = import.meta.glob<{ + default: (_props: Record) => unknown; +}>("/src/assets/icons/socials/*.svg"); + +const items = await Promise.all( + socials.map(async ({ name, url, linkTitle }) => { + const mod = await icons[`/src/assets/icons/socials/${name}.svg`]?.(); + const Icon = mod?.default; + const title = + linkTitle ?? + (url.startsWith("mailto:") || name === "mail" + ? `Send an email to ${site.title}` + : `${site.title} on ${name.charAt(0).toUpperCase() + name.slice(1)}`); + return { url, title, Icon }; + }) +); +--- + +
    + { + items.map(({ url, title, Icon }) => + Icon ? ( + + + {title} + + ) : null + ) + } +
    diff --git a/apps/web/src/components/Tag.astro b/apps/web/src/components/Tag.astro new file mode 100644 index 0000000..9d2ad9f --- /dev/null +++ b/apps/web/src/components/Tag.astro @@ -0,0 +1,39 @@ +--- +import { getRelativeLocaleUrl } from "astro:i18n"; +import IconHash from "@/assets/icons/IconHash.svg"; +import config from "@/config"; + +type Props = { + tag: string; + tagName: string; + size?: "sm" | "lg"; +}; + +const { tag, tagName, size = "lg" } = Astro.props; + +const locale = Astro.currentLocale ?? config.site.lang; +--- + +
  • + + + {tagName} + +
  • diff --git a/apps/web/src/config.ts b/apps/web/src/config.ts new file mode 100644 index 0000000..885b6b9 --- /dev/null +++ b/apps/web/src/config.ts @@ -0,0 +1,43 @@ +/** + * Internal resolved configuration used throughout the codebase. + * + * Prefer editing `astro-paper.config.ts` instead of this file. This module exists to + * apply defaults and expose a fully-resolved config shape (`ResolvedAstroPaperConfig`). + */ +import userConfig from "@/astro-paper.config"; +import type { ResolvedAstroPaperConfig } from "./types/config"; +import { PUBLIC_GOOGLE_SITE_VERIFICATION } from "astro:env/client"; + +const DEFAULT_OG_IMAGE = "default-og.jpg"; + +const config: ResolvedAstroPaperConfig = { + site: { + ...userConfig.site, + // The origin the build was made for (astro.config.ts's `site`). + url: import.meta.env.SITE ?? userConfig.site.url, + ogImage: userConfig.site.ogImage ?? DEFAULT_OG_IMAGE, + lang: userConfig.site.lang ?? "en", + timezone: userConfig.site.timezone ?? "UTC", + dir: userConfig.site.dir ?? "ltr", + googleVerification: + userConfig.site.googleVerification || PUBLIC_GOOGLE_SITE_VERIFICATION, + }, + posts: { + perPage: userConfig.posts?.perPage ?? 4, + perIndex: userConfig.posts?.perIndex ?? 4, + scheduledPostMargin: + userConfig.posts?.scheduledPostMargin ?? 15 * 60 * 1000, + }, + features: { + lightAndDarkMode: userConfig.features?.lightAndDarkMode ?? true, + dynamicOgImage: userConfig.features?.dynamicOgImage ?? true, + showArchives: userConfig.features?.showArchives ?? true, + showBackButton: userConfig.features?.showBackButton ?? true, + editPost: userConfig.features?.editPost ?? { enabled: false }, + search: userConfig.features?.search ?? "pagefind", + }, + socials: userConfig.socials ?? [], + shareLinks: userConfig.shareLinks ?? [], +}; + +export default config; diff --git a/apps/web/src/content.config.ts b/apps/web/src/content.config.ts new file mode 100644 index 0000000..77517be --- /dev/null +++ b/apps/web/src/content.config.ts @@ -0,0 +1,37 @@ +import { defineCollection } from "astro:content"; +import { z } from "astro/zod"; +import { glob } from "astro/loaders"; +import config from "@/config"; + +export const BLOG_PATH = "src/content/posts"; + +const posts = defineCollection({ + loader: glob({ pattern: "**/[^_]*.{md,mdx}", base: `./${BLOG_PATH}` }), + schema: ({ image }) => + z.object({ + author: z.string().default(config.site.author), + pubDatetime: z.date(), + modDatetime: z.date().optional().nullable(), + title: z.string(), + featured: z.boolean().optional(), + draft: z.boolean().optional(), + tags: z.array(z.string()).default(["others"]), + ogImage: image().or(z.string()).optional(), + description: z.string(), + canonicalURL: z.string().optional(), + hideEditPost: z.boolean().optional(), + timezone: z.string().optional(), + }), +}); + +const pages = defineCollection({ + loader: glob({ pattern: "**/[^_]*.{md,mdx}", base: "./src/content/pages" }), + schema: z.object({ + title: z.string(), + description: z.string().optional(), + ogImage: z.string().optional(), + canonicalURL: z.string().optional(), + }), +}); + +export const collections = { posts, pages }; diff --git a/apps/web/src/content/pages/about.md b/apps/web/src/content/pages/about.md new file mode 100644 index 0000000..ac6c021 --- /dev/null +++ b/apps/web/src/content/pages/about.md @@ -0,0 +1,37 @@ +--- +title: "About" +description: "A bit about me and this blog." +--- + +AstroPaper is a minimal, accessible and SEO-friendly blog theme built with [Astro](https://astro.build/) and [Tailwind CSS](https://tailwindcss.com/). + +![Astro Paper](@/assets/images/astropaper-og.jpg) + +AstroPaper provides a solid foundation for blogs, or even portfolios\_ with full markdown support, built-in dark mode, and a clean layout that works out-of-the-box. + +The blog posts in this theme also serve as guides, docs or example articles\_ making AstroPaper a flexible starting point for your next content-driven site. + +## Features + +AstroPaper comes with a set of useful features that make content publishing easy and effective: + +- SEO-friendly +- Fast performance +- Light & dark mode +- Highly customizable +- Organizable blog posts +- Responsive & accessible +- Static search with [PageFind](https://pagefind.app/) +- Automatic social image generation + +and so much more. + +## Show your support + +If you like [AstroPaper](https://github.com/satnaing/astro-paper), consider giving it a star ⭐️. + +Found a bug 🐛 or have an improvement ✨ in mind? Feel free to open an [issue](https://github.com/satnaing/astro-paper/issues), submit a [pull request](https://github.com/satnaing/astro-paper/pulls) or start a [discussion](https://github.com/satnaing/astro-paper/discussions). + +If you find this theme helpful, you can also [sponsor me on GitHub](https://github.com/sponsors/satnaing) or [buy me a coffee](https://buymeacoffee.com/satnaing) to show your support — every penny counts. + +Kyay zuu! 🙏🏼 diff --git a/apps/web/src/content/posts/_color-schemes/assets/ember.png b/apps/web/src/content/posts/_color-schemes/assets/ember.png new file mode 100644 index 0000000..fd8ed79 Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/ember.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/espresso.png b/apps/web/src/content/posts/_color-schemes/assets/espresso.png new file mode 100644 index 0000000..056c20c Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/espresso.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/jadeite.png b/apps/web/src/content/posts/_color-schemes/assets/jadeite.png new file mode 100644 index 0000000..404e39f Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/jadeite.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/kha-yan.png b/apps/web/src/content/posts/_color-schemes/assets/kha-yan.png new file mode 100644 index 0000000..c9740ae Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/kha-yan.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/nila.png b/apps/web/src/content/posts/_color-schemes/assets/nila.png new file mode 100644 index 0000000..c09ac32 Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/nila.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/paper-light.png b/apps/web/src/content/posts/_color-schemes/assets/paper-light.png new file mode 100644 index 0000000..876cc09 Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/paper-light.png differ diff --git a/apps/web/src/content/posts/_color-schemes/assets/pyit-tine-htaung.png b/apps/web/src/content/posts/_color-schemes/assets/pyit-tine-htaung.png new file mode 100644 index 0000000..b34a238 Binary files /dev/null and b/apps/web/src/content/posts/_color-schemes/assets/pyit-tine-htaung.png differ diff --git a/apps/web/src/content/posts/_color-schemes/predefined-color-schemes.mdx b/apps/web/src/content/posts/_color-schemes/predefined-color-schemes.mdx new file mode 100644 index 0000000..85be30e --- /dev/null +++ b/apps/web/src/content/posts/_color-schemes/predefined-color-schemes.mdx @@ -0,0 +1,235 @@ +--- +author: Sat Naing +pubDatetime: 2022-09-26T12:13:24Z +modDatetime: 2026-05-16T11:29:26.658Z +title: Predefined color schemes +slug: predefined-color-schemes +featured: false +draft: false +tags: + - color-schemes +description: + Some of the well-crafted, updated predefined color schemes for AstroPaper. + +--- + +import ResponsiveTable from '@/components/ResponsiveTable.astro'; + +AstroPaper includes a collection of predefined color schemes that can be applied to customize the theme appearance. Each scheme defines a complete set of CSS custom properties (variables) for light and dark modes. + +## Table of contents + +## Quick Start + +To apply a predefined color scheme, copy the CSS variable definitions into your theme configuration. For detailed setup instructions, see the [color scheme configuration guide](https://astro-paper.pages.dev/posts/customizing-astropaper-theme-color-schemes/). + +## CSS Variables Reference + +All color schemes use the following CSS custom properties: + + + +| Variable | Purpose | +| --------------------- | -------------------------------------------------------- | +| `--background` | Primary background color | +| `--foreground` | Primary text color | +| `--accent` | Accent/interactive elements (links, buttons, highlights) | +| `--accent-foreground` | Text color on accent backgrounds | +| `--muted` | Secondary background color for subtle sections | +| `--muted-foreground` | Text color for secondary content | +| `--border` | Border and divider color | + + + +## Light Schemes + +Light color schemes are defined using the CSS selectors `:root` and `[data-theme="light"]`. + +### Paper Light + +Default AstroPaper light theme. + +![Paper Light](assets/paper-light.png) + +```css +:root, +[data-theme="light"] { + --background: #fdfdfd; + --foreground: #282728; + --accent: #006cac; + --accent-foreground: #ffffff; + --muted: #e6e6e6; + --muted-foreground: #6b7280; + --border: #ece9e9; +} +``` + +### Kha-Yan + +Purple-focused light scheme with warm background. + +![Kha-Yan](assets/kha-yan.png) + +```css +:root, +[data-theme="light"] { + --background: #fefaec; + --foreground: #120e01; + --accent: #6e10cf; + --accent-foreground: #fefaec; + --muted: #dcdcdc; + --muted-foreground: #6b7280; + --border: #cdc4d6; +} +``` + +### Nila + +Light purple scheme with cool blue undertones. + +![Nila](assets/nila.png) + +```css +:root, +[data-theme="light"] { + --background: #f6f6fb; + --foreground: #0c0c19; + --accent: #6760b4; + --accent-foreground: #f3f3f3; + --muted: #dddcea; + --muted-foreground: #54515b; + --border: #d8d6ec; +} +``` + +### Jadeite + +Teal-accented light scheme with neutral background. + +![Jadeite](assets/jadeite.png) + +```css +:root, +[data-theme="light"] { + --background: #f6fcf7; + --foreground: #060b07; + --accent: #027c6d; + --accent-foreground: #ffffff; + --muted: #c9e4e2; + --muted-foreground: #6b7280; + --border: #d4e1df; +} +``` + +### Pyit Tine Htaung + +Red and gold accent scheme with warm tones. + +![Pyit Tine Htaung](assets/pyit-tine-htaung.png) + +```css +:root, +[data-theme="light"] { + --background: #fffaf6; + --foreground: #060503; + --accent: #aa0215; + --accent-foreground: #ffcf75; + --muted: #ffdc98; + --muted-foreground: #54515b; + --border: #ffdc98; +} +``` + +## Dark Schemes + +Dark color schemes are defined using the CSS selector `[data-theme="dark"]`. + +### Paper Dark + +Original AstroPaper dark theme with cyan accents. + +![AstroPaper 1 default dark theme](https://user-images.githubusercontent.com/53733092/215769153-13b0ad8d-5ba2-44b1-af06-e5ae61293f62.png) + +```css +[data-theme="dark"] { + --background: #2f3741; + --foreground: #e6e6e6; + --accent: #1ad9d9; + --accent-foreground: #0d2b2b; + --muted: #596b81; + --muted-foreground: #8faabb; + --border: #3b4655; +} +``` + +### Paper Dark II + +Current default dark theme with orange accents. + +![new dark color scheme - low contrast](https://user-images.githubusercontent.com/53733092/215772856-d5b7ae35-ddaa-4ed6-b0bf-3fa5dbcf834c.png) + +```css +[data-theme="dark"] { + --background: #212737; + --foreground: #eaedf3; + --accent: #ff6b01; + --accent-foreground: #ffffff; + --muted: #343f60; + --muted-foreground: #afb9ca; + --border: #ab4b08; +} +``` + +### Deep Purple + +Vibrant magenta accents dark scheme. + +![AstroPaper v3 new theme](https://github.com/satnaing/astro-paper/assets/53733092/c8b5d7e1-a3bc-4852-a5ad-4abf7b3cec79) + +```css +[data-theme="dark"] { + --background: #212737; + --foreground: #eaedf3; + --accent: #eb3fd3; + --accent-foreground: #1a0d1a; + --muted: #513f51; + --muted-foreground: #c09abc; + --border: #642451; +} +``` + +### Ember + +Warm, muted dark scheme with red accents. + +![Ember](assets/ember.png) + +```css +[data-theme="dark"] { + --background: #1a1a1a; + --foreground: #f5efe4; + --accent: #ff3737; + --accent-foreground: #1a1a1a; + --muted: #38342f; + --muted-foreground: #a59a8c; + --border: #6f5648; +} +``` + +### Espresso + +Brown-focused warm dark scheme. + +![Coffee](assets/espresso.png) + +```css +[data-theme="dark"] { + --background: #2f2f2f; + --foreground: #ebe5e1; + --accent: #ee781e; + --accent-foreground: #1a1a1a; + --muted: #4f4b44; + --muted-foreground: #ddbfa7; + --border: #6f5648; +} +``` diff --git a/apps/web/src/content/posts/_releases/assets/AstroPaper-v6.png b/apps/web/src/content/posts/_releases/assets/AstroPaper-v6.png new file mode 100644 index 0000000..088b4c9 Binary files /dev/null and b/apps/web/src/content/posts/_releases/assets/AstroPaper-v6.png differ diff --git a/apps/web/src/content/posts/_releases/astro-paper-2.md b/apps/web/src/content/posts/_releases/astro-paper-2.md new file mode 100644 index 0000000..092606b --- /dev/null +++ b/apps/web/src/content/posts/_releases/astro-paper-2.md @@ -0,0 +1,91 @@ +--- +author: Sat Naing +pubDatetime: 2023-01-30T15:57:52.737Z +title: AstroPaper 2.0 +slug: astro-paper-2 +featured: false +ogImage: https://user-images.githubusercontent.com/53733092/215771435-25408246-2309-4f8b-a781-1f3d93bdf0ec.png +tags: + - release +description: AstroPaper with the enhancements of Astro v2. Type-safe markdown contents, bug fixes and better dev experience etc. +--- + +Astro 2.0 has been released with some cool features, breaking changes, DX improvements, better error overlay and so on. AstroPaper takes advantage of those cool features, especially Content Collections API. + + + +![Introducing AstroPaper 2.0](https://user-images.githubusercontent.com/53733092/215771435-25408246-2309-4f8b-a781-1f3d93bdf0ec.png) + +## Table of contents + +## Features & Changes + +### Type-safe Frontmatters and Redefined Blog Schema + +Frontmatter of AstroPaper 2.0 markdown contents are now type-safe thanks to Astro’s Content Collections. Blog schema is defined inside the `src/content/_schemas.ts` file. + +### New Home for Blog contents + +All the blog posts were moved from `src/contents` to `src/content/blog` directory. + +### New Fetch API + +Contents are now fetched with `getCollection` function. No relative path to the content needs to be specified anymore. + +```ts +// old content fetching method +- const postImportResult = import.meta.glob>( + "../contents/**/**/*.md",); + +// new content fetching method ++ const postImportResult = await getCollection("blog"); +``` + +### Modified Search Logic for better Search Result + +In the older version of AstroPaper, when someone search some article, the search criteria keys that will be searched are `title`, `description` and `headings` (heading means all the headings h1 ~ h6 of the blog post). In AstroPaper v2, only `title` and `description` will be searched as the user types. + +### Renamed Frontmatter Properties + +The following frontmatter properties are renamed. + +| Old Names | New Names | +| --------- | ----------- | +| datetime | pubDatetime | +| slug | postSlug | + +### Default Tag for blog post + +If a blog post doesn't have any tag (in other words, frontmatter property `tags` is not specified), the default tag `others` will be used for that blog post. But you can set the default tag in the `/src/content/_schemas.ts` file. + +```ts +// src/contents/_schemas.ts +export const blogSchema = z.object({ + // --- + // replace "others" with whatever you want + tags: z.array(z.string()).default(["others"]), + ogImage: z.string().optional(), + description: z.string(), +}); +``` + +### New Predefined Dark Color Scheme + +AstroPaper v2 has a new dark color scheme (high contrast & low contrast) which is based on Astro's dark logo. Check out [this link](https://astro-paper.pages.dev/posts/predefined-color-schemes#astro-dark) for more info. + +![New Predefined Dark Color Scheme](https://user-images.githubusercontent.com/53733092/215680520-59427bb0-f4cb-48c0-bccc-f182a428d72d.svg) + +### Automatic Class Sorting + +AstroPaper 2.0 includes automatic class sorting with [TailwindCSS Prettier plugin](https://tailwindcss.com/blog/automatic-class-sorting-with-prettier) + +### Updated Docs & README + +All the [#docs](https://astro-paper.pages.dev/tags/docs/) blog posts and [README](https://github.com/satnaing/astro-paper#readme) are updated for this AstroPaper v2. + +## Bug Fixes + +- fix broken tags in the Blog Post page +- in a tag page, the last part of the breadcrumb is now updated to lower-case for consistency +- exclude draft posts in a tag page +- fix 'onChange value not updating issue' after a page reload diff --git a/apps/web/src/content/posts/_releases/astro-paper-3.md b/apps/web/src/content/posts/_releases/astro-paper-3.md new file mode 100644 index 0000000..0bb2f1c --- /dev/null +++ b/apps/web/src/content/posts/_releases/astro-paper-3.md @@ -0,0 +1,173 @@ +--- +author: Sat Naing +pubDatetime: 2023-09-25T10:25:54.547Z +title: AstroPaper 3.0 +slug: astro-paper-v3 +featured: false +ogImage: https://github.com/satnaing/astro-paper/assets/53733092/1ef0cf03-8137-4d67-ac81-84a032119e3a +tags: + - release +description: "AstroPaper Version 3: Elevating Your Web Experience with Astro v3 and Seamless View Transitions" +--- + +We're excited to announce the release of AstroPaper v3, packed with new features, enhancements, and bug fixes to elevate your web development experience. Let's dive into the highlights of this release: + +![AstroPaper v3](@/assets/images/AstroPaper-v3.png) + +## Table of contents + +## Features & Changes + +### Astro v3 Integration + + + +AstroPaper now fully supports [Astro v3](https://astro.build/blog/astro-3/), offering improved performance and rendering speed. + +Besides, we've added support for Astro's [ViewTransitions API](https://docs.astro.build/en/guides/view-transitions/), allowing you to create captivating and dynamic transitions between views. + +In the "Recent Section", only non-featured posts will be displayed to avoid duplications and better support for ViewTransitions API. + +### Update OG Image Generation Logic + +![Example OG Image](https://user-images.githubusercontent.com/40914272/269252964-a0dc6735-80f7-41ed-8e74-4d4d70f96891.png) + +We've updated the logic for automatic OG image generation, making it even more reliable and efficient. Besides, it now supports special characters in post titles, ensuring accurate, flexible and eye-catching social media previews. + +`SITE.ogImage` is now optional. If it is not specified, AstroPaper will automatically generate an OG image using `SITE.title`, `SITE.desc` and `SITE.website` + +### Theme meta tag + +The theme-color meta tag has been added to dynamically adapt to theme switches, ensuring a seamless user experience. + +> Notice the difference at the top + +**_AstroPaper v2 theme switch_** + + + +**_AstroPaper v3 theme switch_** + + + +## Other Changes + +### Astro Prettier Plugin + +Astro Prettier Plugin is installed out-of-the-box in order to keep the project tidy and organized. + +### Minor Style Changes + +The single-line code block wrapping issue has been solved, making your code snippets look pristine. + +Update nav style CSS to allow adding more nav links to the navigation. + +## Upgrade to AstroPaper v3 + +> This section is only for those who want to upgrade AstroPaper v3 from the older versions. + +This section will help you migrate from AstroPaper v2 to AstroPaper v3. + +Before reading the rest of the section, you might also want to check [this article](https://astro-paper.pages.dev/posts/how-to-update-dependencies/) for upgrading dependencies and AstroPaper. + +## Option 1: Fresh Restart (recommended) + +In this release, a lot of changes have been made\_ replacing old Astro APIs with newer APIs, bug fixes, new features etc. Thus, if you are someone who didn't make customization very much, you should follow this approach. + +**_Step 1: Keep all your updated files_** + +It's important to keep all the files which have been already updated. These files include + +- `/src/config.ts` (didn't touch in v3) +- `/src/styles/base.css` (minor changes in v3; mentioned below) +- `/src/assets/` (didn't touch in v3) +- `/public/assets/` (didn't touch in v3) +- `/content/blog/` (it's your blog content directory 🤷🏻‍♂️) +- Any other customizations you've made. + +```css +/* file: /src/styles/base.css */ +@layer base { + /* Other Codes */ + ::-webkit-scrollbar-thumb:hover { + @apply bg-skin-card-muted; + } + + /* Old code + code { + white-space: pre; + overflow: scroll; + } + */ + + /* New code */ + code, + blockquote { + word-wrap: break-word; + } + pre > code { + white-space: pre; + } +} + +@layer components { + /* other codes */ +} +``` + +**_Step 1: Replace everything else with AstroPaper v3_** + +In this step, replace everything\_ except above files/directories (plus your customized files/directories)\_ with AstroPaper v3. + +**_Step 3: Schema Updates_** + +Keep in mind that `/src/content/_schemas.ts` has been replaced with `/src/content/config.ts`. + +Besides, there is no longer `BlogFrontmatter` type exported from `/src/content/config.ts`. + +Therefore, all the `BlogFrontmatter` type inside files need to be updated with `CollectionEntry<"blog">["data"]`. + +For example: `src/components/Card.tsx` + +```ts +// AstroPaper v2 +import type { BlogFrontmatter } from "@content/_schemas"; + +export interface Props { + href?: string; + frontmatter: BlogFrontmatter; + secHeading?: boolean; +} +``` + +```ts +// AstroPaper v3 +import type { CollectionEntry } from "astro:content"; + +export interface Props { + href?: string; + frontmatter: CollectionEntry<"blog">["data"]; + secHeading?: boolean; +} +``` + +## Option 2: Upgrade using Git + +This approach is not recommended for most users. You should do the "Option 1" if you can. Only do this if you know how to resolve merge conflicts and you know what you're doing. + +Actually, I've already written a blog post for this case and you can check out [here](https://astro-paper.pages.dev/posts/how-to-update-dependencies/#updating-astropaper-using-git). + +## Outro + +Ready to explore the exciting new features and improvements in AstroPaper v3? Start [using AstroPaper](https://github.com/satnaing/astro-paper) now. + +For other bug fixes and integration updates, check out the [release notes](https://github.com/satnaing/astro-paper/releases/tag/v3.0.0) to learn more. + +If you encounter any bugs or face difficulties during the upgrade process, please feel free to open an issue or start a discussion on [GitHub](https://github.com/satnaing/astro-paper). diff --git a/apps/web/src/content/posts/_releases/astro-paper-4.md b/apps/web/src/content/posts/_releases/astro-paper-4.md new file mode 100644 index 0000000..89d40ef --- /dev/null +++ b/apps/web/src/content/posts/_releases/astro-paper-4.md @@ -0,0 +1,124 @@ +--- +author: Sat Naing +pubDatetime: 2024-01-04T09:30:41.816Z +title: AstroPaper 4.0 +slug: "astro-paper-v4" +featured: false +ogImage: ../../../assets/images/AstroPaper-v4.png +tags: + - release +description: "AstroPaper v4: ensuring a smoother and more feature-rich blogging experience." +--- + +Hello everyone! Wishing you a happy New Year 🎉 and all the best for 2024! We're excited to announce the release of AstroPaper v4, a significant update that introduces a range of new features, improvements, and bug fixes to elevate your blogging experience. A big thank you to all the contributors for their valuable input and efforts in making version 4 possible! + +![AstroPaper v4](@/assets/images/AstroPaper-v4.png) + +## Table of contents + +## Major Changes + +### Upgrade to Astro v4 [#202](https://github.com/satnaing/astro-paper/pull/202) + +AstroPaper now leverages the power and capabilities of Astro v4. However, it’s a subtle upgrade and won’t break most Astro users. + +![Astro v4](https://astro.build/_astro/header-astro-4.YunweN9V_OmV0l.webp) + +### Replace `postSlug` with Astro Content `slug` [#197](https://github.com/satnaing/astro-paper/pull/197) + +The `postSlug` in the blog content schema is no longer available in AstroPaper v4. Initially Astro doesn't have a `slug` mechanism and thus we have to figure it out on our own. Since Astro v3, it supports content collection and slug features. Now, we believe it's time to adopt Astro's out-of-the-box `slug` feature. + +**_file: src/content/blog/astro-paper-4.md_** + +```bash +--- +author: Sat Naing +pubDatetime: 2024-01-01T04:35:33.428Z +title: AstroPaper 4.0 +slug: "astro-paper-v4" # if slug is not specified, it will be 'astro-paper-4' (file name). +# slug: "" ❌ cannot be an empty string +--- +``` + +The behavior of the `slug` is slightly different now. In the previous versions of AstroPaper, if the `postSlug` is not specified in a blog post (markdown file), the title of that blog post would be slugified and used as the `slug`. However, in AstroPaper v4, if the `slug` field is not specified, the markdown file name will be used as the `slug`. One thing to keep in mind is that the `slug` field can be omitted, but it cannot be an empty string (slug: "" ❌). + +If you're upgrading AstroPaper from v3 to v4, make sure to replace `postSlug` in your `src/content/blog/*.md` files with `slug`. + +## New Features + +### Add code-snippets for content creation [#206](https://github.com/satnaing/astro-paper/pull/206) + +AstroPaper now includes VSCode snippets for new blog posts, eliminating the need for manual copy/pasting of the frontmatter and content structure (table of contents, heading, excerpt, etc.). + +Read more about VSCode Snippets [here](https://code.visualstudio.com/docs/editor/userdefinedsnippets#:~:text=In%20Visual%20Studio%20Code%2C%20snippets,Snippet%20in%20the%20Command%20Palette). + + + +### Add Modified Datetime in Blog Posts [#195](https://github.com/satnaing/astro-paper/pull/195) + +Keep readers informed about the latest updates by displaying the modified datetime in blog posts. This not only instills user trust in the freshness of the articles but also contributes to improved SEO for the blog. + +![Last Modified Date feature in AstroPaper](https://github.com/satnaing/astro-paper/assets/53733092/cc89585e-148e-444d-9da1-0d496e867175) + +You can add a `modDatetime` to your blog post if you've made modifications. Now, the sorting behavior of the posts is slightly different. All posts are sorted by both `pubDatetime` and `modDatetime`. If a post has both a `pubDatetime` and `modDatetime`, its sorting position will be determined by the `modDatetime`. If not, only `pubDatetime` will be considered to determine the post's sorting order. + +### Implement Back-to-Top Button [#188](https://github.com/satnaing/astro-paper/pull/188) + +Enhance user navigation on your blog detail post with the newly implemented back-to-top button. + +![Back to top button in AstroPaper](https://github.com/satnaing/astro-paper/assets/53733092/79854957-7877-4f19-936e-ad994b772074) + +### Add Pagination in Tag Posts [#201](https://github.com/satnaing/astro-paper/pull/201) + +Improve content organization and navigation with the addition of pagination in tag posts, making it easier for users to explore related content. This ensures that if a tag has many posts, readers won't be overwhelmed by all the tag-related posts. + + + +### Dynamically Generate robots.txt [#130](https://github.com/satnaing/astro-paper/pull/130) + +AstroPaper v4 now dynamically generates the robots.txt file, giving you more control over search engine indexing and web crawling. Besides, sitemap URL will also be added inside `robot.txt` file. + +### Add Docker-Compose File [#174](https://github.com/satnaing/astro-paper/pull/174) + +Managing your AstroPaper environment is now easier than ever with the addition of a Docker-Compose file, simplifying deployment and configuration. + +## Refactoring & Bug Fixes + +### Replace Slugified Title with Unslugified Tag Name [#198](https://github.com/satnaing/astro-paper/pull/198) + +To improve clarity, user experience and SEO, titles (`Tag: some-tag`) in tag page are no longer slugified (`Tag: Some Tag`). + +![Unslugified Tag Names](https://github.com/satnaing/astro-paper/assets/53733092/2fe90d6e-ec52-467b-9c44-95009b3ae0b7) + +### Implement 100svh for Min-Height ([79d569d](https://github.com/satnaing/astro-paper/commit/79d569d053036f2113519f41b0d257523d035b76)) + +We've updated the min-height on the body to use 100svh, offering a better UX for mobile users. + +### Update Site URL as Single Source of Truth [#143](https://github.com/satnaing/astro-paper/pull/143) + +The site URL is now a single source of truth, streamlining configuration and avoiding inconsistencies. Read more at this [PR](https://github.com/satnaing/astro-paper/pull/143) and its related issue(s). + +### Solve Invisible Text Code Block Issue in Light Mode [#163](https://github.com/satnaing/astro-paper/pull/163) + +We've fixed the invisible text code block issue in light mode. + +### Decode Unicode Tag Characters in Breadcrumb [#175](https://github.com/satnaing/astro-paper/pull/175) + +The last part of Tag in the breadcrumb is now decoded, making non-English Unicode characters display better. + +### Update LOCALE Config to Cover Overall Locales ([cd02b04](https://github.com/satnaing/astro-paper/commit/cd02b047d2b5e3b4a2940c0ff30568cdebcec0b8)) + +The LOCALE configuration has been updated to cover a broader range of locales, catering to a more diverse audience. + +## Outtro + +We believe these updates will significantly elevate your AstroPaper experience. Thank you to everyone who contributed, solved issues, and gave stars to AstroPaper. We look forward to seeing the amazing content you create with AstroPaper v4! + +Happy Blogging! + +[Sat Naing](https://satnaing.dev)
    +Creator of AstroPaper diff --git a/apps/web/src/content/posts/_releases/astro-paper-5.md b/apps/web/src/content/posts/_releases/astro-paper-5.md new file mode 100644 index 0000000..df2e1c5 --- /dev/null +++ b/apps/web/src/content/posts/_releases/astro-paper-5.md @@ -0,0 +1,101 @@ +--- +pubDatetime: 2025-03-08T08:18:19.693Z +title: AstroPaper 5.0 +slug: astro-paper-v5 +featured: false +ogImage: ../../../assets/images/AstroPaper-v5.png +tags: + - release +description: "AstroPaper v5: keep the clean look, updates under the hood." +--- + +At last, the long-awaited AstroPaper v5 is finally here. AstroPaper v5 keeps the same minimal & clean look, but comes with significant updates under the hood. + +![AstroPaper v5](@/assets/images/AstroPaper-v5.png) + +## Table of contents + +## Major Changes + +### Upgrade to Astro v5 [#455](https://github.com/satnaing/astro-paper/pull/455) + +AstroPaper now comes with Astro v5, bringing all the new features and improvements that come with it. + +### Tailwind v4 + +AstroPaper has been upgraded to Tailwind v4, which includes many style changes under the hood. The `tailwind.config.js` file has been removed, and now all the configuration is located within the `src/styles/global.css` file. Typography-related styles have been extracted and moved to `src/styles/typography.css`. + +Due to the new behavior in TailwindCSS v4, styles inside ` diff --git a/apps/web/src/pages/tags/[tag]/[...page].astro b/apps/web/src/pages/tags/[tag]/[...page].astro new file mode 100644 index 0000000..9087f1f --- /dev/null +++ b/apps/web/src/pages/tags/[tag]/[...page].astro @@ -0,0 +1,57 @@ +--- +import { getCollection } from "astro:content"; +import type { GetStaticPathsOptions } from "astro"; +import Layout from "@/layouts/Layout.astro"; +import Header from "@/components/Header.astro"; +import Main from "@/components/Main.astro"; +import Breadcrumb from "@/components/Breadcrumb.astro"; +import Card from "@/components/Card.astro"; +import Footer from "@/components/Footer.astro"; +import Pagination from "@/components/Pagination.astro"; +import { getUniqueTags } from "@/utils/getUniqueTags"; +import { getSortedPosts } from "@/utils/getSortedPosts"; +import { slugifyAll } from "@/utils/slugify"; +import { useTranslations } from "@/i18n"; +import config from "@/config"; + +export async function getStaticPaths({ paginate }: GetStaticPathsOptions) { + const posts = await getCollection("posts", ({ data }) => !data.draft); + const tags = getUniqueTags(posts); + + return tags.flatMap(({ tag, tagName }) => { + const tagPosts = getSortedPosts( + posts.filter(({ data }) => slugifyAll(data.tags).includes(tag)) + ); + + return paginate(tagPosts, { + params: { tag }, + props: { tagName }, + pageSize: config.posts.perPage, + }); + }); +} + +const { page, tagName } = Astro.props; + +const locale = Astro.currentLocale ?? config.site.lang; +const t = useTranslations(locale); +--- + + +
    + + + +
    +
      + {page.data.map(data => )} +
    +
    + + + +