From 8cf1c4ba65aa8d2c0c484da0789fc3ad0875f60c Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:22:51 -0600 Subject: [PATCH] feat: add rest of solution pages --- src/content/geothermal/cost.mdx | 8 ++ src/content/geothermal/environment.mdx | 11 +++ src/content/geothermal/geothermal.mdx | 18 ----- src/content/geothermal/what.mdx | 12 +++ src/content/geothermal/worth-it.mdx | 12 +++ src/content/recycling/cost.mdx | 9 +++ src/content/recycling/environment.mdx | 13 ++++ src/content/recycling/recycle.mdx | 16 ---- src/content/recycling/what.mdx | 9 +++ src/content/recycling/worth-it.mdx | 13 ++++ src/content/solar/environment.mdx | 2 +- src/content/solar/index.mdx | 33 --------- src/content/solar/what.mdx | 8 +- src/content/solar/worth-it.mdx | 4 +- src/routes/solutions/[category]/[[slug]].tsx | 1 + src/routes/solutions/[category]/index.tsx | 32 ++++---- src/utils/categories.gen.ts | 77 +++++++++++++++----- src/utils/imports.gen.ts | 11 ++- src/utils/type-helpers.ts | 8 +- 19 files changed, 180 insertions(+), 117 deletions(-) create mode 100644 src/content/geothermal/cost.mdx create mode 100644 src/content/geothermal/environment.mdx delete mode 100644 src/content/geothermal/geothermal.mdx create mode 100644 src/content/geothermal/what.mdx create mode 100644 src/content/geothermal/worth-it.mdx create mode 100644 src/content/recycling/cost.mdx create mode 100644 src/content/recycling/environment.mdx delete mode 100644 src/content/recycling/recycle.mdx create mode 100644 src/content/recycling/what.mdx create mode 100644 src/content/recycling/worth-it.mdx delete mode 100644 src/content/solar/index.mdx diff --git a/src/content/geothermal/cost.mdx b/src/content/geothermal/cost.mdx new file mode 100644 index 00000000..0400d947 --- /dev/null +++ b/src/content/geothermal/cost.mdx @@ -0,0 +1,8 @@ +--- +title: How Much Do a Geothermal Energy Solutions Cost? +description: The cost to install a geothermal system can range anywhere from $10,000 all the way up to $25,000 +--- + +The cost to install a geothermal system can range anywhere from $10,000 all the way up to $25,000. +These costs can vary depending on factors such as region, type of system, and how much renovation your house needs. +Feel free to use our [price calculator](/calculator/) to get an estimate on much it would cost you! diff --git a/src/content/geothermal/environment.mdx b/src/content/geothermal/environment.mdx new file mode 100644 index 00000000..f388b72f --- /dev/null +++ b/src/content/geothermal/environment.mdx @@ -0,0 +1,11 @@ +--- +title: How Does Geothermal Energy Impact the Environment? +description: When it comes to carbon emissions, geothermal energy is very efficient +--- + +When it comes to carbon emissions, geothermal energy is very efficient. +It produces 10 times less CO2 than coal! +But it still isn’t as efficient as solar as it produces roughly 3x more CO2. +Possibly the biggest issue with geothermal though is the land it takes to build the infrastructure. +The building of larger plants can often disrupt ecosystems but this effect comes with all types of energy. +This effect is mitigated though with smaller systems such as ones installed on houses. diff --git a/src/content/geothermal/geothermal.mdx b/src/content/geothermal/geothermal.mdx deleted file mode 100644 index f73adad7..00000000 --- a/src/content/geothermal/geothermal.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Geothermal Energy Solutions -description: Geothermal Energy is an undertapped energy resource ---- - -## What is it? - -## Cost - -## Tax Rebates - -## Best Practices - -## Buy Now - -You can use our [online calculator](/calculator/) to calculate costs and buy _your_ geothermal energy solution today! - -## Sources diff --git a/src/content/geothermal/what.mdx b/src/content/geothermal/what.mdx new file mode 100644 index 00000000..876d3618 --- /dev/null +++ b/src/content/geothermal/what.mdx @@ -0,0 +1,12 @@ +--- +title: Geothermal Energy Solutions +description: Geothermal Energy is an undertapped energy resource +--- + +Geothermal energy is heat energy captured from within the earth and is then used for various things such as heating, cooking, and even electricity. +What’s fascinating about geothermal energy is that it’s actually all around us. +Just about anywhere on the planet this energy can be captured. In fact if we were to harness all of it, it would be enough to power the earth 3 times over. +That’s an incredible amount of energy. +However, it’s important to remember that geothermal energy isn’t a new concept. +Humans have been using it for over 10,000 years for functions such as heating hot springs, cooking, and even space heating in cities such as Pompeii. +Nowadays, it’s still mainly used for heating; however, if you install a converter, it can also be used for electricity. diff --git a/src/content/geothermal/worth-it.mdx b/src/content/geothermal/worth-it.mdx new file mode 100644 index 00000000..2acee9ea --- /dev/null +++ b/src/content/geothermal/worth-it.mdx @@ -0,0 +1,12 @@ +--- +title: Is Geothermal Energy Worth the Investment? +description: Deciding to invest in a geothermal energy solution can be tricky +--- + +Deciding to invest in a geothermal energy solution can be tricky. +When comparing it to solar it’s a lot more expensive to start and can take up to 20 years to pay itself off. +The pumps also require electricity to power so it’s not technically _free_. +Similar to solar energy, there are also federal tax credits that range from 22% to 30%, applicable on the install. +However, geothermal can be much more efficient than wind and solar as it isn’t impacted by weather. +It will always run as long as it’s powered. +Overall, investing in geothermal can be a smart choice depending on your location and budget as it will save you money over time and lessen carbon emissions. diff --git a/src/content/recycling/cost.mdx b/src/content/recycling/cost.mdx new file mode 100644 index 00000000..55accd79 --- /dev/null +++ b/src/content/recycling/cost.mdx @@ -0,0 +1,9 @@ +--- +title: The Cost of Recycling +description: The cost of recycling on municipal governments can vary anywhere from $100 to $300 per ton +--- + +The cost to collect, transport, clean, and process recycled material can vary anywhere from $100 to $300 per ton! +However, the cost to recycle is not a complete loss: recycled materials that are made into new products and sold help make money back. + +It was reported that in Atlantic County, New Jersey, the sale of goods made from recycled material generated $2.45 million, while the cost of processing the recycled materials cost the county over $3 million. diff --git a/src/content/recycling/environment.mdx b/src/content/recycling/environment.mdx new file mode 100644 index 00000000..bc6b24b4 --- /dev/null +++ b/src/content/recycling/environment.mdx @@ -0,0 +1,13 @@ +--- +title: How Does Recycling Affect the Environment? +description: The process of recycling reduces pollution and emissions +--- + +The process of recycling prevents these waste materials from ending up in landfills or the environment, reducing pollution and emissions. +Recycling also reduces the need to extract natural resources from the environment for new products, reduces carbon dioxide emissions, and conserves energy. + +However, material that is recycled doesn't always get recycled: only around 32% of all recycling is actually recycled. +This number is even worse when it comes to plastics specifically: only 5-6% of all plastics are recycled. +This is due to the fact that many often don't recycle them correctly: many throw non-recyclable plastics in the recycling bin, such as plastic bags, packing peanuts, batteries, straws, etc. +Another issue is that there is a huge variety of plastics. +Different types of plastics with different chemical additives and dyes are unable to be recycled together. diff --git a/src/content/recycling/recycle.mdx b/src/content/recycling/recycle.mdx deleted file mode 100644 index 2ca08e31..00000000 --- a/src/content/recycling/recycle.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: Recycling -description: Recycling saves energy ---- - -## What is it? - -## Cost - -## Tax Rebates - -## Best Practices - -## Buy Now - -## Sources diff --git a/src/content/recycling/what.mdx b/src/content/recycling/what.mdx new file mode 100644 index 00000000..861a1e66 --- /dev/null +++ b/src/content/recycling/what.mdx @@ -0,0 +1,9 @@ +--- +title: Recycling +description: Recycling is the process of taking inorganic waste materials and turning them into new products +--- + +Recycling is the process of taking inorganic waste materials and turning them into new products. +These materials include paper, glass, metal, and plastic. +Recyclable material is collected by consumers and businesses, which is then collected by private or government entities. +The material is then sorted, cleaned, processed, and shipped to manufacturing facilities to be made into new products. diff --git a/src/content/recycling/worth-it.mdx b/src/content/recycling/worth-it.mdx new file mode 100644 index 00000000..15dff14f --- /dev/null +++ b/src/content/recycling/worth-it.mdx @@ -0,0 +1,13 @@ +--- +title: Is Recycling Worth It? +description: The process of recycling prevents waste materials from ending up in landfills +--- + +The process of recycling prevents these waste materials from ending up in landfills or the environment, reducing pollution and emissions. +Recycling also reduces the need to extract natural resources from the environment for new products, reduces carbon dioxide emissions, and conserves energy. + +However, material that is recycled doesn't always get recycled: only around 32% of all recycling is actually recycled. +This number is even worse when it comes to plastics specifically: only 5-6% of all plastics are recycled. +This is due to the fact that many often don't recycle them correctly: many throw non-recyclable plastics in the recycling bin, such as plastic bags, packing peanuts, batteries, straws, etc. +Another issue is that there is a huge variety of plastics. +Different types of plastics with different chemical additives and dyes are unable to be recycled together. diff --git a/src/content/solar/environment.mdx b/src/content/solar/environment.mdx index 9adadd1c..ddc6b669 100644 --- a/src/content/solar/environment.mdx +++ b/src/content/solar/environment.mdx @@ -4,7 +4,7 @@ description: The best thing about solar power is that it has nearly zero negativ --- The best thing about solar power is that it has nearly zero negative effects on the environment! -It doesn't produce greenhouse gasses and has little effect on local wildlife. +It doesn’t produce greenhouse gasses and has little effect on local wildlife. They can be placed on rooftops, which means that they are incredibly space-efficient. The only harmful effect of solar power on the environment is its production. A major component of solar panels is lithium, which is plagued by unsustainable mining practices. diff --git a/src/content/solar/index.mdx b/src/content/solar/index.mdx deleted file mode 100644 index 249318a2..00000000 --- a/src/content/solar/index.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Solar Energy Solutions -description: Solar Energy is an undertapped energy resource ---- - -## What is it? - -Solar panels are useful. -They collect energy from the sun, and can be placed on roofs discreetly. - -For more information, see [What is Solar Power](./what/). - -## How does it impact the environment? - -The best thing about solar power is that it has nearly zero negative effects on the environment. - -For more information, see [How Does Solar Power Impact the Environment?](./environment/) - -## Cost - -The cost of solar panels can vary depending on your state and region. - -For more information, see [How Much Do Solar Panels Cost](./cost/). - -## Tax Rebates - -## Best Practices - -## Buy Now - -You can use our [online calculator](/calculator/) to calculate costs and buy _your_ solar energy solution today! - -## Sources diff --git a/src/content/solar/what.mdx b/src/content/solar/what.mdx index 059b2797..226cdc60 100644 --- a/src/content/solar/what.mdx +++ b/src/content/solar/what.mdx @@ -6,13 +6,13 @@ description: Solar power is a fascinating technology that converts energy from t import { Admonition } from "../../components/Admonition.tsx"; Solar power is a fascinating technology that converts energy from the sun into electricity. -It is a renewable and near infinite resource as the sun isn't expected to run out of energy for billions of years to come. -Unlike coal and oil, it doesn't emit greenhouse gasses, meaning that it doesn't contribute to global warming. +It is a renewable and near infinite resource as the sun isn’t expected to run out of energy for billions of years to come. +Unlike coal and oil, it doesn’t emit greenhouse gasses, meaning that it doesn’t contribute to global warming. Nowadays, solar power is used for powering a wide array of things, from satellites to homes. The government has also been working on constructing solar farms, where thousands of solar panels are connected together to power an energy grid. Solar power was first harnessed circa 213 B.C.E by the Greeks, who allegedly - used reflected the sun's rays with mirrors to light enemy ships on fire during - the Siege of Syracuse. + reflected the sun’s rays with mirrors to light enemy ships on fire during the + Siege of Syracuse. diff --git a/src/content/solar/worth-it.mdx b/src/content/solar/worth-it.mdx index 9695f0f3..6dee6d8e 100644 --- a/src/content/solar/worth-it.mdx +++ b/src/content/solar/worth-it.mdx @@ -8,10 +8,10 @@ Overall, solar panels are a worthwhile investment for most homeowners. Their cost of entry is fairly high, but they do pay themselves off= after around 9 to 12 years. This does depend on the region you live in and the model of solar panel you purchase. Monocrystalline solar panels, for example, are more expensive but last longer and are more energy efficient. -Polycrystalline panels, on the other hand, are much cheaper; however, they don't last as long and are not nearly as efficient. +Polycrystalline panels, on the other hand, are much cheaper; however, they don’t last as long and are not nearly as efficient. Due to their cheaper price, polycrystalline panels are very popular for residential areas. More often than not, your region will have a much greater impact than the type of solar panels. In places like Arizona, your panels will get more hours of sunlight and therefore generate more energy. Sunnier regions also tend to have more legislation that support solar panels, such as tax rebates. -Even if you don't live in one of those areas, there's still a 30% federal tax credit on _all_ solar systems. +Even if you don’t live in one of those areas, there’s still a 30% federal tax credit on _all_ solar systems. In conclusion solar panels are a amazing investment that can help your budget and the environment diff --git a/src/routes/solutions/[category]/[[slug]].tsx b/src/routes/solutions/[category]/[[slug]].tsx index c61c85c7..7dfec6e7 100644 --- a/src/routes/solutions/[category]/[[slug]].tsx +++ b/src/routes/solutions/[category]/[[slug]].tsx @@ -43,6 +43,7 @@ export const handler: Handlers = { return ctx.render({ page: file }); } catch (e) { console.error(e); + return ctx.renderNotFound(); } }, diff --git a/src/routes/solutions/[category]/index.tsx b/src/routes/solutions/[category]/index.tsx index 27028325..0c84d173 100644 --- a/src/routes/solutions/[category]/index.tsx +++ b/src/routes/solutions/[category]/index.tsx @@ -8,7 +8,7 @@ import { solutions } from "../../../utils/categories.gen.ts"; import type { FreshContextHelper } from "../../../utils/handlers.ts"; import { IconSolarPanel } from "../../../utils/icons.ts"; import { kebabToCamel } from "../../../utils/strings.ts"; -import { hasSlug, isKey, isSlug } from "../../../utils/type-helpers.ts"; +import { hasSlug, isKey } from "../../../utils/type-helpers.ts"; export type CategoryProps = z.infer; export type CategoryPages = z.infer; @@ -29,7 +29,7 @@ const categoryPropsPages = z.object({ const categoryProps = z.object({ page: categoryPropsPages, title: z.string(), - description: z.string(), + description: z.string().refine((value) => !value.endsWith(",")), }); /** @@ -52,7 +52,7 @@ export const handler: Handlers = { const { slug, data: solutionData } = solution; const camelSlug = kebabToCamel(slug); - if (solutionData.category === category && isSlug(camelSlug)) { + if (solutionData.category === category) { data = { ...data, [camelSlug]: { @@ -65,20 +65,14 @@ export const handler: Handlers = { } } - const parsedData = categoryPropsPages.safeParse(data); - - if (parsedData.success) { - return ctx.render({ - page: parsedData.data, - title: categoryMetadata[category].title, - description: categoryMetadata[category].description, - }); - } - - console.error(parsedData.error); - return ctx.renderNotFound(); + return ctx.render({ + page: categoryPropsPages.parse(data), + title: categoryMetadata[category].title, + description: categoryMetadata[category].description, + }); } catch (e) { console.error(e); + return ctx.renderNotFound(); } }, @@ -89,6 +83,14 @@ const categoryMetadata = { title: "Solar Energy", description: "Solar Energy is an undertapped energy resource", }, + geothermal: { + title: "Geothermal Energy", + description: "Geothermal Energy is an undertapped energy resource", + }, + recycling: { + title: "Recycling", + description: "Recycling saves energy and reduces pollution", + }, }; /** diff --git a/src/utils/categories.gen.ts b/src/utils/categories.gen.ts index 94b7fc06..983bac5c 100644 --- a/src/utils/categories.gen.ts +++ b/src/utils/categories.gen.ts @@ -2,50 +2,75 @@ import type { SolutionPages } from "./solutions.ts"; export const solutions = [ { - "slug": "index", + "slug": "environment", "data": { - "title": "Solar Energy Solutions", - "description": "Solar Energy is an undertapped energy resource", + "title": "How Does Solar Power Impact the Environment?", + "description": "The best thing about solar power is that it has nearly zero negative effects on the environment", "category": "solar" } }, { - "slug": "recycle", + "slug": "cost", "data": { - "title": "Recycling", - "description": "Recycling saves energy", + "title": "How Much Do Solar Panels Cost?", + "description": "The cost of solar panels can vary depending on your state and region", + "category": "solar" + } + }, + { + "slug": "what", + "data": { + "title": "What is Solar Power?", + "description": "Solar power is a fascinating technology that converts energy from the sun into electricity", + "category": "solar" + } + }, + { + "slug": "environment", + "data": { + "title": "How Does Recycling Affect the Environment?", + "description": "The process of recycling reduces pollution and emissions", "category": "recycling" } }, { + "slug": "environment", "data": { - "title": "Geothermal Energy Solutions", - "description": "Geothermal Energy is an undertapped energy resource", + "title": "How Does Geothermal Energy Impact the Environment?", + "description": "When it comes to carbon emissions, geothermal energy is very efficient", "category": "geothermal" } }, { - "slug": "environment", + "slug": "what", "data": { - "title": "How Does Solar Power Impact the Environment?", - "description": "The best thing about solar power is that it has nearly zero negative effects on the environment", - "category": "solar" + "title": "Geothermal Energy Solutions", + "description": "Geothermal Energy is an undertapped energy resource", + "category": "geothermal" } }, { "slug": "cost", "data": { - "title": "How Much Do Solar Panels Cost?", - "description": "The cost of solar panels can vary depending on your state and region", - "category": "solar" + "title": "The Cost of Recycling", + "description": "The cost of recycling on municipal governments can vary anywhere from $100 to $300 per ton", + "category": "recycling" } }, { "slug": "what", "data": { - "title": "What is Solar Power?", - "description": "Solar power is a fascinating technology that converts energy from the sun into electricity", - "category": "solar" + "title": "Recycling", + "description": "Recycling is the process of taking inorganic waste materials and turning them into new products", + "category": "recycling" + } + }, + { + "slug": "cost", + "data": { + "title": "How Much Do a Geothermal Energy Solutions Cost?", + "description": "The cost to install a geothermal system can range anywhere from $10,000 all the way up to $25,000", + "category": "geothermal" } }, { @@ -55,5 +80,21 @@ export const solutions = [ "description": "Overall, solar panels are a worthwhile investment", "category": "solar" } + }, + { + "slug": "worth-it", + "data": { + "title": "Is Recycling Worth It?", + "description": "The process of recycling prevents waste materials from ending up in landfills", + "category": "recycling" + } + }, + { + "slug": "worth-it", + "data": { + "title": "Is Geothermal Energy Worth the Investment?", + "description": "Deciding to invest in a geothermal energy solution can be tricky", + "category": "geothermal" + } } ] as const satisfies SolutionPages; diff --git a/src/utils/imports.gen.ts b/src/utils/imports.gen.ts index c15c30cf..14511706 100644 --- a/src/utils/imports.gen.ts +++ b/src/utils/imports.gen.ts @@ -1,7 +1,12 @@ -(async () => await import("../content/solar/index.js")); (async () => await import("../content/solar/environment.js")); (async () => await import("../content/solar/cost.js")); (async () => await import("../content/solar/what.js")); (async () => await import("../content/solar/worth-it.js")); -(async () => await import("../content/recycling/recycle.js")); -(async () => await import("../content/geothermal/geothermal.js")); +(async () => await import("../content/recycling/environment.js")); +(async () => await import("../content/recycling/cost.js")); +(async () => await import("../content/recycling/what.js")); +(async () => await import("../content/recycling/worth-it.js")); +(async () => await import("../content/geothermal/environment.js")); +(async () => await import("../content/geothermal/cost.js")); +(async () => await import("../content/geothermal/what.js")); +(async () => await import("../content/geothermal/worth-it.js")); diff --git a/src/utils/type-helpers.ts b/src/utils/type-helpers.ts index e2ffe059..449c8af8 100644 --- a/src/utils/type-helpers.ts +++ b/src/utils/type-helpers.ts @@ -10,7 +10,7 @@ export function hasItems(menu: Menu): menu is MenuWithItems { export function hasSlug( data: SolutionPage, -): data is SolutionPage & { slug: string } { +): data is SolutionPage & { slug: string | undefined } { return isKey(data, "slug"); } @@ -28,9 +28,3 @@ export function isKey( ): key is keyof T { return Object.hasOwn(obj, key); } - -export function isSlug( - slug: string, -): slug is "what" | "environment" | "cost" | "worthIt" { - return ["what", "environment", "cost", "worthIt"].includes(slug); -}