From 77da1e1fd103b47d4ee7e15323e8f228d54ad508 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Fri, 18 Oct 2019 13:41:43 -0700 Subject: [PATCH] :sparkles: Support for custom colors --- README.md | 4 ++++ package.json | 2 +- src/generator.ts | 18 ++++++++++++++++-- src/interfaces.ts | 4 ++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8dfa7bb2..60ef79b7 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ You can create a `.staartrc` file or another [Cosmiconfig](https://github.com/da | `stylePath` | Scss stylesheet path | `style.scss` | | `homePath` | Markdown file path for homepage | `README.md` | | `hostname` | Base URL for sitemap | `http://localhost:8080` | +| `themeColor` | Main theme color | `#0e632c` | +| `textColor` | Dark text color | `#001b01` | +| `linkColor` | Hyperlink color | `#0e632c` | +| `lightColor` | Light text color | `#ffffff` | | `navbar` | Array of filenames for navbar | Root files/folders in `contentDir` | | `contentFileExt` | File extension for content files | `md` | | `keepHomeHeading` | Show `h1` heading on homepage | `false` | diff --git a/package.json b/package.json index a3431e31..89961215 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@staart/site", - "version": "0.9.57", + "version": "0.9.58", "module": "dist/module.js", "main": "dist/index.js", "bin": "./dist/index.js", diff --git a/src/generator.ts b/src/generator.ts index 2d998f69..ed871141 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -66,7 +66,8 @@ const renderScss = (styles: string) => }); }); export const getCss = async () => { - return await cached("css", async () => { + const config = await getConfig(); + return (await cached("css", async () => { try { return await renderScss( (await readFile(await getStylePath())).toString() @@ -76,7 +77,20 @@ export const getCss = async () => { (await readFile(join(__dirname, "..", "src", "style.scss"))).toString() ); } - }); + })) + .replace("$theme: #0e632c", `$theme: ${config.themeColor || "#0e632c"};`) + .replace( + "$text-color: #001b01", + `$text-color: ${config.textColor || "#001b01"};` + ) + .replace( + "$link-color: #0e632c", + `$link-color: ${config.linkColor || "#0e632c"};` + ) + .replace( + "$light-color: #fff", + `$light-color: ${config.lightColor || "#fff"};` + ); }; export const generate = async () => { diff --git a/src/interfaces.ts b/src/interfaces.ts index fd467de7..2818d307 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -20,6 +20,10 @@ export interface StaartSiteConfig { noHome?: boolean; noSitemap?: boolean; noContentList?: boolean; + themeColor?: string; + textColor?: string; + linkColor?: string; + lightColor?: string; [index: string]: any; }