Skip to content
New issue

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

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

Already on GitHub? # to your account

Banner image property for home page #130

Merged
merged 5 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions cli/src/getDocusaurusConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default function getDocusaurusConfig({

...config.docusaurus,

customFields: {
bannerImage: config.home?.bannerImage
},

themeConfig: {
prism: {
additionalLanguages: ["lua"],
Expand Down
1 change: 1 addition & 0 deletions cli/src/prepareProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type Config = Partial<{

home: Partial<{
enabled: boolean
bannerImage: string
includeReadme: boolean

features: {
Expand Down
17 changes: 14 additions & 3 deletions cli/template/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ export function HomepageFeatures() {

function HomepageHeader() {
const { siteConfig } = useDocusaurusContext()
const bannerImage = siteConfig.customFields.bannerImage
const hasBannerImage = bannerImage ? true : false
const heroBannerStyle = hasBannerImage ? { backgroundImage: `url("${bannerImage}")` } : null

const titleClassName = clsx("hero__title", {
[styles.titleOnBannerImage]: hasBannerImage
})
const taglineClassName = clsx("hero__subtitle", {
[styles.taglineOnBannerImage]: hasBannerImage
})

return (
<header className={clsx("hero", styles.heroBanner)}>
<header className={clsx("hero", styles.heroBanner)} style={heroBannerStyle}>
<div className="container">
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<h1 className={titleClassName}>{siteConfig.title}</h1>
<p className={taglineClassName}>{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link
className="button button--secondary button--lg"
Expand Down
14 changes: 14 additions & 0 deletions cli/template/home/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
text-align: center;
position: relative;
overflow: hidden;

background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

@media screen and (max-width: 966px) {
Expand All @@ -35,3 +39,13 @@
height: 200px;
width: 200px;
}

.titleOnBannerImage {
text-shadow: 0px 2px 4px rgb(0, 0, 0);
color: var(--ifm-color-gray-100);
}

.taglineOnBannerImage {
text-shadow: 0px 2px 4px rgb(0, 0, 0);
color: var(--ifm-color-gray-100);
}
1 change: 1 addition & 0 deletions website/docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ By default your project's README is used as the homepage. To use a custom homepa
[home]
enabled = true
includeReadme = true # Optional
bannerImage = "https://url" # Optional

[[home.features]]
title = "Feature 1"
Expand Down