rename primary color template variables

This commit is contained in:
Reorx 2023-02-14 15:51:59 +08:00
parent 51fd7f8754
commit 0776062bb6
4 changed files with 11 additions and 14 deletions

View File

@ -18,8 +18,10 @@
<link rel="stylesheet" href="/src/themes/<%= theme %>/index.scss"> <link rel="stylesheet" href="/src/themes/<%= theme %>/index.scss">
<style> <style>
:root { :root {
/* override primary color */ <% if (primaryColor) { %>
<%= primaryColor.var %>: <%= primaryColor.value %>; /* override primary color */
<%= varNamePrimaryColor %>: <%= primaryColor %>;
<% } %>
} }
</style> </style>
</head> </head>

View File

@ -2,7 +2,7 @@ import { reformatDate } from '../lib/date';
import { getIconSVG } from '../lib/icons'; import { getIconSVG } from '../lib/icons';
import { renderMarkdown } from '../lib/markdown'; import { renderMarkdown } from '../lib/markdown';
export const primaryColorVarName = '--color-primary' export const varNamePrimaryColor = '--color-primary'
export function getRenderData(cvData) { export function getRenderData(cvData) {
return { return {
@ -13,7 +13,8 @@ export function getRenderData(cvData) {
getIconSVG, getIconSVG,
noSchemaURL, noSchemaURL,
renderMarkdown, renderMarkdown,
} },
varNamePrimaryColor,
} }
} }

View File

@ -2,7 +2,7 @@ import ejs from 'ejs';
import { import {
getRenderData, getRenderData,
primaryColorVarName, varNamePrimaryColor,
} from './data'; } from './data';
const themes = {} const themes = {}
@ -50,5 +50,5 @@ export function renderThemeOn(name, el, data, primaryColor) {
} }
elStyle.innerHTML = theme.style elStyle.innerHTML = theme.style
document.documentElement.style.setProperty(primaryColorVarName, primaryColor) document.documentElement.style.setProperty(varNamePrimaryColor, primaryColor)
} }

View File

@ -4,10 +4,7 @@ import { ViteEjsPlugin } from 'vite-plugin-ejs';
import { viteSingleFile } from 'vite-plugin-singlefile'; import { viteSingleFile } from 'vite-plugin-singlefile';
import { TransformEjs } from './src/lib/vite-plugins'; import { TransformEjs } from './src/lib/vite-plugins';
import { import { getRenderData } from './src/themes/data';
getRenderData,
primaryColorVarName,
} from './src/themes/data';
const dataFilename = process.env.DATA_FILENAME || './sample.cv.json' const dataFilename = process.env.DATA_FILENAME || './sample.cv.json'
const outDir = process.env.OUT_DIR || 'dist' const outDir = process.env.OUT_DIR || 'dist'
@ -15,10 +12,7 @@ const outDir = process.env.OUT_DIR || 'dist'
const data = require(dataFilename) const data = require(dataFilename)
const renderData = getRenderData(data) const renderData = getRenderData(data)
renderData.theme = process.env.THEME || 'reorx' renderData.theme = process.env.THEME || 'reorx'
renderData.primaryColor = { renderData.primaryColor = process.env.PRIMARY_COLOR
var: primaryColorVarName,
value: process.env.PRIMARY_COLOR || '#2A3FFB'
}
renderData.isProduction = process.env.NODE_ENV === 'production' renderData.isProduction = process.env.NODE_ENV === 'production'
renderData.meta = { renderData.meta = {
title: data.basics.name, title: data.basics.name,