Skip to content

Commit

Permalink
feat: show bip page
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu89 committed Jan 21, 2024
1 parent 6dcecc7 commit 16a8e44
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/controllers/bips_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ export default class BipsController {
const lastUpdate = await this.bipService.getLastUpdate()
return view.render('index', { bips, lastUpdate })
}

public async show({ params, view, response }: HttpContext) {
const { bip } = params

const data = await this.bipService.getBip(bip)
if (!data?.title) {
return response.notFound()
}
const lastUpdate = await this.bipService.getLastUpdate()

return view.render('bip', { bip: data, lastUpdate })
}
}
2 changes: 1 addition & 1 deletion app/services/github_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class GithubService {
})

// Gist creation
const fileName = `test.md`
const fileName = `tmp-bips.mediawiki`
const gistCreationResult = await octokit.gists.create({
public: false,
files: { [fileName]: { content: content } },
Expand Down
7 changes: 7 additions & 0 deletions resources/views/bip.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@layout({
title: `BIP${bip.bip} - ${bip.title}`,
description: `Read more about the BIP${bip.bip} on bips.xyz - ${bip.title}`
})
<h1>{{bip.title}}</h1>
{{{bip.content}}}
@end
4 changes: 2 additions & 2 deletions start/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
import router from '@adonisjs/core/services/router'
const BipsController = () => import('#controllers/bips_controller')


router.get('/', [BipsController, 'index'])
router.get('/', [BipsController, 'index'])
router.get('/:bip', [BipsController, 'show']).where('bip', '[0-9]')

0 comments on commit 16a8e44

Please sign in to comment.