Skip to content

Instantly share code, notes, and snippets.

@qwtel
Created September 17, 2016 05:10
Show Gist options
  • Save qwtel/d4e68cdd0e04ea1c02e39e8def3bf170 to your computer and use it in GitHub Desktop.
Save qwtel/d4e68cdd0e04ea1c02e39e8def3bf170 to your computer and use it in GitHub Desktop.
The problem with HTML? Not enough JSON!
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