Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const h = require('hyperscript')
  4.  
  5. module.exports = function (opts = {}) {
  6. // Prepare
  7. const { document, content } = this
  8. const {
  9. permalink = document.url,
  10. heading = document.title,
  11. subheading = document.subheading,
  12. author = document.author,
  13. cssClasses = (document.cssClasses || []),
  14. editUrl = document.editUrl,
  15. date,
  16. prev,
  17. next,
  18. up,
  19. parents = []
  20. } = opts
  21.  
  22. // Render
  23. const classes = ['block'].concat(cssClasses)
  24. return h('article', {
  25. class: classes.join(' ')
  26. }, [
  27. h('header', {class: 'block-header'}, [
  28. parents.length ? h('nav', { class: 'parentcrumbs' }, [
  29. h('ul', parents.map((parent) => h('li', [
  30. h('a', {
  31. class: 'permalink',
  32. href: parent.url
  33. }, [
  34. h('h3', parent.title)
  35. ])
  36. ])
  37. ))
  38. ]) : null,
  39. permalink ? h('a', {
  40. class: 'permalink hover-link',
  41. href: permalink
  42. }, [
  43. h('h1', heading)
  44. ]) : h('h1', heading),
  45. subheading ? h('h2', subheading) : '',
  46. date ? h('span', { class: 'date' }, date) : '',
  47. author ? h('a', {
  48. class: 'author',
  49. href: `/people/${author}`
  50. }, author) : ''
  51. ]),
  52. h('section', { class: 'block-content', innerHTML: content }),
  53. h('footer', { class: 'block-footer' }, [
  54. (prev || up || next) ? h('nav', { class: 'prev-next' }, [
  55. prev ? h('a', {
  56. class: 'prev',
  57. href: prev.url
  58. }, [
  59. h('span', { class: 'icon' }),
  60. h('span', { class: 'title' }, prev.title)
  61. ]) : '',
  62. up ? h('a', {
  63. class: 'up',
  64. href: up.url
  65. }, [
  66. h('span', { class: 'icon' }),
  67. h('span', { class: 'title' }, up.title)
  68. ]) : '',
  69. next ? h('a', {
  70. class: 'next',
  71. href: next.url
  72. }, [
  73. h('span', { class: 'icon' }),
  74. h('span', { class: 'title' }, next.title)
  75. ]) : ''
  76. ]) : ''
  77. ]),
  78. editUrl ? h('aside', { class: 'block-edit' }, [
  79. h('a', { href: editUrl }, 'Edit and improve this page!')
  80. ]) : ''
  81. ])
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement