guides and api sections working
This commit is contained in:
Родитель
10b5181dbd
Коммит
c8280aaae8
|
@ -0,0 +1,12 @@
|
|||
module.exports = (req, res) => {
|
||||
const category = req.params.category
|
||||
if (['tutorial', 'api', 'advanced'].includes(category)) {
|
||||
const capitalize = str => str.charAt(0).toUpperCase() + str.substring(1);
|
||||
const context = Object.assign(req.context, {
|
||||
layout: 'docs',
|
||||
category: capitalize(category)
|
||||
})
|
||||
|
||||
res.render(`docs/${category}`, context)
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ const i18n = require('../../lib/i18n')
|
|||
|
||||
module.exports = (req, res) => {
|
||||
const doc = i18n.docs[req.language][req.path]
|
||||
|
||||
if (!doc) return res.status(404).render('404')
|
||||
|
||||
const context = Object.assign(req.context, {
|
||||
|
@ -12,4 +11,4 @@ module.exports = (req, res) => {
|
|||
})
|
||||
|
||||
res.render('docs/show', context)
|
||||
}
|
||||
}
|
|
@ -61,7 +61,8 @@ app.get('/app/:slug', (req, res) => res.redirect(`/apps/${req.params.slug}`))
|
|||
app.get('/apps/:slug', routes.apps.show)
|
||||
|
||||
app.get('/docs', routes.docs.index)
|
||||
app.get('/docs/*', routes.docs.show)
|
||||
app.get('/docs/:category', routes.docs.category)
|
||||
app.get('/docs/:category/*', routes.docs.show)
|
||||
|
||||
app.get('/userland', routes.userland.index)
|
||||
app.get('/userland/*', routes.userland.show)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<h2 class="docs-heading pb-3 mb-3"><span class="mega-octicon octicon-gear pr-3"></span>API Reference</h2>
|
||||
|
||||
<table class="table table-ruled table-full-width table-with-spacious-second-column">
|
||||
<tr>
|
||||
<th>API</th><th>Processes</th><th>Description</th>
|
||||
</tr>
|
||||
|
||||
{{#each docs}}
|
||||
{{#if this.isApiDoc}}
|
||||
{{#includes this.source_url '/structures/'}}
|
||||
<!-- DO NOTHING -->
|
||||
{{else}}
|
||||
<tr>
|
||||
<td><a href="{{ site.baseurl }}{{ this.url }}">{{ this.title }}</a></td>
|
||||
<td>{{ this.excerpt }}</td>
|
||||
</tr>
|
||||
{{/includes}}
|
||||
{{else}}
|
||||
<!-- DO NOTHING -->
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
</table>
|
|
@ -13,7 +13,7 @@
|
|||
<div class="row">
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/docs/"><span class="mega-octicon octicon-book pr-3"></span>Guides</a></h2>
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/tutorial"><span class="mega-octicon octicon-book pr-3"></span>Guides</a></h2>
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isTutorial}}
|
||||
|
@ -39,7 +39,7 @@
|
|||
</div>
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/development/"><span class="mega-octicon octicon-tools pr-3"></span>Advanced</a></h2>
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/advanced/"><span class="mega-octicon octicon-tools pr-3"></span>Advanced</a></h2>
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isDevTutorial}}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<h2 class="docs-heading pb-3 mb-3"><span class="mega-octicon octicon-book pr-3"></span>Guides</h2>
|
||||
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isTutorial}}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ this.href }}"> {{ this.title }}</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</ul>
|
|
@ -1,11 +1,17 @@
|
|||
{{!< main}}
|
||||
|
||||
<div class='subtron text-left'>
|
||||
<h1><span class="mr-3 mr-lg-4">Electron Documentation</span><span class="docs-version">{{electronLatestStableVersion}}</span></h1>
|
||||
|
||||
<div class='container-narrow'>
|
||||
|
||||
<h4 class="docs-breadcrumbs">
|
||||
<a href='/docs/'>Docs</a> /
|
||||
<a href="/docs/{{doc.category}}">{{doc.categoryFancy}}</a> / {{doc.title}}
|
||||
<a href='/docs/'>Docs</a> /
|
||||
{{#if category}}
|
||||
<a href="/docs/{{doc.category}}">{{category}}</a>
|
||||
{{else}}
|
||||
<a href="/docs/{{doc.category}}">{{doc.categoryFancy}}</a> / {{doc.title}}
|
||||
{{/if}}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Загрузка…
Ссылка в новой задаче