2023-05-25 10:41:54 +00:00
|
|
|
const fs = require("fs");
|
2023-06-03 11:08:32 +00:00
|
|
|
const path = require("path");
|
2023-07-08 04:12:11 +00:00
|
|
|
const themePath = path.join(__dirname, "data/theme.json");
|
|
|
|
const themeRead = fs.readFileSync(themePath, "utf8");
|
|
|
|
const theme = JSON.parse(themeRead);
|
2023-08-20 07:49:46 +00:00
|
|
|
const hugoStatsPath = path.join(__dirname, "hugo_stats.json");
|
|
|
|
const hugoStatsRead = fs.readFileSync(hugoStatsPath, "utf8");
|
|
|
|
|
|
|
|
// Function to decode Unicode escape sequences
|
|
|
|
function decodeUnicode(json) {
|
|
|
|
return JSON.parse(json, (key, value) => {
|
|
|
|
if (typeof value === "string") {
|
|
|
|
return value.replace(/\\u[\dA-Fa-f]{4}/g, (match) => {
|
|
|
|
return String.fromCharCode(parseInt(match.slice(2), 16));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
"hugo_stats_decoded.json",
|
|
|
|
JSON.stringify(decodeUnicode(hugoStatsRead), null, 2),
|
|
|
|
);
|
2023-05-25 10:41:54 +00:00
|
|
|
|
2023-07-08 04:12:11 +00:00
|
|
|
let font_base = Number(theme.fonts.font_size.base.replace("px", ""));
|
|
|
|
let font_scale = Number(theme.fonts.font_size.scale);
|
2023-05-25 10:41:54 +00:00
|
|
|
let h6 = font_base / font_base;
|
|
|
|
let h5 = h6 * font_scale;
|
|
|
|
let h4 = h5 * font_scale;
|
|
|
|
let h3 = h4 * font_scale;
|
|
|
|
let h2 = h3 * font_scale;
|
|
|
|
let h1 = h2 * font_scale;
|
|
|
|
let fontPrimary, fontPrimaryType, fontSecondary, fontSecondaryType;
|
2023-07-08 04:12:11 +00:00
|
|
|
if (theme.fonts.font_family.primary) {
|
|
|
|
fontPrimary = theme.fonts.font_family.primary
|
2023-05-25 10:41:54 +00:00
|
|
|
.replace(/\+/g, " ")
|
|
|
|
.replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, "");
|
2023-07-08 04:12:11 +00:00
|
|
|
fontPrimaryType = theme.fonts.font_family.primary_type;
|
2023-05-25 10:41:54 +00:00
|
|
|
}
|
2023-07-08 04:12:11 +00:00
|
|
|
if (theme.fonts.font_family.secondary) {
|
|
|
|
fontSecondary = theme.fonts.font_family.secondary
|
2023-05-25 10:41:54 +00:00
|
|
|
.replace(/\+/g, " ")
|
|
|
|
.replace(/:[ital,]*[ital@]*[wght@]*[0-9,;]+/gi, "");
|
2023-07-08 04:12:11 +00:00
|
|
|
fontSecondaryType = theme.fonts.font_family.secondary_type;
|
2023-05-25 10:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @type {import('tailwindcss').Config} */
|
|
|
|
module.exports = {
|
2023-08-20 07:49:46 +00:00
|
|
|
content: ["./hugo_stats_decoded.json"],
|
2023-05-25 10:41:54 +00:00
|
|
|
safelist: [{ pattern: /^swiper-/ }],
|
|
|
|
darkMode: "class",
|
|
|
|
theme: {
|
|
|
|
screens: {
|
|
|
|
sm: "540px",
|
|
|
|
md: "768px",
|
|
|
|
lg: "1024px",
|
|
|
|
xl: "1280px",
|
|
|
|
"2xl": "1536px",
|
|
|
|
},
|
|
|
|
container: {
|
|
|
|
center: true,
|
|
|
|
padding: "2rem",
|
|
|
|
},
|
|
|
|
extend: {
|
|
|
|
colors: {
|
2023-07-08 04:12:11 +00:00
|
|
|
text: theme.colors.default.text_color.default,
|
|
|
|
light: theme.colors.default.text_color.light,
|
|
|
|
dark: theme.colors.default.text_color.dark,
|
|
|
|
primary: theme.colors.default.theme_color.primary,
|
|
|
|
secondary: theme.colors.default.theme_color.secondary,
|
|
|
|
body: theme.colors.default.theme_color.body,
|
|
|
|
border: theme.colors.default.theme_color.border,
|
|
|
|
"theme-light": theme.colors.default.theme_color.theme_light,
|
|
|
|
"theme-dark": theme.colors.default.theme_color.theme_dark,
|
2023-05-25 10:41:54 +00:00
|
|
|
darkmode: {
|
2023-07-08 04:12:11 +00:00
|
|
|
text: theme.colors.darkmode.text_color.default,
|
|
|
|
light: theme.colors.darkmode.text_color.light,
|
|
|
|
dark: theme.colors.darkmode.text_color.dark,
|
|
|
|
primary: theme.colors.darkmode.theme_color.primary,
|
|
|
|
secondary: theme.colors.darkmode.theme_color.secondary,
|
|
|
|
body: theme.colors.darkmode.theme_color.body,
|
|
|
|
border: theme.colors.darkmode.theme_color.border,
|
|
|
|
"theme-light": theme.colors.darkmode.theme_color.theme_light,
|
|
|
|
"theme-dark": theme.colors.darkmode.theme_color.theme_dark,
|
2023-05-25 10:41:54 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
fontSize: {
|
|
|
|
base: font_base + "px",
|
|
|
|
h1: h1 + "rem",
|
|
|
|
"h1-sm": h1 * 0.8 + "rem",
|
|
|
|
h2: h2 + "rem",
|
|
|
|
"h2-sm": h2 * 0.8 + "rem",
|
|
|
|
h3: h3 + "rem",
|
|
|
|
"h3-sm": h3 * 0.8 + "rem",
|
|
|
|
h4: h4 + "rem",
|
|
|
|
h5: h5 + "rem",
|
|
|
|
h6: h6 + "rem",
|
|
|
|
},
|
|
|
|
fontFamily: {
|
|
|
|
primary: [fontPrimary, fontPrimaryType],
|
|
|
|
secondary: [fontSecondary, fontSecondaryType],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
require("@tailwindcss/typography"),
|
|
|
|
require("@tailwindcss/forms"),
|
|
|
|
require("tailwind-bootstrap-grid")({
|
|
|
|
generateContainer: false,
|
|
|
|
gridGutterWidth: "2rem",
|
|
|
|
gridGutters: {
|
|
|
|
1: "0.25rem",
|
|
|
|
2: "0.5rem",
|
|
|
|
3: "1rem",
|
|
|
|
4: "1.5rem",
|
|
|
|
5: "3rem",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|