Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a main description to the home page #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PostcodeLookup from "../components/PostcodeLookup";
import defaultContent from "../models/defaultContent";
import contentAPI from "./api/content";
import generalAPI from "./api/general";
import ReactMarkdown from "react-markdown";

const Home = ({ areas, content }) => {
const { locale } = useRouter();
Expand All @@ -29,6 +30,8 @@ const Home = ({ areas, content }) => {
]
: areas;

console.log(JSON.stringify(content.mainDescription));

return (
<div className="min-h-screen py-2">
<Head>
Expand All @@ -41,6 +44,24 @@ const Home = ({ areas, content }) => {
<h1 className="text-3xl my-6 font-medium">
{content.mainTitle[`text-${locale}`] || content.mainTitle[`text-en`]}
</h1>
<ReactMarkdown
components={{
// Map `h1` (`# heading`) to use `h2`s.
a: ({ node, ...props }) => (
<a
className="underline text-primary hover:text-blue-800"
target="_blank"
rel="noopener noreferrer"
{...props}
/>
),
}}
className="markdown space-y-4 max-w-4xl whitespace-pre-line mb-8"
children={
content.mainDescription[`text-${locale}`] ||
content.mainDescription["text-en"]
}
/>
<PostcodeLookup handleSearch={(obj) => setPostcodeObj(obj)} />
<div className="grid lg:grid-cols-4 md:grid-cols-3 grid-cols-2 gap-4">
{filteredAreas.map((area) => (
Expand All @@ -62,6 +83,17 @@ const Home = ({ areas, content }) => {
))}
</div>
</div>
<style jsx global>
{`
.markdown a {
text-decoration: underline !important;
}

.markdown p {
margin: 8px 0px !important;
}
`}
</style>
</div>
);
};
Expand Down