docs: embed GoatCounter visits counter
db-rest equivalent of 5b1ade80ed
This commit is contained in:
parent
9879365e9b
commit
63964f91f3
3 changed files with 28 additions and 1 deletions
|
@ -1,5 +1,10 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
// todo: use import assertions once they're supported by Node.js & ESLint
|
||||||
|
// https://github.com/tc39/proposal-import-assertions
|
||||||
|
import {createRequire} from 'module'
|
||||||
|
const require = createRequire(import.meta.url)
|
||||||
|
|
||||||
import {dirname, join} from 'node:path'
|
import {dirname, join} from 'node:path'
|
||||||
import {pipeline} from 'node:stream/promises'
|
import {pipeline} from 'node:stream/promises'
|
||||||
import {createReadStream, createWriteStream} from 'node:fs'
|
import {createReadStream, createWriteStream} from 'node:fs'
|
||||||
|
@ -12,6 +17,8 @@ const {
|
||||||
} = _technicalDocsCli
|
} = _technicalDocsCli
|
||||||
import {generateMarkdownApiDocs} from './api-docs.js'
|
import {generateMarkdownApiDocs} from './api-docs.js'
|
||||||
|
|
||||||
|
const pkg = require('../package.json')
|
||||||
|
|
||||||
const BASE_URL = new URL('..', import.meta.url).href
|
const BASE_URL = new URL('..', import.meta.url).href
|
||||||
const API_DOCS_DEST = 'docs/api.md'
|
const API_DOCS_DEST = 'docs/api.md'
|
||||||
const DOCS_TO_RENDER = [
|
const DOCS_TO_RENDER = [
|
||||||
|
@ -35,6 +42,23 @@ const SYNTAX_STYLESHEET_DEST = 'docs/syntax.css'
|
||||||
|
|
||||||
const markdownRenderingCfg = {
|
const markdownRenderingCfg = {
|
||||||
syntaxStylesheetUrl: SYNTAX_STYLESHEET_URL,
|
syntaxStylesheetUrl: SYNTAX_STYLESHEET_URL,
|
||||||
|
additionalHeadChildren: (h) => {
|
||||||
|
if (!pkg.goatCounterUrl) return []
|
||||||
|
return [
|
||||||
|
// https://72afc0822cce0642af90.goatcounter.com/help/skip-dev#skip-loading-staging-beta-sites-312
|
||||||
|
h('script', `
|
||||||
|
if (window.location.host !== ${JSON.stringify(config.hostname)}) {
|
||||||
|
window.goatcounter = {no_onload: true}
|
||||||
|
}
|
||||||
|
`),
|
||||||
|
// https://72afc0822cce0642af90.goatcounter.com/help/start
|
||||||
|
h('script', {
|
||||||
|
src: '//gc.zgo.at/count.js',
|
||||||
|
async: true,
|
||||||
|
'data-goatcounter': pkg.goatCounterUrl,
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for (const [src, dest] of DOCS_TO_RENDER) {
|
for (const [src, dest] of DOCS_TO_RENDER) {
|
||||||
console.info(`rendering Markdown file ${src} to HTML file ${dest}`)
|
console.info(`rendering Markdown file ${src} to HTML file ${dest}`)
|
||||||
|
|
|
@ -50,5 +50,6 @@
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"test": "node test/index.js | tap-min"
|
"test": "node test/index.js | tap-min"
|
||||||
}
|
},
|
||||||
|
"goatCounterUrl": "https://37462fdee48390778258.goatcounter.com/count"
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ git clone https://github.com/derhuerst/db-rest.git
|
||||||
cd db-rest
|
cd db-rest
|
||||||
git checkout 6
|
git checkout 6
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
export HOSTNAME='my-vbb-rest-api.example.org'
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
redis-server &
|
redis-server &
|
||||||
|
|
Loading…
Reference in a new issue