mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-11 18:56:06 +09:00
refactor darkmode
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
(function () {
|
||||
const rootDirs = ["src/pages", "src/hooks", "src/layouts", "src/styles"];
|
||||
|
||||
const deleteAssetList = [
|
||||
"public/images/logo-darkmode.png",
|
||||
"src/layouts/components/ThemeSwitcher.astro",
|
||||
];
|
||||
|
||||
const configFiles = [
|
||||
{
|
||||
filePath: "tailwind.config.js",
|
||||
@@ -11,6 +17,29 @@ const configFiles = [
|
||||
{ filePath: "src/config/theme.json", patterns: ["colors.darkmode"] },
|
||||
];
|
||||
|
||||
const filePaths = [
|
||||
{
|
||||
filePath: "src/layouts/partials/Header.astro",
|
||||
patterns: [
|
||||
"<ThemeSwitchers*(?:\\s+[^>]+)?\\s*(?:\\/\\>|>([\\s\\S]*?)<\\/ThemeSwitchers*>)",
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
filePaths.forEach(({ filePath, patterns }) => {
|
||||
removeDarkModeFromFiles(filePath, patterns);
|
||||
});
|
||||
|
||||
deleteAssetList.forEach(deleteAsset);
|
||||
function deleteAsset(asset) {
|
||||
try {
|
||||
fs.unlinkSync(asset);
|
||||
console.log(`${path.basename(asset)} deleted successfully!`);
|
||||
} catch (error) {
|
||||
console.error(`${asset} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
rootDirs.forEach(removeDarkModeFromPages);
|
||||
configFiles.forEach(removeDarkMode);
|
||||
|
||||
@@ -64,3 +93,4 @@ function deleteNestedProperty(obj, propertyPath) {
|
||||
}
|
||||
delete currentObj[properties[properties.length - 1]];
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user