diff options
Diffstat (limited to 'src/page')
-rw-r--r-- | src/page/index.js | 2 | ||||
-rw-r--r-- | src/page/news.js | 141 |
2 files changed, 19 insertions, 124 deletions
diff --git a/src/page/index.js b/src/page/index.js index 408a7e72..a2cdbbdf 100644 --- a/src/page/index.js +++ b/src/page/index.js @@ -14,7 +14,7 @@ export * as artistAlias from './artist-alias.js'; export * as group from './group.js'; export * as homepage from './homepage.js'; export * as listing from './listing.js'; -// export * as news from './news.js'; +export * as news from './news.js'; export * as static from './static.js'; export * as tag from './tag.js'; export * as track from './track.js'; diff --git a/src/page/news.js b/src/page/news.js index 00d1e4dc..4928a116 100644 --- a/src/page/news.js +++ b/src/page/news.js @@ -10,130 +10,25 @@ export function targets({wikiData}) { return wikiData.newsData; } -export function write(entry, {wikiData}) { - const page = { - type: 'page', - path: ['newsEntry', entry.directory], - page: ({ - generateNavigationLinks, - html, - language, - link, - transformMultiline, - }) => ({ - title: language.$('newsEntryPage.title', {entry: entry.name}), - - main: { - classes: ['long-content'], - headingMode: 'sticky', - - content: [ - html.tag('p', - language.$('newsEntryPage.published', { - date: language.formatDate(entry.date), - })), - - transformMultiline(entry.content), - ], - }, - - nav: generateNewsEntryNav(entry, { - generateNavigationLinks, - html, - language, - link, - wikiData, - }), - }), - }; - - return [page]; -} - -export function writeTargetless({wikiData}) { - const {newsData} = wikiData; - - const page = { - type: 'page', - path: ['newsIndex'], - page: ({ - html, - language, - link, - transformMultiline, - }) => ({ - title: language.$('newsIndex.title'), - - main: { - classes: ['long-content', 'news-index'], - headingMode: 'sticky', - - content: - newsData.map(entry => - html.tag('article', - {id: entry.directory}, - [ - html.tag('h2', [ - html.tag('time', - language.formatDate(entry.date)), - link.newsEntry(entry), - ]), - - transformMultiline(entry.contentShort), - - entry.contentShort !== entry.content && - html.tag('p', - link.newsEntry(entry, { - text: language.$( - 'newsIndex.entry.viewRest' - ), - })), - ])), +export function pathsForTarget(newsEntry) { + return [ + { + type: 'page', + path: ['newsEntry', newsEntry.directory], + contentFunction: { + name: 'generateNewsEntryPage', + args: [newsEntry], }, - - nav: {simple: true}, - }), - }; - - return [page]; + }, + ]; } -function generateNewsEntryNav(entry, { - generateNavigationLinks, - html, - language, - link, - wikiData: {newsData}, -}) { - // The newsData list is sorted reverse chronologically (newest ones first), - // so the way we find next/previous entries is flipped from normal. - const previousNextLinks = generateNavigationLinks(entry, { - data: newsData.slice().reverse(), - linkKey: 'newsEntry', - - html, - language, - link, - }); - - return { - linkContainerClasses: ['nav-links-hierarchy'], - links: [ - {toHome: true}, - { - path: ['localized.newsIndex'], - title: language.$('newsEntryPage.nav.news'), - }, - { - html: language.$('newsEntryPage.nav.entry', { - date: language.formatDate(entry.date), - entry: link.newsEntry(entry, {class: 'current'}), - }), - }, - previousNextLinks && { - divider: false, - html: `(${previousNextLinks})`, - }, - ], - }; +export function pathsTargetless() { + return [ + { + type: 'page', + path: ['newsIndex'], + contentFunction: {name: 'generateNewsIndexPage'}, + }, + ]; } |