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> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Sharp Docs</title> <title>sharp - High performance Node.js image processing</title>
<link rel="stylesheet" href="https://unpkg.com/docute@4/dist/docute.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute@4/dist/docute.min.css">
</head> </head>
<body> <body>
<div id="docute"></div> <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> <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({ new Docute({
title: 'Sharp', router: { mode: 'history' },
// sourcePath:'https://cdn.jsdelivr.net/gh/lovell/sharp@latest/docs/' 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: [ nav: [
{ {
title: 'Home', title: 'Funding',
link: '/' link: 'https://opencollective.com/libvips'
}, },
{ {
title: 'Github', title: 'GitHub',
link: 'https://github.com/lovell/sharp' link: 'https://github.com/lovell/sharp'
} }
], ],
@ -31,13 +57,8 @@
link: '/' link: '/'
}, },
{ {
title: 'Getting Started', title: 'Installation',
children: [ link: '/install'
{
title: 'Installation',
link: '/install'
}
]
}, },
{ {
title: 'API', title: 'API',
@ -47,11 +68,11 @@
link: '/api-constructor' link: '/api-constructor'
}, },
{ {
title: 'Input', title: 'Input metadata',
link: '/api-input' link: '/api-input'
}, },
{ {
title: 'Output', title: 'Output options',
link: '/api-output' link: '/api-output'
}, },
{ {
@ -75,7 +96,7 @@
link: '/api-channel' link: '/api-channel'
}, },
{ {
title: 'Utilities', title: 'Global properties',
link: '/api-utility' link: '/api-utility'
}, },
], ],
@ -87,14 +108,10 @@
{ {
title: 'Changelog', title: 'Changelog',
link: '/changelog' link: '/changelog'
},
{
title: 'GitHub',
link: 'https://github.com/lovell/sharp'
} }
], ]
}) });
</script> </script>
</body> </body>
</html> </html>