Docs: inject API section name as title

This commit is contained in:
Lovell Fuller 2020-01-04 11:11:27 +00:00
parent 3925689435
commit 43b7f9fc0e

View File

@ -4,24 +4,50 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Sharp Docs</title>
<link rel="stylesheet" href="https://unpkg.com/docute@4/dist/docute.css">
<title>sharp - High performance Node.js image processing</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute@4/dist/docute.min.css">
</head>
<body>
<div id="docute"></div>
<script src="https://unpkg.com/docute@4/dist/docute.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docute@4/dist/docute.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docute-google-analytics@1/dist/index.min.js"></script>
<script>
var docuteApiTitlePlugin = {
name: 'apiTitle',
extend(api) {
api.processMarkdown(function (md) {
var title = api.store.getters.sidebarLinks
.filter(function (sidebarLink) {
return sidebarLink.link === api.router.history.current.path
})
.map(function (sidebarLink) {
return sidebarLink.title;
})[0];
return title
? md.replace(/<!-- Generated by documentation.js. Update this documentation by updating the source code. -->/, '# ' + title)
: md;
});
}
};
new Docute({
title: 'Sharp',
// sourcePath:'https://cdn.jsdelivr.net/gh/lovell/sharp@latest/docs/'
router: { mode: 'history' },
logo: '<div><strong>sharp</strong> <span style="opacity:0.8">- High performance Node.js image processing</span></div>',
darkThemeToggler: true,
detectSystemDarkTheme: true,
footer: '<a href="https://pixelplumbing.com/" target="_blank">pixelplumbing.com<a>',
plugins: [
docuteGoogleAnalytics('UA-13034748-12'),
docuteApiTitlePlugin
],
sourcePath: 'https://cdn.jsdelivr.net/gh/lovell/sharp@wit/docs',
nav: [
{
title: 'Home',
link: '/'
title: 'Funding',
link: 'https://opencollective.com/libvips'
},
{
title: 'Github',
title: 'GitHub',
link: 'https://github.com/lovell/sharp'
}
],
@ -31,13 +57,8 @@
link: '/'
},
{
title: 'Getting Started',
children: [
{
title: 'Installation',
link: '/install'
}
]
title: 'Installation',
link: '/install'
},
{
title: 'API',
@ -47,11 +68,11 @@
link: '/api-constructor'
},
{
title: 'Input',
title: 'Input metadata',
link: '/api-input'
},
{
title: 'Output',
title: 'Output options',
link: '/api-output'
},
{
@ -75,7 +96,7 @@
link: '/api-channel'
},
{
title: 'Utilities',
title: 'Global properties',
link: '/api-utility'
},
],
@ -87,14 +108,10 @@
{
title: 'Changelog',
link: '/changelog'
},
{
title: 'GitHub',
link: 'https://github.com/lovell/sharp'
}
],
})
]
});
</script>
</body>
</html>
</html>