From 456cf011b36de91c9936994b1fa45703adcd309b Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Thu, 3 Jul 2025 10:56:21 +0300 Subject: Initial fork of chrismwilliams/astro-theme-cactus theme --- astro.config.ts | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 astro.config.ts (limited to 'astro.config.ts') diff --git a/astro.config.ts b/astro.config.ts new file mode 100644 index 0000000..287a6de --- /dev/null +++ b/astro.config.ts @@ -0,0 +1,119 @@ +import fs from "node:fs"; +// Rehype plugins +import { rehypeHeadingIds } from "@astrojs/markdown-remark"; +import mdx from "@astrojs/mdx"; +import sitemap from "@astrojs/sitemap"; +import tailwind from "@tailwindcss/vite"; +import { defineConfig, envField } from "astro/config"; +import expressiveCode from "astro-expressive-code"; +import icon from "astro-icon"; +import robotsTxt from "astro-robots-txt"; +import webmanifest from "astro-webmanifest"; +import rehypeAutolinkHeadings from "rehype-autolink-headings"; +import rehypeExternalLinks from "rehype-external-links"; +import rehypeUnwrapImages from "rehype-unwrap-images"; +// Remark plugins +import remarkDirective from "remark-directive"; /* Handle ::: directives as nodes */ +import { remarkAdmonitions } from "./src/plugins/remark-admonitions"; /* Add admonitions */ +import { remarkReadingTime } from "./src/plugins/remark-reading-time"; +import { expressiveCodeOptions, siteConfig } from "./src/site.config"; + +// https://astro.build/config +export default defineConfig({ + site: siteConfig.url, + image: { + domains: ["webmention.io"], + }, + integrations: [ + expressiveCode(expressiveCodeOptions), + icon(), + sitemap(), + mdx(), + robotsTxt(), + webmanifest({ + // See: https://github.com/alextim/astro-lib/blob/main/packages/astro-webmanifest/README.md + name: siteConfig.title, + short_name: "Astro_Cactus", // optional + description: siteConfig.description, + lang: siteConfig.lang, + icon: "public/icon.svg", // the source for generating favicon & icons + icons: [ + { + src: "icons/apple-touch-icon.png", // used in src/components/BaseHead.astro L:26 + sizes: "180x180", + type: "image/png", + }, + { + src: "icons/icon-192.png", + sizes: "192x192", + type: "image/png", + }, + { + src: "icons/icon-512.png", + sizes: "512x512", + type: "image/png", + }, + ], + start_url: "/", + background_color: "#1d1f21", + theme_color: "#2bbc8a", + display: "standalone", + config: { + insertFaviconLinks: false, + insertThemeColorMeta: false, + insertManifestLink: false, + }, + }), + ], + markdown: { + rehypePlugins: [ + rehypeHeadingIds, + [rehypeAutolinkHeadings, { behavior: "wrap", properties: { className: ["not-prose"] } }], + [ + rehypeExternalLinks, + { + rel: ["noreferrer", "noopener"], + target: "_blank", + }, + ], + rehypeUnwrapImages, + ], + remarkPlugins: [remarkReadingTime, remarkDirective, remarkAdmonitions], + remarkRehype: { + footnoteLabelProperties: { + className: [""], + }, + }, + }, + // https://docs.astro.build/en/guides/prefetch/ + prefetch: true, + vite: { + optimizeDeps: { + exclude: ["@resvg/resvg-js"], + }, + plugins: [tailwind(), rawFonts([".ttf", ".woff"])], + }, + env: { + schema: { + WEBMENTION_API_KEY: envField.string({ context: "server", access: "secret", optional: true }), + WEBMENTION_URL: envField.string({ context: "client", access: "public", optional: true }), + WEBMENTION_PINGBACK: envField.string({ context: "client", access: "public", optional: true }), + }, + }, +}); + +function rawFonts(ext: string[]) { + return { + name: "vite-plugin-raw-fonts", + // @ts-expect-error:next-line + transform(_, id) { + if (ext.some((e) => id.endsWith(e))) { + const buffer = fs.readFileSync(id); + return { + code: `export default ${JSON.stringify(buffer)}`, + map: null, + }; + } + }, + }; +} -- cgit v1.2.3