UNPKG

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