Created
September 17, 2016 05:10
-
-
Save qwtel/d4e68cdd0e04ea1c02e39e8def3bf170 to your computer and use it in GitHub Desktop.
The problem with HTML? Not enough JSON!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render() { | |
return ( | |
['aside', { id: 'sidebar' }, | |
['div', { className: 'sidebar' }, | |
['div', { className: ['container', 'sidebar-sticky'] }, | |
['div', { className: 'sidebar-about' }, | |
['h1', { className: 'font-accent' }, | |
['a', { tabindex: '1', href: site.baseurl }, | |
site.title | |
], | |
], | |
], | |
['nav', { className: ['sidebar-nav', 'font-accent'] }, | |
['ul', | |
site.sidebarTags.map(listElement) | |
], | |
], | |
], | |
], | |
] | |
); | |
} | |
function listElement(tagKey) { | |
const tag = site.data.tags[tagKey]; | |
return ( | |
['li', | |
['a', { | |
tabindex: '1', | |
className: page.tag === tagKey ? 'active' : null, | |
href: `${site.baseurl}/tag/${tagKey}`, | |
}, | |
tag.name, | |
], | |
] | |
); | |
} | |
function renderCompact() { | |
return ( | |
['aside#sidebar', | |
['div.sidebar', | |
['div.container.sidebar-sticky', | |
['div.sidebar-about', | |
['h1.font-accent', | |
['a', { tabindex: '1', href: site.baseurl }, | |
site.title, | |
], | |
], | |
], | |
['nav.sidebar-nav.font-accent', | |
['ul', | |
site.sidebarTags.map(this.listElemente, this), | |
], | |
], | |
], | |
], | |
] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment