Move plant configuration to different files (one per plant)

main
trivernis 6 months ago
parent 554edd2d17
commit 3bb73c0bd9
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

19
package-lock.json generated

@ -16,7 +16,6 @@
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"typescript-plugin-toml": "^0.3.1",
"vite": "^4.4.2",
"vite-plugin-toml": "^0.6.0"
}
@ -1718,12 +1717,6 @@
"node": ">=8.0"
}
},
"node_modules/toml": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
"dev": true
},
"node_modules/toml-eslint-parser": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/toml-eslint-parser/-/toml-eslint-parser-0.6.1.tgz",
@ -1767,18 +1760,6 @@
"node": ">=14.17"
}
},
"node_modules/typescript-plugin-toml": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/typescript-plugin-toml/-/typescript-plugin-toml-0.3.1.tgz",
"integrity": "sha512-pBRKcuidbQyGQZOejx3abJtjX2NRemYCIBImWAJ/Lek6byUJObw/j/jPwdlrOWEcIo37t4AHHeh9fXAgQ8FZzA==",
"dev": true,
"dependencies": {
"toml": "^3.0.0"
},
"peerDependencies": {
"typescript": "^5.0.2"
}
},
"node_modules/undici": {
"version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.26.5.tgz",

@ -18,7 +18,6 @@
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"typescript-plugin-toml": "^0.3.1",
"vite": "^4.4.2",
"vite-plugin-toml": "^0.6.0"
},

@ -1,8 +1,8 @@
[aloe-vera]
slug = "aloe-vera"
name = "Aloe Vera"
bin_name = "Aloe Vera"
[aloe-vera.image]
[image]
small = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Aloe_Vera_%284700054020%29.jpg/320px-Aloe_Vera_%284700054020%29.jpg"
medium = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Aloe_Vera_%284700054020%29.jpg/1024px-Aloe_Vera_%284700054020%29.jpg"
large = "https://upload.wikimedia.org/wikipedia/commons/d/d2/Aloe_Vera_%284700054020%29.jpg"
@ -13,12 +13,12 @@ Tentacle-like succulent leaves sprout out from the base of the plant \
going up at multiple angles.
"""
[aloe-vera.temp]
[temp]
death = 5
lower = 12
upper = 29
[aloe-vera.site]
[site]
description = """
Aloe Vera prefers to grow in direct sunlight at temperatures between 12°C and 29°C. Temperatures below 5°C might kill the plant. Aloe Vera doesn't have any special humidity preferences.
"""
@ -26,7 +26,7 @@ light = "full or part sun"
humidity = "any"
[aloe-vera.care]
[care]
description = """
Aloe Vera needs to be watered about ever 16 days. Make sure the soil is almost completely dry before watering it as it can be overwatered easily.
"""

@ -0,0 +1,36 @@
slug = "monstera-deliciosa"
name = "Monstera Deliciosa"
bin_name = "Monstera Deliciosa"
[image]
small = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/New_Monstera_Deliciosa_Leaf.jpg/360px-New_Monstera_Deliciosa_Leaf.jpg"
medium = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/New_Monstera_Deliciosa_Leaf.jpg/768px-New_Monstera_Deliciosa_Leaf.jpg"
large = "https://upload.wikimedia.org/wikipedia/commons/d/d4/New_Monstera_Deliciosa_Leaf.jpg"
source = "https://commons.wikimedia.org/wiki/File:New_Monstera_Deliciosa_Leaf.jpg"
alt = """
Monstera deliciosa. \
A big leaf with gaps is shown in the middle \
with other leaves in the back. The leaf is heart-shaped. \
The plant is potted in a pot with a moss stick.\
"""
[temp]
death = 10
lower = 18
upper = 24
[site]
description = """
Monstera is best positioned in an area with changing shade and sunny conditions. It is best kept indoors at temperatures between 18°C and 24°C. Temperatures below 10°C might damage the plant. Monstera prefers high humidity which can be achieved by misting the plant regularly. Every 16 days common plant fertilizer can be applied.
"""
light = "shade, some sun"
humidity = "high"
[care]
description = """
On average Monstera needs to be watered every 8 days. Ideally when the top layer of the dirt has dried out. Monstera is used to growing in high humidity climate. Misting every week will increase the health of the plant as it rasises the humditity. Make sure to remove dead leaves and branches about every 3 months.
"""
water_schedule = "8 days"
mist_schedule = "week"
fertilize_schedule = "16 days"
clean_schedule = "3 months"

@ -0,0 +1,43 @@
import aloeVera from "$lib/assets/plants/aloe-vera.toml";
import monsteraDeliciosa from "$lib/assets/plants/monstera-deliciosa.toml";
export type PlantData = {
slug: string;
name: string;
bin_name: string;
image: {
small: string;
medium: string;
large: string;
source: string;
alt: string;
};
temp: {
death: number;
lower: number;
upper: number;
};
care: {
description: string;
water_schedule: string;
mist_schedule?: string;
fertilize_schedule?: string;
clean_schedule?: string;
};
site: {
description: string;
light: string;
humidity?: string;
};
};
type PlantMap = { [key: PlantData["slug"]]: PlantData };
export const plants: PlantMap = [aloeVera, monsteraDeliciosa].reduce(
(acc, cur) => {
acc[cur.slug] = cur;
return acc;
},
{} as PlantMap,
);

@ -0,0 +1,5 @@
declare module "$lib/assets/plants/*.toml" {
import type { PlantData } from "$lib/plants";
const value: PlantData;
export default value;
}

@ -1,37 +1,6 @@
import { error } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
// @ts-ignore
import plants from "$lib/assets/plants.toml";
export type PlantData = {
name: string;
bin_name: string;
image: {
small: string;
medium: string;
large: string;
source: string;
alt: string;
};
temp: {
death: number;
lower: number;
upper: number;
};
care: {
description: string;
water_schedule: string;
mist_schedule?: string;
fertilize_schedule?: string;
clean_schedule?: string;
};
site: {
description: string;
light: string;
humidity?: string;
};
};
import { plants, type PlantData } from "$lib/plants";
export const load: PageLoad = ({ params }) => {
console.log(plants);

@ -9,9 +9,6 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
},
"typeRoots": ["src/lib/types/"]
}

Loading…
Cancel
Save