UNPKG

719 BJavaScriptView Raw
1import { getLink, getFileUrl } from './util.js'
2// Get History Section
3export function getHistorySection(data) {
4 // Prepare
5 let link = null
6 const file = data.filenamesForReadmeFiles.history
7 if (file) {
8 link = getLink({
9 url: getFileUrl(data, file),
10 text: `Discover the release history by heading on over to the <code>${file}</code> file.`,
11 })
12 } else if (data.github.slug) {
13 link = getLink({
14 url: `https://github.com/${data.github.slug}/releases`,
15 text:
16 'Discover the release history by heading on over to the releases page.',
17 })
18 } else {
19 throw new Error(
20 'History section either requires a HISTORY file or a Github repository'
21 )
22 }
23 // Return
24 return '<h2>History</h2>\n\n' + link
25}