one-aalam / astro-ink

Crisp, minimal, personal blog theme for Astro
https://astro-ink.vercel.app
MIT License
556 stars 93 forks source link

How to pass THEME_KEY parameter to CLI dev script #54

Open stewcam opened 11 months ago

stewcam commented 11 months ago

I could not work out the correct syntax for adding the THEME_KEY parameter to npm dev or npx astro dev scripts (as suggested in the features list). I tried a few conventional ways including: npm run dev -- THEME_KEY=indigone npm run dev -- --THEME_KEY=indigone I was able to make the change by direct edit of the default section of tailwind.theme.config.cjs but how does it work through CLI?

one-aalam commented 10 months ago

Hey @camedgell the THEME_KEY needs to go before the command you wanna run. You can pass THEME_KEY with the dev or build commands like THEME_KEY=purpleheart astro build/dev to change the color theme being used.

stewcam commented 10 months ago

Thanks but the suggested syntax does not work at my end (running on Windows 11). Error code is EINVALIDTAGNAME with error message Invalid tag name "THEME_KEY=purpleheart" of package "THEME_KEY=purpleheart": Tags may not have any characters that encodeURIComponent encodes.

lovettbarron commented 10 months ago

You should be able to pass it direct in the package.json

eg.

  "scripts": {
    "dev": "THEME_KEY=indigone astro dev",
    "build": "astro build",
    "check": "astro check",
    "postbuild": "node ./scripts/search/prepare-index.js",
    "preview": "astro preview",
    "check:type": "tsc --project tsconfig.json --pretty --noEmit",
    "lint": "biome lint src",
    "format": "biome format src --write",
    "cz": "cz"
  },
stewcam commented 10 months ago

Thanks @lovettbarron but that does not work either. However, I have found that I can change the theme by direct edit of the default section of tailwind.theme.config.cjs, so will proceed with that.