Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 54 additions & 4 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @type {import('sass').Importer} */
import { defineConfig } from "astro/config";
import path from "path";
import fs from "fs";

import sitemap from "@astrojs/sitemap";
import svelte from "@astrojs/svelte";
import mdx from "@astrojs/mdx";
Expand All @@ -9,6 +13,9 @@ import yaml from "@rollup/plugin-yaml";
import astroExpressiveCode from "astro-expressive-code";
import getReadingTime from "reading-time";
import { toString } from "mdast-util-to-string";
import { fileURLToPath, pathToFileURL } from "node:url";

const __dirname = import.meta.dirname;

const remarkReadingTime = () => {
return function (tree, { data }) {
Expand All @@ -18,11 +25,55 @@ const remarkReadingTime = () => {
};
};

// https://astro.build/config
// Workaround until astro importing sass bug is fixed: https://github.com/withastro/astro/issues/15897
const stylesImporter = {
canonicalize(url) {
if (!url.startsWith("@styles/")) return null;

const importPath = url.slice(8);
const basePath = path.resolve(__dirname, "src/styles", importPath);

const candidates = [
basePath + ".scss",
basePath + ".sass",
path.join(path.dirname(basePath), "_" + path.basename(basePath) + ".scss"),
path.join(path.dirname(basePath), "_" + path.basename(basePath) + ".sass"),
];

for (const filePath of candidates) {
if (fs.existsSync(filePath)) {
return pathToFileURL(filePath);
}
}

return null;
},

load(canonicalUrl) {
const filePath = fileURLToPath(canonicalUrl);
try {
const contents = fs.readFileSync(filePath, "utf-8");
const syntax = filePath.endsWith(".sass") ? "sass" : "scss";
return { contents, syntax }; // <- Add syntax field
} catch {
return null;
}
},
};

export default defineConfig({
site: "https://catppuccin.com",
vite: {
plugins: [yaml()],
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
silenceDeprecations: ["mixed-decls"],
importers: [stylesImporter],
},
},
},
},
markdown: {
rehypePlugins: [
Expand All @@ -46,11 +97,10 @@ export default defineConfig({
themes: ["catppuccin-latte", "catppuccin-mocha", "catppuccin-frappe", "catppuccin-macchiato"],
themeCssSelector: (theme) => {
const themeName = theme.name.split("-")[1];
const selector = `[data-theme='${themeName}']`;
return selector;
return `[data-theme='${themeName}']`;
},
useDarkModeMediaQuery: true,
// Stop it from auto-correcting colour contrast
// Stop it from autocorrecting colour contrast
minSyntaxHighlightingColorContrast: 0,
styleOverrides: {
frames: {
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"devDependencies": {
"@astrojs/check": "^0.9.8",
"@astrojs/markdown-remark": "^6.3.11",
"@astrojs/mdx": "^4.3.14",
"@astrojs/mdx": "^5.0.4",
"@astrojs/rss": "^4.0.18",
"@astrojs/sitemap": "^3.7.2",
"@astrojs/svelte": "^7.2.5",
"@astrojs/svelte": "^8.1.0",
"@catppuccin/catppuccin": "github:catppuccin/catppuccin#7e4506607b8a6c298ce0876e385c52281e879245",
"@catppuccin/palette": "^1.8.0",
"@iconify-json/ph": "^1.2.2",
Expand All @@ -40,9 +40,10 @@
"@iconify/types": "^2.0.0",
"@playwright/test": "^1.59.1",
"@rollup/plugin-yaml": "^4.1.2",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@types/node": "^24.12.2",
"@vitest/coverage-v8": "^3.2.4",
"astro": "^5.18.1",
"astro": "6.1.6",
"astro-expressive-code": "^0.41.7",
"astro-icon": "1.1.5",
"fuse.js": "^7.3.0",
Expand All @@ -61,9 +62,10 @@
"svelte-intersection-observer-action": "^0.0.5",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"vite": "^8.0.0",
"vite": "8.0.5",
"vitest": "^3.2.4",
"yaml": "^2.8.3"
"yaml": "^2.8.3",
"zod": "^4.3.6"
},
"packageManager": "pnpm@10.33.0",
"engines": {
Expand Down
Loading