Skip to content

Commit

Permalink
fix: Build
Browse files Browse the repository at this point in the history
  • Loading branch information
oodamien committed Jun 17, 2024
1 parent 114327f commit 196c293
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 56 deletions.
20 changes: 9 additions & 11 deletions src/helpers/versionTree.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
'use strict'

module.exports = (components) => versionTree(components)

function versionTree (components) {
return components.map((comp) => {
return {
...comp,
versions: splitVersions(comp.versions),
}
})
}

function splitVersions (versions) {
const snapshot = versions.filter((v) => v.version.includes('SNAPSHOT'))
const stable = versions.filter((v) => {
Expand All @@ -25,3 +14,12 @@ function splitVersions (versions) {
preview: preview.length > 0 ? preview : null,
}
}

module.exports = (components) => {
return Object.values(components)?.map((comp) => {
return {
...comp,
versions: splitVersions(comp.versions),
}
})
}
61 changes: 16 additions & 45 deletions src/partials/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,23 @@
</button>
<div class="colset">
<div class="col-left">

<ul class="nav-versions">
{{#each (versionTree site.components)}}
<li class="component">
<div>
<a class="title" href="{{{relativize ./url}}}">{{{./title}}}</a>
</div>


{{~#if (notEmpty ./versions.stable)}}
<div class="version-item is-active">
<div>
<button class="version-toggle" type="button">
<span></span>
Stable
</button>
</div>
{{> version-nav ./versions.stable}}
</div>
{{/if}}

{{~#if (notEmpty ./versions.preview)}}
<div class="version-item">
<div>
<button class="version-toggle" type="button">
<span></span>
Preview
</button>
</div>
{{> version-nav ./versions.preview}}
</div>
{{/if}}

{{~#if (notEmpty ./versions.snapshot)}}
<div class="version-item">
<div>
<button class="version-toggle" type="button">
<span></span>
Snapshot
</button>
</div>
{{> version-nav ./versions.snapshot}}
</div>
{{/if}}

</li>
{{#each site.components}}
<li class="component{{#if (eq this @root.page.component)}} is-current{{/if}}">
<a class="title" href="{{{relativize ./url}}}">{{{./title}}}</a>
<ul class="versions">
{{#each ./versions}}
<li class="version
{{~#if (and (eq .. @root.page.component) (eq this @root.page.componentVersion))}} is-current{{/if~}}
{{~#if (eq this ../latest)}} is-latest{{/if}}">
<a href="{{{relativize ./url}}}">
{{./displayVersion}}
{{~#if (eq this ../latest)}}<span class="current">current</span>{{/if}}
</a>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</div>
Expand Down

0 comments on commit 196c293

Please sign in to comment.