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

Skip fields without content from result. #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions assets/_includes/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h2 id="about">About {{company.title}}</h2>
</section>
{{/if}}

{{#if hasAbouts}}
{{#each presskit.abouts}}
<section class="block">
<h2 id="about_{{title}}">About {{title}}</h2>
Expand All @@ -27,3 +28,4 @@ <h2 id="about_{{title}}">About {{title}}</h2>
</dl>
</section>
{{/each}}
{{/if}}
8 changes: 7 additions & 1 deletion assets/_includes/description.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{{#if hasDescription}}
<h2 id="description">Description</h2>
<p>{{rawText presskit.description}}</p>
{{/if}}

{{#if hasHistoryOrHistories}}
<h2 id="history">History</h2>
{{#if presskit.history}}
{{/if}}
{{#if hasHistory}}
<p>{{rawText presskit.history}}</p>
{{/if}}

{{#if hasHistories}}
{{#each presskit.histories}}
<h3>{{header}}</h3>
<p>{{rawText text}}</p>
{{/each}}
{{/if}}
42 changes: 40 additions & 2 deletions assets/_includes/factsheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,81 @@ <h2 id="factsheet" class="factsheet__title">Factsheet</h2>

{{#if isCompany}}
<dl class="factsheet__list">

{{#if hasDeveloper}}
<dt>Developer:</dt>
<dd>
<a href=".">{{presskit.title}}</a>
</dd>

{{#if hasBasedIn}}
<dd>Based in {{presskit.basedIn}}</dd>
{{/if}}
{{/if}}

{{#if hasFoundingDate}}
<dt>Founding date:</dt>
<dd>{{presskit.foundingDate}}</dd>
{{/if}}

{{#if hasWebsite}}
<dt>Website:</dt>
<dd>
<a href="{{presskit.website}}">{{prettyURL presskit.website}}</a>
</dd>
{{/if}}

{{#if hasPressContact}}
<dt>Press / Business contact:</dt>
<dd>
<a href="mailto:{{presskit.pressContact}}">{{presskit.pressContact}}</a>
</dd>

{{/if}}
{{#if hasSocials}}
<dt>Social:</dt>
{{#each presskit.socials}}
<dd>
<a href="{{link}}">{{name}}</a>
</dd>
{{/each}}
{{/if}}

{{#if hasProducts}}
<dt>Releases:</dt>
{{#each products}}
<dd>
<a href="{{permalink path}}">{{title}}</a>
</dd>
{{/each}}
{{/if}}

{{#if hasAddresses}}
<dt>Address:</dt>
{{#each presskit.address.line}}
<dd>{{.}}</dd>
{{/each}}
{{/if}}

{{#if hasPhone}}
<dt>Phone:</dt>
<dd>{{presskit.phone}}</dd>
{{/if}}
</dl>
{{/if}}

{{#if isProduct}}
<dl class="factsheet__list">
{{#if hasCompanyDeveloper}}
<dt>Developer:</dt>
<dd>
<a href="..">{{company.title}}</a>
</dd>
{{#if hasCompanyBasedIn}}
<dd>Based in {{company.basedIn}}</dd>
{{/if}}
{{/if}}

{{#if hasPartners}}
{{#each presskit.partners}}
<dt>{{type}}:</dt>
<dd>
Expand All @@ -65,12 +89,17 @@ <h2 id="factsheet" class="factsheet__title">Factsheet</h2>
</dd>
{{#if basedIn}}<dd>Based in {{basedIn}}</dd>{{/if}}
{{/each}}
{{/if}}


{{#if hasReleaseDates}}
<dt>Release date:</dt>
{{#each presskit.releaseDates}}
<dd>{{.}}</dd>
{{/each}}
{{/if}}

{{#if hasPlatforms}}
<dt>Platforms:</dt>
{{#each presskit.platforms}}
<dd>
Expand All @@ -81,33 +110,42 @@ <h2 id="factsheet" class="factsheet__title">Factsheet</h2>
{{/if}}
</dd>
{{/each}}
{{/if}}

{{#if hasWebsite}}
<dt>Website:</dt>
<dd>
<a href="{{presskit.website}}">{{prettyURL presskit.website}}</a>
</dd>
{{/if}}

{{#if hasPrices}}
<dt>Regular Price:</dt>
{{#each presskit.prices}}
<dd>{{currency}} {{value}}</dd>
{{/each}}
{{/if}}

{{#if hasRelations}}
{{#each presskit.relations}}
<dt>{{type}}:</dt>
<dd>
<a href="{{permalink path}}">{{text}}</a>
</dd>
{{/each}}
{{/if}}

{{#if hasRelationsOf}}
{{#each presskit.relationOf}}
<dt>{{type}} of:</dt>
<dd>
<a href="{{permalink path}}">{{text}}</a>
</dd>
{{/each}}
{{/if}}
</dl>

{{#if presskit.pressCopyRequest}}
{{#if hasPressCopyRequest}}
<p class="press">
<a href="{{presskit.pressCopyRequest}}" class="button" tabindex="0">
Request Press Copy
Expand Down
2 changes: 2 additions & 0 deletions assets/company.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<article class="description grid__item">
{{>description}}

{{#if products}}
<h2 id="projects">Projects</h2>
<ul>
{{#each products}}
Expand All @@ -29,6 +30,7 @@ <h2 id="projects">Projects</h2>
</li>
{{/each}}
</ul>
{{/if}}
</article>
</section>

Expand Down
4 changes: 3 additions & 1 deletion assets/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

<article class="description grid__item">
{{>description}}

{{#if hasFeatures}}
<h2 id="features">Features</h2>
<ul>
{{#each presskit.features}}
<li>{{.}}</li>
{{/each}}
</ul>
{{/if}}

</article>
</section>

Expand Down
35 changes: 31 additions & 4 deletions lib/core/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,32 @@ async function build (dataFilePath, presskit, {
// variables to differentiate a product and a company sheet.
isCompany: presskit.type === 'company',
isProduct: presskit.type === 'product',

// Same to know if a presskit has any screenshots.
hasScreenshots: images.screenshots && images.screenshots.length > 0,

// Check if a presskit has any products, addresses, screenshots, etc.
hasDeveloper: checkValidVar(presskit.title),
hasBasedIn: checkValidVar(presskit.basedIn),
hasFoundingDate: checkValidVar(presskit.foundingDate),
hasWebsite: checkValidVar(presskit.website),
hasPressContact: checkValidVar(presskit.pressContact),
hasPhone: checkValidVar(presskit.phone),
hasCompanyDeveloper: checkValidVar(company.title),
hasCompanyBasedIn: checkValidVar(company.basedIn),
hasPressCopyRequest: checkValidVar(presskit.pressCopyRequest),
hasReleaseDates: checkValidVar(presskit.releaseDates),
hasDescription: checkValidVar(presskit.description),
hasHistory: checkValidVar(presskit.history),
hasProducts: checkValidVar(presskit.product) && presskit.product.length > 0,
hasAddresses: checkValidVar(presskit.address) && presskit.address.length > 0,
hasSocials: checkValidVar(presskit.socials) && presskit.socials.length > 0,
hasScreenshots: checkValidVar(images.screenshots) && images.screenshots.length > 0,
hasPartners: checkValidVar(presskit.partners) && presskit.partners.length > 0,
hasPrices: checkValidVar(presskit.prices) && presskit.prices.length > 0,
hasPlatforms: checkValidVar(presskit.platforms) && presskit.platforms.length > 0,
hasRelations: checkValidVar(presskit.relations) && presskit.relations.length > 0,
hasRelationsOf: checkValidVar(presskit.relationOf) && presskit.relationOf.length > 0,
hasHistories: checkValidVar(presskit.histories) && presskit.histories.length > 0,
hasFeatures: checkValidVar(presskit.features) && presskit.features.length > 0,
hasAbouts: checkValidVar(presskit.abouts) && presskit.abouts.length > 0,
hasHistoryOrHistories: checkValidVar(presskit.history) || (checkValidVar(presskit.histories) && presskit.histories.length > 0),
// Additional build options:
hamburger: config.commands.build.hamburger,

Expand All @@ -86,6 +108,11 @@ async function build (dataFilePath, presskit, {
return path.relative(buildFolder, htmlFilePath)
}

// Check if a var exists or it's valid
function checkValidVar (value) {
return (typeof value !== 'undefined' && value)
}

// -------------------------------------------------------------
// Folders.
// -------------------------------------------------------------
Expand Down