From c51480ba2f57bf29498a9a518e02d228c44d315a Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 10:43:09 +0200 Subject: [PATCH 01/17] refactor: use highlighting plugin instead of custom shortcode, add inline markdown filter --- docs/eleventy.config.js | 57 +++++++---------------------------------- package-lock.json | 15 ++++++++++- package.json | 7 +++-- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/docs/eleventy.config.js b/docs/eleventy.config.js index 3ff0e68e26..0f3f2ddd76 100644 --- a/docs/eleventy.config.js +++ b/docs/eleventy.config.js @@ -1,11 +1,10 @@ const markdownIt = require('markdown-it'); -const Prism = require('prismjs'); -const loadLanguages = require('prismjs/components/'); const LINEBREAK_PLACEHOLDER = '---linebreak-placeholder---'; module.exports = eleventyConfig => { process.env.TZ = 'UTC'; + eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-syntaxhighlight")); eleventyConfig.addPassthroughCopy('asf.md'); eleventyConfig.addPassthroughCopy('static'); @@ -56,14 +55,16 @@ module.exports = eleventyConfig => { return this.liquid.parseAndRender(content, this.context); }); - const renderMarkdown = initMarkdown(); + const md = markdownIt({ + html: true, + }); + + eleventyConfig.addFilter('inlinemarkdown', content => md.renderInline(content)); // Re-defined markdown-it lib to prevent eleventy messing with internals. // See: https://github.com/11ty/eleventy/issues/2438 - eleventyConfig.setLibrary('md', { render:renderMarkdown }); - eleventyConfig.addFilter('markdown', renderMarkdown); - eleventyConfig.addPairedShortcode('markdown', renderMarkdown); - - eleventyConfig.addPairedShortcode('highlight', wrapCode); + eleventyConfig.setLibrary('md', md); + eleventyConfig.addFilter('markdown', content => md.render(content)); + eleventyConfig.addPairedShortcode('markdown', content => md.render(content)); eleventyConfig.addTransform('revert-linebreak-markers', function(content) { console.log('revert-linebreak-markers', this.outputPath); @@ -78,43 +79,3 @@ module.exports = eleventyConfig => { }, }; }; - -// Ensure consistent code style across: -// * markdown indented code blocks -// * markdown "fenced" code blocks -// * liquid {% highlight ... %} code blocks -function initMarkdown() { - const md = markdownIt({ - html: true, - }); - - // Indented code blocks seem to introduce parsing differences across - // markdownversions, and inconsistencies with whitespace introduced - // by liquid templates. The simplest option is to disable them, and - // require code "fences" (```) instead. - md.disable('code'); - - md.renderer.rules.fence = (tokens, idx, options, env, slf) => { - const { content, info } = tokens[idx]; - const lang = info ? info.trim().split(/\s/)[0] : ''; - - return wrapCode(content, lang); - }; - - return md.render.bind(md); -} - -function wrapCode(code, lang) { - let html = code.trim(); - - if(lang) { - loadLanguages([lang]); - html = Prism.highlight(html, Prism.languages[lang], lang); - } - - // prevent markdown interpreter from converting multiple - // linebreaks in code examples into

...

- html = html.replaceAll(/\n(?=\n)/g, `\n${LINEBREAK_PLACEHOLDER}`); - - return `
${html}
`; -} diff --git a/package-lock.json b/package-lock.json index 429ef0a423..1edf8f7c92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "7.0.0-prerelease", "license": "Apache-2.0", "dependencies": { + "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "@neighbourhoodie/websql": "2.0.4", "double-ended-queue": "2.1.0-0", "fetch-cookie": "2.2.0", @@ -363,6 +364,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@11ty/eleventy-plugin-syntaxhighlight": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-5.0.2.tgz", + "integrity": "sha512-T6xVVRDJuHlrFMHbUiZkHjj5o1IlLzZW+1IL9eUsyXFU7rY2ztcYhZew/64vmceFFpQwzuSfxQOXxTJYmKkQ+A==", + "license": "MIT", + "dependencies": { + "prismjs": "^1.30.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, "node_modules/@11ty/eleventy-utils": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-2.0.7.tgz", @@ -8936,7 +8950,6 @@ "version": "1.30.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", "integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" diff --git a/package.json b/package.json index e8eed0f0a3..f44fb0ce6e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "release": "./bin/release.sh", "publish-site": "./bin/publish-site.sh", "build-site": "node ./bin/build-site.js", + "build:less": "lessc docs/src/less/pouchdb/pouchdb.less docs/static/css/pouchdb.css", + "build11": "npm run build:less && eleventy", "test-coverage": "./bin/test-coverage.sh", "coverage": "COVERAGE=1 SERVER=pouchdb-server POUCHDB_SERVER_FLAGS=--in-memory PLUGINS=pouchdb-find ./bin/test-coverage.sh", "build-test": "npm run build-test-utils && npm run build-perf", @@ -36,6 +38,8 @@ "url": "https://github.com/apache/pouchdb.git" }, "dependencies": { + "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", + "@neighbourhoodie/websql": "2.0.4", "double-ended-queue": "2.1.0-0", "fetch-cookie": "2.2.0", "level": "6.0.1", @@ -51,8 +55,7 @@ "spark-md5": "3.0.2", "through2": "3.0.2", "uuid": "8.3.2", - "vuvuzela": "1.0.3", - "@neighbourhoodie/websql": "2.0.4" + "vuvuzela": "1.0.3" }, "devDependencies": { "@11ty/eleventy": "3.1.2", From 328dc2bb013e8799cbd3d611eda1ab2d57e4c57e Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 10:43:28 +0200 Subject: [PATCH 02/17] fix: Tune syntax highlighting colours, fix margins for JS style tabs above code blocks --- docs/src/less/pouchdb/code.less | 23 ++++++++++++++++++----- docs/src/less/pouchdb/navs.less | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/src/less/pouchdb/code.less b/docs/src/less/pouchdb/code.less index cff926eafc..99666985ed 100644 --- a/docs/src/less/pouchdb/code.less +++ b/docs/src/less/pouchdb/code.less @@ -7,6 +7,8 @@ code { pre { padding-left: @pre-padding; padding-right: @pre-padding; + background-color:@dry-slate; + color:@soft-green } @duck-egg: #66d9ef; @@ -16,25 +18,36 @@ pre { @pinky: #f92672; @soft-green: #6eca97; @dry-slate: #3f3f3f; +@mud: #75715e; @whitish: #f8f8f2; -.language-bash { background-color:@dry-slate; color:@whitish } .language-bash .token.parameter.variable { color:@pinky } -.language-html { background-color:@dry-slate; color:@soft-green } -.language-js,.language-javascript { background-color:@dry-slate; color:@soft-green } +.language-html { color:@soft-green } +.language-html { + color: @whitish; + .tag, + .tag .punctuation { + color: #f92672; + } +} +.language-js,.language-javascript { color:@soft-green } .token.attr-name { color:@martian-green } .token.attr-value { color:@mustard } -.token.tag .token.attr-value .attr-equals { color:@martian-green } +.token.boolean { color:@duck-egg } .token.tag .token.attr-value .token.punctuation { color:@mustard } .token.class-name { color:@soft-green } +.token.comment { color:@mud } .token.function { color:@soft-green } .token.keyword { color:@duck-egg } .token.number { color:@purple } .token.operator { color:@pinky } .token.property + .token.operator { color:@whitish } -.token.property { color:@martian-green } +.token.parameter { color:@soft-green } +.token.property { color:@mustard } .token.punctuation { color:@whitish } .token.string { color:@mustard } .token.tag { color:@pinky } .token.tag .token.punctuation { color:@pinky } + +.token.tag .token.attr-value .attr-equals, .token.attr-name, .token.attr-equals, .token.literal-property, .token.function-variable { color:@martian-green } \ No newline at end of file diff --git a/docs/src/less/pouchdb/navs.less b/docs/src/less/pouchdb/navs.less index 18e848f638..a022b3dbb0 100644 --- a/docs/src/less/pouchdb/navs.less +++ b/docs/src/less/pouchdb/navs.less @@ -88,6 +88,7 @@ color: #eee; padding-bottom: 15px; margin-bottom: -15px; + z-index: 1; } .nav-code > li > a:hover { border-color: transparent; From 8693a1107828c92c35c445fb7538eb9f6fbcf709 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 10:44:44 +0200 Subject: [PATCH 03/17] chore: remove quotation marks from highlight block language attribute --- docs/_includes/api/active_tasks.html | 8 ++-- docs/_includes/api/batch_create.html | 30 ++++++------- docs/_includes/api/batch_fetch.html | 22 +++++----- docs/_includes/api/bulk_get.html | 10 ++--- docs/_includes/api/changes.html | 38 ++++++++--------- docs/_includes/api/close_database.html | 8 ++-- docs/_includes/api/compaction.html | 10 ++--- docs/_includes/api/create_database.html | 8 ++-- docs/_includes/api/create_document.html | 26 ++++++------ docs/_includes/api/create_index.html | 38 ++++++++--------- docs/_includes/api/database_information.html | 10 ++--- docs/_includes/api/defaults.html | 4 +- docs/_includes/api/delete_attachment.html | 10 ++--- docs/_includes/api/delete_database.html | 10 ++--- docs/_includes/api/delete_document.html | 24 +++++------ docs/_includes/api/delete_index.html | 16 +++---- docs/_includes/api/events.html | 2 +- docs/_includes/api/explain_index.html | 10 ++--- docs/_includes/api/fetch_document.html | 10 ++--- docs/_includes/api/get_attachment.html | 18 ++++---- docs/_includes/api/list_indexes.html | 10 ++--- docs/_includes/api/overview.html | 8 ++-- docs/_includes/api/plugins.html | 12 +++--- docs/_includes/api/purge.html | 10 ++--- docs/_includes/api/query_database.html | 32 +++++++------- docs/_includes/api/query_index.html | 42 +++++++++---------- docs/_includes/api/replication.html | 36 ++++++++-------- docs/_includes/api/revisions_diff.html | 10 ++--- docs/_includes/api/save_attachment.html | 36 ++++++++-------- docs/_includes/api/sync.html | 14 +++---- docs/_includes/api/view_cleanup.html | 10 ++--- docs/download.md | 12 +++--- docs/errors.md | 6 +-- docs/getting-started.md | 26 ++++++------ docs/index.md | 2 +- ...5-03-05-taming-the-async-beast-with-es7.md | 36 ++++++++-------- docs/posts/2015-04-05-filtered-replication.md | 8 ++-- 37 files changed, 311 insertions(+), 311 deletions(-) diff --git a/docs/_includes/api/active_tasks.html b/docs/_includes/api/active_tasks.html index 0d57da5b8a..673a8a8850 100644 --- a/docs/_includes/api/active_tasks.html +++ b/docs/_includes/api/active_tasks.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="List active tasks" hash="active_tasks" %} -{% highlight "js" %} +{% highlight js %} PouchDB.activeTasks.list() {% endhighlight %} @@ -8,13 +8,13 @@ #### Example Usage: -{% highlight "js" %} +{% highlight js %} const tasks = PouchDB.activeTasks.list() {% endhighlight %} #### Example Result: -{% highlight "js" %} +{% highlight js %} [{ "id": "d81fea92-8ce4-42df-bb2b-89a4e67536c3", "name": "database_compaction", @@ -29,7 +29,7 @@ You can use [JavaScript Proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) to monitor calls to the active tasks API. For the `PouchDB.activeTasks.add()` function, which is used internally to announce new tasks to PouchDB, you can monitor calls as follows: -{% highlight "js" %} +{% highlight js %} PouchDB.activeTasks.add = new Proxy(PouchDB.activeTasks.add, { apply: (target, thisArg, argumentsList) => { const task = argumentsList[0]; diff --git a/docs/_includes/api/batch_create.html b/docs/_includes/api/batch_create.html index aa7510617f..13f58a6abf 100644 --- a/docs/_includes/api/batch_create.html +++ b/docs/_includes/api/batch_create.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Create/update a batch of documents" hash="batch_create" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs(docs, [options], [callback]) {% endhighlight %} @@ -13,7 +13,7 @@ Put some new docs, providing the `_id`s: {% include code/start.html id="bulk_docs_1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ {title : 'Lisa Says', _id: 'doc1'}, {title : 'Space Oddity', _id: 'doc2'} @@ -25,7 +25,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.bulkDocs([ {title : 'Lisa Says', _id: 'doc1'}, @@ -38,7 +38,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ {title : 'Lisa Says', _id: 'doc1'}, {title : 'Space Oddity', _id: 'doc2'} @@ -53,7 +53,7 @@ Post some new docs and auto-generate the `_id`s: {% include code/start.html id="bulk_docs_2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ {title : 'Lisa Says'}, {title : 'Space Oddity'} @@ -65,7 +65,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.bulkDocs([ {title : 'Lisa Says'}, @@ -78,7 +78,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ {title : 'Lisa Says'}, {title : 'Space Oddity'} @@ -91,7 +91,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} [ { "ok": true, @@ -110,7 +110,7 @@ from the [put()/post() API](#create_document). If there are any errors, they will be provided individually like so: -{% highlight "js" %} +{% highlight js %} [ { status: 409, name: 'conflict', @@ -131,7 +131,7 @@ You can also use `bulkDocs()` to update/delete many documents at once: {% include code/start.html id="bulk_docs3" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ { title : 'Lisa Says', @@ -153,7 +153,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.bulkDocs([ { @@ -176,7 +176,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs3" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ { title : 'Lisa Says', @@ -201,7 +201,7 @@ Or delete them: {% include code/start.html id="bulk_docs_4" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ { title : 'Lisa Says', @@ -223,7 +223,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_4" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.bulkDocs([ { @@ -246,7 +246,7 @@ {% include code/end.html %} {% include code/start.html id="bulk_docs_4" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.bulkDocs([ { title : 'Lisa Says', diff --git a/docs/_includes/api/batch_fetch.html b/docs/_includes/api/batch_fetch.html index ce970a9407..0e7e6749ae 100644 --- a/docs/_includes/api/batch_fetch.html +++ b/docs/_includes/api/batch_fetch.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Fetch a batch of documents" hash="batch_fetch" %} -{% highlight "js" %} +{% highlight js %} db.allDocs([options], [callback]) {% endhighlight %} @@ -33,7 +33,7 @@ #### Example Usage: {% include code/start.html id="all_docs" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true @@ -45,7 +45,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.allDocs({ include_docs: true, @@ -58,7 +58,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true @@ -72,7 +72,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "offset": 0, "total_rows": 1, @@ -109,7 +109,7 @@ You can use `startkey`/`endkey` to find all docs in a range: {% include code/start.html id="all_docs_2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true, @@ -123,7 +123,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs_2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.allDocs({ include_docs: true, @@ -138,7 +138,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs_2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true, @@ -159,7 +159,7 @@ You can do prefix search in `allDocs()` – i.e. "give me all the documents whose `_id`s start with `'foo'`" – by using the special high Unicode character `'\ufff0'`: {% include code/start.html id="all_docs_3" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true, @@ -173,7 +173,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs_3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.allDocs({ include_docs: true, @@ -188,7 +188,7 @@ {% include code/end.html %} {% include code/start.html id="all_docs_3" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.allDocs({ include_docs: true, attachments: true, diff --git a/docs/_includes/api/bulk_get.html b/docs/_includes/api/bulk_get.html index d5cb826f1c..a664a3e1b3 100644 --- a/docs/_includes/api/bulk_get.html +++ b/docs/_includes/api/bulk_get.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Document bulk get" hash="bulk_get" %} -{% highlight "js" %} +{% highlight js %} db.bulkGet(options, [callback]) {% endhighlight %} @@ -21,7 +21,7 @@ #### Example Usage: {% include code/start.html id="bulkget1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.bulkGet({ docs: [ { id: "existing-doc", rev: "1-b2e54331db828310f3c772d6e042ac9c"}, @@ -36,7 +36,7 @@ {% include code/end.html %} {% include code/start.html id="bulkget1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.bulkGet({ docs: [ @@ -52,7 +52,7 @@ {% include code/end.html %} {% include code/start.html id="bulkget1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.bulkGet({ docs: [ { id: "doc-that-exists", rev: "1-967a00dff5e02add41819138abb3284d"}, @@ -68,7 +68,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "results": [ { diff --git a/docs/_includes/api/changes.html b/docs/_includes/api/changes.html index 706c00cfe8..6bfbf69079 100644 --- a/docs/_includes/api/changes.html +++ b/docs/_includes/api/changes.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Listen to database changes" hash="changes" %} -{% highlight "js" %} +{% highlight js %} db.changes(options) {% endhighlight %} @@ -41,7 +41,7 @@ #### Example Usage: -{% highlight "js" %} +{% highlight js %} const changes = db.changes({ since: 'now', live: true, @@ -58,7 +58,7 @@ {% endhighlight %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "id":"somestuff", "seq":21, @@ -83,7 +83,7 @@ Example response in the `'change'` listener (using `{include_docs: true}`): -{% highlight "js" %} +{% highlight js %} { id: 'doc1', changes: [ { rev: '1-9152679630cc461b9477792d93b83eae' } ], doc: { @@ -96,7 +96,7 @@ Example response in the `'change'` listener when a doc was deleted: -{% highlight "js" %} +{% highlight js %} { id: 'doc2', changes: [ { rev: '2-9b50a4b63008378e8d0718a9ad05c7af' } ], doc: { _id: 'doc2', @@ -110,7 +110,7 @@ Example response in the `'complete'` listener: -{% highlight "js" %} +{% highlight js %} { "results": [ { @@ -147,7 +147,7 @@ returns a list of the changes (i.e. what the `'complete'` event emits): {% include code/start.html id="changes1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.changes({ limit: 10, since: 0 @@ -159,7 +159,7 @@ {% include code/end.html %} {% include code/start.html id="changes1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.changes({ limit: 10, @@ -172,7 +172,7 @@ {% include code/end.html %} {% include code/start.html id="changes1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.changes({ limit: 10, since: 0 @@ -186,7 +186,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "results": [{ "id": "0B3358C1-BA4B-4186-8795-9024203EB7DD", @@ -242,7 +242,7 @@ In these examples, we'll work with some mammals. Let's imagine our docs are: -{% highlight "js" %} +{% highlight js %} [ {_id: 'a', name: 'Kangaroo', type: 'marsupial'}, {_id: 'b', name: 'Koala', type: 'marsupial'}, @@ -258,7 +258,7 @@ Filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} db.changes({ filter: function (doc) { return doc.type === 'marsupial'; @@ -270,7 +270,7 @@ Filter documents with `_id`s `['a', 'c']`. -{% highlight "js" %} +{% highlight js %} db.changes({ doc_ids: ['a', 'c'] }); @@ -280,7 +280,7 @@ First `put()` a design document: -{% highlight "js" %} +{% highlight js %} { _id: '_design/mydesign', filters: { @@ -293,7 +293,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} db.changes({ filter: 'mydesign/myfilter' }); @@ -305,7 +305,7 @@ First `put()` a design document: -{% highlight "js" %} +{% highlight js %} { _id: '_design/myfilter', filters: { @@ -318,7 +318,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} db.changes({ filter: 'myfilter', query_params: {type: 'marsupial'} @@ -335,7 +335,7 @@ First `put()` a design document: -{% highlight "js" %} +{% highlight js %} { _id: '_design/mydesign', views: { @@ -350,7 +350,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} db.changes({ filter: '_view', view: 'mydesign/myview' diff --git a/docs/_includes/api/close_database.html b/docs/_includes/api/close_database.html index 71ff21d78c..3e82f1563e 100644 --- a/docs/_includes/api/close_database.html +++ b/docs/_includes/api/close_database.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Close a database" hash="close_database"%} -{% highlight "js" %} +{% highlight js %} db.close([callback]) {% endhighlight %} @@ -9,7 +9,7 @@ #### Example Usage {% include code/start.html id="close_db" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.close(function () { // success }); @@ -18,14 +18,14 @@ {% include code/start.html id="close_db" type="async" %} -{% highlight "js" %} +{% highlight js %} await db.close(); {% endhighlight %} {% include code/end.html %} {% include code/start.html id="close_db" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.close().then(function () { // success }); diff --git a/docs/_includes/api/compaction.html b/docs/_includes/api/compaction.html index 7b12671a18..c936375d54 100644 --- a/docs/_includes/api/compaction.html +++ b/docs/_includes/api/compaction.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Compact the database" hash="compaction" %} -{% highlight "js" %} +{% highlight js %} db.compact([options], [callback]) {% endhighlight %} @@ -15,7 +15,7 @@ #### Example Usage: {% include code/start.html id="compact" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.compact(function (err, result) { if (err) { return console.log(err); } // handle result @@ -24,7 +24,7 @@ {% include code/end.html %} {% include code/start.html id="compact" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.compact(); } catch (err) { @@ -34,7 +34,7 @@ {% include code/end.html %} {% include code/start.html id="compact" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.compact().then(function (result) { // handle result }).catch(function (err) { @@ -44,6 +44,6 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok" : "true" } {% endhighlight %} diff --git a/docs/_includes/api/create_database.html b/docs/_includes/api/create_database.html index 3d606f47f8..d2792ca0fc 100644 --- a/docs/_includes/api/create_database.html +++ b/docs/_includes/api/create_database.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Create a database" hash="create_database" %} -{% highlight "js" %} +{% highlight js %} new PouchDB([name], [options]) {% endhighlight %} @@ -38,7 +38,7 @@ [levelup_options]: https://github.com/rvagg/node-levelup/#options #### Example Usage: -{% highlight "js" %} +{% highlight js %} const db = new PouchDB('dbname'); // or const db = new PouchDB('http://localhost:5984/dbname'); @@ -46,13 +46,13 @@ Create an in-memory Pouch (must install `pouchdb-adapter-memory` first): -{% highlight "js" %} +{% highlight js %} const db = new PouchDB('dbname', {adapter: 'memory'}); {% endhighlight %} Create a remote PouchDB with special fetch options: -{% highlight "js" %} +{% highlight js %} const db = new PouchDB('http://example.com/dbname', { fetch: function (url, opts) { opts.headers.set('X-Some-Special-Header', 'foo'); diff --git a/docs/_includes/api/create_document.html b/docs/_includes/api/create_document.html index d0f2a61451..6a377ead31 100644 --- a/docs/_includes/api/create_document.html +++ b/docs/_includes/api/create_document.html @@ -1,7 +1,7 @@ {% include anchor.html edit="true" title="Create/update a document" hash="create_document" %} ### Using db.put() -{% highlight "js" %} +{% highlight js %} db.put(doc, [options], [callback]) {% endhighlight %} @@ -16,7 +16,7 @@ Create a new doc with an `_id` of `'mydoc'`: {% include code/start.html id="newDoc" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.put({ _id: 'mydoc', title: 'Heroes' @@ -28,7 +28,7 @@ {% include code/end.html %} {% include code/start.html id="newDoc" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const response = await db.put({ _id: 'mydoc', @@ -41,7 +41,7 @@ {% include code/end.html %} {% include code/start.html id="newDoc" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.put({ _id: 'mydoc', title: 'Heroes' @@ -56,7 +56,7 @@ You can update an existing doc using `_rev`: {% include code/start.html id="updateDoc" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } db.put({ @@ -72,7 +72,7 @@ {% include code/end.html %} {% include code/start.html id="updateDoc" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = await db.get('mydoc'); const response = await db.put({ @@ -88,7 +88,7 @@ {% include code/start.html id="updateDoc" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc').then(function(doc) { return db.put({ _id: 'mydoc', @@ -104,7 +104,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true, "id": "mydoc", @@ -117,7 +117,7 @@ ### Using db.post() -{% highlight "js" %} +{% highlight js %} db.post(doc, [options], [callback]) {% endhighlight %} @@ -126,7 +126,7 @@ #### Example Usage: {% include code/start.html id="post_doc" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.post({ title: 'Ziggy Stardust' }, function (err, response) { @@ -137,7 +137,7 @@ {% include code/end.html %} {% include code/start.html id="post_doc" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const response = await db.post({ title: 'Ziggy Stardust' @@ -149,7 +149,7 @@ {% include code/end.html %} {% include code/start.html id="post_doc" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.post({ title: 'Ziggy Stardust' }).then(function (response) { @@ -161,7 +161,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok" : true, "id" : "8A2C3761-FFD5-4770-9B8C-38C33CED300A", diff --git a/docs/_includes/api/create_index.html b/docs/_includes/api/create_index.html index 8c474728b9..38b26a61f4 100644 --- a/docs/_includes/api/create_index.html +++ b/docs/_includes/api/create_index.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Create index" hash="create_index" %} -{% highlight "js" %} +{% highlight js %} db.createIndex(index [, callback]) {% endhighlight %} @@ -18,7 +18,7 @@ #### Example Usage: {% include code/start.html id="create_idx" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo'] @@ -31,7 +31,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.createIndex({ index: { @@ -45,7 +45,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo'] @@ -62,20 +62,20 @@ If the index was created, you'll see: -{% highlight "js" %} +{% highlight js %} { "result": "created" } {% endhighlight %} Or if the index already exists: -{% highlight "js" %} +{% highlight js %} { "result": "exists" } {% endhighlight %} You can also create an index on multiple fields: {% include code/start.html id="create_idx2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo', 'bar', 'baz'] @@ -88,7 +88,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.createIndex({ index: { @@ -102,7 +102,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo', 'bar', 'baz'] @@ -118,7 +118,7 @@ Or an index on deep fields: {% include code/start.html id="create_idx3" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['person.address.zipcode'] @@ -131,7 +131,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.createIndex({ index: { @@ -145,7 +145,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx3" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['person.address.zipcode'] @@ -161,7 +161,7 @@ You can also specify additional options, if you want more control over how your index is created: {% include code/start.html id="create_idx4" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo', 'bar'], @@ -177,7 +177,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx4" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.createIndex({ index: { @@ -194,7 +194,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx4" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['foo', 'bar'], @@ -224,7 +224,7 @@ {% include alert/end.html%} {% include code/start.html id="create_idx5" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['year', 'title'], @@ -240,7 +240,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx5" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = db.createIndex({ index: { @@ -257,7 +257,7 @@ {% include code/end.html %} {% include code/start.html id="create_idx5" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.createIndex({ index: { fields: ['year', 'title'], @@ -283,7 +283,7 @@ When a PouchDB instance updates an index, it emits `indexing` events that include information about the progress of the index update task. -{% highlight "js" %} +{% highlight js %} const db = new PouchDB('my-docs'); db.on('indexing', function (event) { diff --git a/docs/_includes/api/database_information.html b/docs/_includes/api/database_information.html index a37926fd95..e2cb79ff5f 100644 --- a/docs/_includes/api/database_information.html +++ b/docs/_includes/api/database_information.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Get database information" hash="database_information" %} -{% highlight "js" %} +{% highlight js %} db.info([callback]) {% endhighlight %} @@ -9,7 +9,7 @@ #### Example Usage: {% include code/start.html id="dbinfo" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.info(function(err, info) { if (err) { return console.log(err); } // handle result @@ -18,7 +18,7 @@ {% include code/end.html %} {% include code/start.html id="dbinfo" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.info(); } catch (err) { @@ -28,7 +28,7 @@ {% include code/end.html %} {% include code/start.html id="dbinfo" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.info().then(function (result) { // handle result }).catch(function (err) { @@ -38,7 +38,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "db_name": "test", "doc_count": 4, diff --git a/docs/_includes/api/defaults.html b/docs/_includes/api/defaults.html index 8012d10cdd..de2b22cab5 100644 --- a/docs/_includes/api/defaults.html +++ b/docs/_includes/api/defaults.html @@ -3,7 +3,7 @@ If you find yourself using the same constructor options repeatedly, you can simplify your code with `PouchDB.defaults()`: -{% highlight "js" %} +{% highlight js %} PouchDB.defaults({ option1: 'foo', option2: 'value' @@ -13,7 +13,7 @@ The returned object is a constructor function that works the same as `PouchDB`, except that whenever you invoke it (e.g. with `new`), the given options will be passed in by default. #### Example Usage: -{% highlight "js" %} +{% highlight js %} const MyMemPouch = PouchDB.defaults({ adapter: 'memory' }); diff --git a/docs/_includes/api/delete_attachment.html b/docs/_includes/api/delete_attachment.html index bebb5c2b5f..bceff6a70c 100644 --- a/docs/_includes/api/delete_attachment.html +++ b/docs/_includes/api/delete_attachment.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Delete an attachment" hash="delete_attachment" %} -{% highlight "js" %} +{% highlight js %} db.removeAttachment(docId, attachmentId, rev, [callback]) {% endhighlight %} @@ -9,7 +9,7 @@ #### Example Usage: {% include code/start.html id="delete_att" type="callback" %} -{% highlight "js" %} +{% highlight js %} const rev = '1-068E73F5B44FEC987B51354DFC772891'; db.removeAttachment('doc', 'att.txt', rev, function(err, res) { if (err) { return console.log(err); } @@ -19,7 +19,7 @@ {% include code/end.html %} {% include code/start.html id="delete_att" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const rev = '1-068E73F5B44FEC987B51354DFC772891'; const result = await db.removeAttachment('doc', 'att.txt', rev); @@ -30,7 +30,7 @@ {% include code/end.html %} {% include code/start.html id="delete_att" type="promise" %} -{% highlight "js" %} +{% highlight js %} const rev = '1-068E73F5B44FEC987B51354DFC772891'; db.removeAttachment('doc', 'att.txt', rev).then(function (result) { // handle result @@ -42,7 +42,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true, "rev": "2-1F983211AB87EFCCC980974DFC27382F" diff --git a/docs/_includes/api/delete_database.html b/docs/_includes/api/delete_database.html index 5a6a94f0ea..69cca3cad8 100644 --- a/docs/_includes/api/delete_database.html +++ b/docs/_includes/api/delete_database.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Delete a database" hash="delete_database"%} -{% highlight "js" %} +{% highlight js %} db.destroy([options], [callback]) {% endhighlight %} @@ -9,7 +9,7 @@ #### Example Usage {% include code/start.html id="destroy_db" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.destroy(function (err, response) { if (err) { return console.log(err); @@ -22,7 +22,7 @@ {% include code/start.html id="destroy_db" type="async" %} -{% highlight "js" %} +{% highlight js %} try { await db.destroy(); } catch (err) { @@ -33,7 +33,7 @@ {% include code/start.html id="destroy_db" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.destroy().then(function (response) { // success }).catch(function (err) { @@ -43,7 +43,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok" : true } diff --git a/docs/_includes/api/delete_document.html b/docs/_includes/api/delete_document.html index 4005db0b70..c6e11c7c15 100644 --- a/docs/_includes/api/delete_document.html +++ b/docs/_includes/api/delete_document.html @@ -1,12 +1,12 @@ {% include anchor.html edit="true" title="Delete a document" hash="delete_document"%} -{% highlight "js" %} +{% highlight js %} db.remove(doc, [options], [callback]) {% endhighlight %} Or: -{% highlight "js" %} +{% highlight js %} db.remove(docId, docRev, [options], [callback]) {% endhighlight %} @@ -18,7 +18,7 @@ #### Example Usage: {% include code/start.html id="delete_doc" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } db.remove(doc, function(err, response) { @@ -30,7 +30,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = await db.get('mydoc'); const response = await db.remove(doc); @@ -41,7 +41,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc').then(function(doc) { return db.remove(doc); }).then(function (result) { @@ -54,7 +54,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true, "id": "mydoc", @@ -65,7 +65,7 @@ You can also delete a document by just providing an `id` and `rev`: {% include code/start.html id="delete_doc3" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } db.remove(doc._id, doc._rev, function(err, response) { @@ -77,7 +77,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = await db.get('mydoc'); const response = await db.remove(doc._id, doc._rev); @@ -88,7 +88,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc3" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc').then(function(doc) { return db.remove(doc._id, doc._rev); }).then(function (result) { @@ -102,7 +102,7 @@ You can also delete a document by using `put()` with `{_deleted: true}`: {% include code/start.html id="delete_doc2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } doc._deleted = true; @@ -115,7 +115,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = await db.get('mydoc'); doc._deleted = true; @@ -127,7 +127,7 @@ {% include code/end.html %} {% include code/start.html id="delete_doc2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc').then(function(doc) { doc._deleted = true; return db.put(doc); diff --git a/docs/_includes/api/delete_index.html b/docs/_includes/api/delete_index.html index b76448c80b..733bd743c1 100644 --- a/docs/_includes/api/delete_index.html +++ b/docs/_includes/api/delete_index.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Delete index" hash="delete_index" %} -{% highlight "js" %} +{% highlight js %} db.deleteIndex(index [, callback]) {% endhighlight %} @@ -19,7 +19,7 @@ #### Example Usage: {% include code/start.html id="delete_idx" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.deleteIndex({ "ddoc": "_design/idx-0f3a6f73110868266fa5c688caf8acd3", "name": "idx-0f3a6f73110868266fa5c688caf8acd3", @@ -38,7 +38,7 @@ {% include code/end.html %} {% include code/start.html id="delete_idx" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.deleteIndex({ "ddoc": "_design/idx-0f3a6f73110868266fa5c688caf8acd3", @@ -58,7 +58,7 @@ {% include code/end.html %} {% include code/start.html id="delete_idx" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.deleteIndex({ "ddoc": "_design/idx-0f3a6f73110868266fa5c688caf8acd3", "name": "idx-0f3a6f73110868266fa5c688caf8acd3", @@ -79,7 +79,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true } {% endhighlight %} @@ -88,7 +88,7 @@ one after the built-in `_all_docs` index): {% include code/start.html id="delete_idx2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.getIndexes(function (err, indexesResult) { if (err) { return console.log(err); } db.deleteIndex(indexesResult.indexes[1], function (err, result) { @@ -100,7 +100,7 @@ {% include code/end.html %} {% include code/start.html id="delete_idx2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const indexesResult = await db.getIndexes(); const result = await db.deleteIndex(indexesResult.indexes[1]); @@ -111,7 +111,7 @@ {% include code/end.html %} {% include code/start.html id="delete_idx2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.getIndexes().then(function (indexesResult) { return db.deleteIndex(indexesResult.indexes[1]); }).then(function (result) { diff --git a/docs/_includes/api/events.html b/docs/_includes/api/events.html index be755403d4..1e7563e305 100644 --- a/docs/_includes/api/events.html +++ b/docs/_includes/api/events.html @@ -2,7 +2,7 @@ PouchDB is an [event emitter][event emitter] and will emit a `'created'` event when a database is created. A `'destroyed'` event is emitted when a database is destroyed. -{% highlight "js" %} +{% highlight js %} PouchDB.on('created', function (dbName) { // called whenever a db is created. }); diff --git a/docs/_includes/api/explain_index.html b/docs/_includes/api/explain_index.html index ff40d1b818..e79cd50e2c 100644 --- a/docs/_includes/api/explain_index.html +++ b/docs/_includes/api/explain_index.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Explain index" hash="explain_index" %} -{% highlight "js" %} +{% highlight js %} db.explain(request [, callback]) {% endhighlight %} @@ -18,7 +18,7 @@ #### Example Usage: {% include code/start.html id="explain_idx" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.explain({ selector: { name: 'Mario', @@ -34,7 +34,7 @@ {% include code/end.html %} {% include code/start.html id="explain_idx" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const explanation = await db.explain({ selector: { @@ -51,7 +51,7 @@ {% include code/end.html %} {% include code/start.html id="explain_idx" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.explain({ selector: { name: 'Mario', @@ -69,7 +69,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "dbname": "database-name" "index": { diff --git a/docs/_includes/api/fetch_document.html b/docs/_includes/api/fetch_document.html index 6d14d01e1f..0897a24f09 100644 --- a/docs/_includes/api/fetch_document.html +++ b/docs/_includes/api/fetch_document.html @@ -1,7 +1,7 @@ {% include anchor.html edit="true" title="Fetch a document" hash="fetch_document"%} -{% highlight "js" %} +{% highlight js %} db.get(docId, [options], [callback]) {% endhighlight %} @@ -23,7 +23,7 @@ #### Example Usage: {% include code/start.html id="get1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc', function(err, doc) { if (err) { return console.log(err); } // handle doc @@ -32,7 +32,7 @@ {% include code/end.html %} {% include code/start.html id="get1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = await db.get('mydoc'); } catch (err) { @@ -42,7 +42,7 @@ {% include code/end.html %} {% include code/start.html id="get1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.get('mydoc').then(function (doc) { // handle doc }).catch(function (err) { @@ -52,7 +52,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "_id": "mydoc", "_rev": "1-A6157A5EA545C99B00FF904EEF05FD9F" diff --git a/docs/_includes/api/get_attachment.html b/docs/_includes/api/get_attachment.html index 1c8218a707..5578176228 100644 --- a/docs/_includes/api/get_attachment.html +++ b/docs/_includes/api/get_attachment.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Get an attachment" hash="get_attachment" %} -{% highlight "js" %} +{% highlight js %} db.getAttachment(docId, attachmentId, [options], [callback]) {% endhighlight %} @@ -15,7 +15,7 @@ Get an attachment with filename `'att.txt'` from document with ID `'doc'`: {% include code/start.html id="get_att1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.getAttachment('doc', 'att.txt', function(err, blobOrBuffer) { if (err) { return console.log(err); } // handle result @@ -24,7 +24,7 @@ {% include code/end.html %} {% include code/start.html id="get_att1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const blobOrBuffer = await db.getAttachment('doc', 'att.txt'); } catch (err) { @@ -34,7 +34,7 @@ {% include code/end.html %} {% include code/start.html id="get_att1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.getAttachment('doc', 'att.txt').then(function (blobOrBuffer) { // handle result }).catch(function (err) { @@ -47,7 +47,7 @@ the revision `'1-abcd'`: {% include code/start.html id="get_att2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.getAttachment('doc', 'att.txt', {rev: '1-abcd'}, function(err, blobOrBuffer) { if (err) { return console.log(err); } // handle result @@ -56,7 +56,7 @@ {% include code/end.html %} {% include code/start.html id="get_att2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const blobOrBuffer = await db.getAttachment('doc', 'att.txt', {rev: '1-abcd'}); } catch (err) { @@ -66,7 +66,7 @@ {% include code/end.html %} {% include code/start.html id="get_att2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.getAttachment('doc', 'att.txt', {rev: '1-abcd'}).then(function (blobOrBuffer) { // handle result }).catch(function (err) { @@ -83,7 +83,7 @@ You can specify `{attachments: true}` to most "read" operations, such as `get()`, `allDocs()`, `changes()`, and `query()`. The attachment data will then be included inlined in the resulting doc(s). However, it will always be supplied as base64. For example: -{% highlight "js" %} +{% highlight js %} { "_attachments": { "att.txt": { @@ -99,7 +99,7 @@ For such APIs, when you don't specify `{attachments: true}`, you will instead get metadata about the attachments. For example: -{% highlight "js" %} +{% highlight js %} { "_attachments": { "att.txt": { diff --git a/docs/_includes/api/list_indexes.html b/docs/_includes/api/list_indexes.html index 283195e35c..fa24c9be11 100644 --- a/docs/_includes/api/list_indexes.html +++ b/docs/_includes/api/list_indexes.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="List indexes" hash="list_indexes" %} -{% highlight "js" %} +{% highlight js %} db.getIndexes([callback]) {% endhighlight %} @@ -19,7 +19,7 @@ #### Example Usage: {% include code/start.html id="get_idxs" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.getIndexes(function (err, result) { if (err) { return console.log(err); } // handle result @@ -28,7 +28,7 @@ {% include code/end.html %} {% include code/start.html id="get_idxs" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.getIndexes(); } catch (err) { @@ -38,7 +38,7 @@ {% include code/end.html %} {% include code/start.html id="get_idxs" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.getIndexes().then(function (result) { // handle result }).catch(function (err) { @@ -49,7 +49,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "indexes": [ { diff --git a/docs/_includes/api/overview.html b/docs/_includes/api/overview.html index 04a35649cd..02df9305fd 100644 --- a/docs/_includes/api/overview.html +++ b/docs/_includes/api/overview.html @@ -5,7 +5,7 @@ Most of the API is exposed as: -{% highlight "js" %} +{% highlight js %} db.doSomething(args..., [options], [callback]) {% endhighlight %} @@ -15,7 +15,7 @@ Callbacks use the standard Node.js idiom of: -{% highlight "js" %} +{% highlight js %} function(error, result) { /* ... */ } {% endhighlight %} @@ -35,7 +35,7 @@ To use a custom promise implementation with PouchDB, you must redefine a global `Promise` object before loading PouchDB: -{% highlight "html" %} +{% highlight html %} {% endhighlight %} @@ -46,7 +46,7 @@ Note that the samples for `async`/`await` in the API documentation assume that your code is inside an async function. So for instance: -{% highlight "js" %} +{% highlight js %} async function myFunction() { // your code goes in here } diff --git a/docs/_includes/api/plugins.html b/docs/_includes/api/plugins.html index 890db8ac51..06b29c1113 100644 --- a/docs/_includes/api/plugins.html +++ b/docs/_includes/api/plugins.html @@ -12,7 +12,7 @@ Writing a plugin is easy! The API is: -{% highlight "js" %} +{% highlight js %} PouchDB.plugin({ methodName: myFunction }); @@ -23,7 +23,7 @@ There is a [PouchDB Plugin Seed project](https://github.com/pouchdb/plugin-seed), which is the fastest way to get started writing, building and testing your very own plugin. #### Example Usage: -{% highlight "js" %} +{% highlight js %} PouchDB.plugin({ sayHello : function () { console.log("Hello!"); @@ -38,7 +38,7 @@ or attach event listeners to the `PouchDB` object. #### Example Usage: -{% highlight "js" %} +{% highlight js %} PouchDB.plugin(function (PouchDB) { PouchDB.hello = 'world'; }); @@ -53,7 +53,7 @@ You can load plugins into PouchDB when you load it via `require()`. -{% highlight "js" %} +{% highlight js %} const greet = {sayHello: function() { console.log("Hello!"); }}; const PouchDB = require('pouchdb').plugin(greet); @@ -64,7 +64,7 @@ You can chain plugins, as well: -{% highlight "js" %} +{% highlight js %} const greet = {sayHello: function() { console.log("Hello!"); }}; const manners = {thank: function(name) { console.log("Thank you, " + name); }}; @@ -85,7 +85,7 @@ Because PouchDB guarantees to plugin authors that all data changes ultimately happen via `bulkDocs()`, it is the ideal place for an application or plugin to intercept updates. -{% highlight "js" %} +{% highlight js %} // Keep a reference to the "upstream" function. const pouchBulkDocs = PouchDB.prototype.bulkDocs; PouchDB.plugin({bulkDocs: validBulkDocs}); diff --git a/docs/_includes/api/purge.html b/docs/_includes/api/purge.html index 27b7aeb270..54374a8026 100644 --- a/docs/_includes/api/purge.html +++ b/docs/_includes/api/purge.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Purge a document rev" hash="purge" %} -{% highlight "js" %} +{% highlight js %} db.purge(docId, rev) {% endhighlight %} @@ -23,7 +23,7 @@ #### Example Usage: {% include code/start.html id="purge1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.purge('mydoc', '6-3a24009a9525bde9e4bfa8a99046b00d', function (err, result) { if (err) { return console.log(err); } @@ -33,7 +33,7 @@ {% include code/end.html %} {% include code/start.html id="purge1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.purge('mydoc', '6-3a24009a9525bde9e4bfa8a99046b00d'); // handle result @@ -44,7 +44,7 @@ {% include code/end.html %} {% include code/start.html id="purge1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.purge('mydoc', '6-3a24009a9525bde9e4bfa8a99046b00d') .then(function (result) { // handle result @@ -56,7 +56,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true, "deletedRevs": [ diff --git a/docs/_includes/api/query_database.html b/docs/_includes/api/query_database.html index 0895330a56..073ce32fe0 100644 --- a/docs/_includes/api/query_database.html +++ b/docs/_includes/api/query_database.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Map/reduce queries" hash="query_database" %} -{% highlight "js" %} +{% highlight js %} db.query(fun, [options], [callback]) {% endhighlight %} @@ -62,7 +62,7 @@ #### Example Usage: {% include code/start.html id="query1" type="callback" %} -{% highlight "js" %} +{% highlight js %} // create a design doc const ddoc = { _id: '_design/index', @@ -96,7 +96,7 @@ {% include code/end.html %} {% include code/start.html id="query1" type="async" %} -{% highlight "js" %} +{% highlight js %} // create a design doc const ddoc = { _id: '_design/index', @@ -133,7 +133,7 @@ {% include code/end.html %} {% include code/start.html id="query1" type="promise" %} -{% highlight "js" %} +{% highlight js %} // create a design doc const ddoc = { _id: '_design/index', @@ -169,7 +169,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "offset" : 0, "rows": [{ @@ -197,7 +197,7 @@ You can also use [complex keys](https://docs.couchdb.org/en/stable/ddocs/views/collation.html#complex-keys) for fancy ordering: {% include code/start.html id="query2" type="callback" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // sort by last name, first name, and age emit([doc.lastName, doc.firstName, doc.age]); @@ -210,7 +210,7 @@ {% include code/end.html %} {% include code/start.html id="query2" type="async" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // sort by last name, first name, and age emit([doc.lastName, doc.firstName, doc.age]); @@ -224,7 +224,7 @@ {% include code/end.html %} {% include code/start.html id="query2" type="promise" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // sort by last name, first name, and age emit([doc.lastName, doc.firstName, doc.age]); @@ -238,7 +238,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "offset": 0, "rows": [{ @@ -271,7 +271,7 @@ PouchDB fully supports [linked documents](https://docs.couchdb.org/en/stable/ddocs/views/joins.html?highlight=linked%20documents#linked-documents). Use them to join two types of documents together, by simply adding an `_id` to the emitted value: {% include code/start.html id="query3" type="callback" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // join artist data to albums if (doc.type === 'album') { @@ -286,7 +286,7 @@ {% include code/end.html %} {% include code/start.html id="query3" type="async" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // join artist data to albums if (doc.type === 'album') { @@ -302,7 +302,7 @@ {% include code/end.html %} {% include code/start.html id="query3" type="promise" %} -{% highlight "js" %} +{% highlight js %} function map(doc) { // join artist data to albums if (doc.type === 'album') { @@ -319,7 +319,7 @@ #### Example response: -{% highlight "js" %} +{% highlight js %} { "offset": 0, "rows": [ @@ -378,7 +378,7 @@ If you pass a function to `db.query` and give it the `emit` function as the second argument, then you can use a closure. (Since PouchDB has to use `eval()` to bind `emit`.) {% include code/start.html id="query4" type="callback" %} -{% highlight "js" %} +{% highlight js %} // BAD! will throw error const myId = 'foo'; db.query(function(doc) { @@ -403,7 +403,7 @@ {% include code/end.html %} {% include code/start.html id="query4" type="async" %} -{% highlight "js" %} +{% highlight js %} // BAD! will throw error const myId = 'foo'; try { @@ -431,7 +431,7 @@ {% include code/end.html %} {% include code/start.html id="query4" type="promise" %} -{% highlight "js" %} +{% highlight js %} // BAD! will throw error const myId = 'foo'; db.query(function(doc) { diff --git a/docs/_includes/api/query_index.html b/docs/_includes/api/query_index.html index 3ee32da6b7..7ea7ca8b8a 100644 --- a/docs/_includes/api/query_index.html +++ b/docs/_includes/api/query_index.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Query index" hash="query_index" %} -{% highlight "js" %} +{% highlight js %} db.find(request [, callback]) {% endhighlight %} @@ -18,7 +18,7 @@ #### Example Usage: {% include code/start.html id="query_idx" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: 'Mario'}, fields: ['_id', 'name'], @@ -31,7 +31,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: {name: 'Mario'}, @@ -45,7 +45,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: 'Mario'}, fields: ['_id', 'name'], @@ -60,7 +60,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "docs": [ { @@ -104,7 +104,7 @@ If there's no index that matches your `selector`/`sort`, then this method will issue a warning: -{% highlight "js" %} +{% highlight js %} { "docs": [ /* ... */ ], "warning": "No matching index found, create an index to optimize query time." @@ -121,7 +121,7 @@ Use `$eq` for "equals": {% include code/start.html id="query_idx2" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: {$eq: 'Mario'}} }, function (err, result) { @@ -132,7 +132,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: {name: {$eq: 'Mario'}} @@ -144,7 +144,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx2" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: {$eq: 'Mario'}} }).then(function (result) { @@ -158,7 +158,7 @@ This is equivalent to: {% include code/start.html id="query_idx3" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: 'Mario'} }, function (err, result) { @@ -169,7 +169,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: {name: 'Mario'} @@ -181,7 +181,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx3" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: {name: 'Mario'} }).then(function (result) { @@ -196,7 +196,7 @@ find all docs where `series` is `'Mario'` and `debut` is greater than `1990`: {% include code/start.html id="query_idx4" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { series: 'Mario', @@ -210,7 +210,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx4" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: { @@ -225,7 +225,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx4" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { series: 'Mario', @@ -242,7 +242,7 @@ This is equivalent to: {% include code/start.html id="query_idx5" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { $and: [ @@ -258,7 +258,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx5" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: { @@ -275,7 +275,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx5" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { $and: [ @@ -294,7 +294,7 @@ You can also sort the returned documents. For instance, to find all docs sorted by `debut` descending: {% include code/start.html id="query_idx6" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { debut: {'$gte': null} @@ -308,7 +308,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx6" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.find({ selector: { @@ -323,7 +323,7 @@ {% include code/end.html %} {% include code/start.html id="query_idx6" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.find({ selector: { debut: {'$gte': null} diff --git a/docs/_includes/api/replication.html b/docs/_includes/api/replication.html index 4beea78eb9..7ee4284e07 100644 --- a/docs/_includes/api/replication.html +++ b/docs/_includes/api/replication.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Replicate a database" hash="replication" %} -{% highlight "js" %} +{% highlight js %} PouchDB.replicate(source, target, [options]) {% endhighlight %} @@ -36,7 +36,7 @@ #### Example Usage: -{% highlight "js" %} +{% highlight js %} const rep = PouchDB.replicate('mydb', 'http://localhost:5984/mydb', { live: true, retry: true @@ -59,7 +59,7 @@ There are also shorthands for replication given existing PouchDB objects. These behave the same as `PouchDB.replicate()`: -{% highlight "js" %} +{% highlight js %} db.replicate.to(remoteDB, [options]); // or db.replicate.from(remoteDB, [options]); @@ -82,7 +82,7 @@ As with [changes()](#changes), you can also omit `live`, in which case you can use `replicate()` in the callback/promise style and it will be treated as a single-shot operation. {% include code/start.html id="replication1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.replicate.to(remote, function (err, result) { if (err) { return console.log(err); } // handle 'completed' result @@ -91,7 +91,7 @@ {% include code/end.html %} {% include code/start.html id="replication1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.replicate.to(remote); } catch (err) { @@ -101,7 +101,7 @@ {% include code/end.html %} {% include code/start.html id="replication1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.replicate.to(remote).then(function (result) { // handle 'completed' result }).catch(function (err) { @@ -116,7 +116,7 @@ Example response in the `'change'` listener: -{% highlight "js" %} +{% highlight js %} { "doc_write_failures": 0, "docs_read": 1, @@ -135,7 +135,7 @@ Example response in the `'complete'` listener: -{% highlight "js" %} +{% highlight js %} { "doc_write_failures": 0, "docs_read": 2, @@ -181,7 +181,7 @@ In these examples, we'll work with some mammals. Let's imagine our docs are: -{% highlight "js" %} +{% highlight js %} [ {_id: 'a', name: 'Kangaroo', type: 'marsupial'}, {_id: 'b', name: 'Koala', type: 'marsupial'}, @@ -197,7 +197,7 @@ Filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} remote.replicate.to(local, { filter: function (doc) { return doc.type === 'marsupial'; @@ -209,7 +209,7 @@ Filter documents with `_id`s `['a', 'c']`. -{% highlight "js" %} +{% highlight js %} remote.replicate.to(local, { doc_ids: ['a', 'c'] }); @@ -219,7 +219,7 @@ First `put()` a design document in the remote database: -{% highlight "js" %} +{% highlight js %} { _id: '_design/mydesign', filters: { @@ -232,7 +232,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} remote.replicate.to(local, { filter: 'mydesign/myfilter' }); @@ -244,7 +244,7 @@ First `put()` a design document in the remote database: -{% highlight "js" %} +{% highlight js %} { _id: '_design/mydesign', filters: { @@ -257,7 +257,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} remote.replicate.to(local, { filter: 'mydesign/myfilter', query_params: {type: 'marsupial'} @@ -272,7 +272,7 @@ First `put()` a design document in the remote database: -{% highlight "js" %} +{% highlight js %} { _id: '_design/mydesign', views: { @@ -289,7 +289,7 @@ Then filter by `type === 'marsupial'`: -{% highlight "js" %} +{% highlight js %} remote.replicate.to(local, { filter: '_view', view: 'mydesign/myview' @@ -302,7 +302,7 @@ Here's a simple backoff function that starts at 1000 milliseconds and triples it every time a remote request fails: -{% highlight "js" %} +{% highlight js %} db.replicate.to(remote, { live: true, diff --git a/docs/_includes/api/revisions_diff.html b/docs/_includes/api/revisions_diff.html index 61a649a55e..9bd6c45607 100644 --- a/docs/_includes/api/revisions_diff.html +++ b/docs/_includes/api/revisions_diff.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Document revisions diff" hash="revisions_diff" %} -{% highlight "js" %} +{% highlight js %} db.revsDiff(diff, [callback]) {% endhighlight %} @@ -10,7 +10,7 @@ #### Example Usage: {% include code/start.html id="revsdiff1" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.revsDiff({ myDoc1: [ "1-b2e54331db828310f3c772d6e042ac9c", @@ -24,7 +24,7 @@ {% include code/end.html %} {% include code/start.html id="revsdiff1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.revsDiff({ myDoc1: [ @@ -39,7 +39,7 @@ {% include code/end.html %} {% include code/start.html id="revsdiff1" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.revsDiff({ myDoc1: [ "1-b2e54331db828310f3c772d6e042ac9c", @@ -54,7 +54,7 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "myDoc1": { "missing": ["2-3a24009a9525bde9e4bfa8a99046b00d"] diff --git a/docs/_includes/api/save_attachment.html b/docs/_includes/api/save_attachment.html index 4cba436a3f..3f2ac38207 100644 --- a/docs/_includes/api/save_attachment.html +++ b/docs/_includes/api/save_attachment.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Save an attachment" hash="save_attachment" %} -{% highlight "js" %} +{% highlight js %} db.putAttachment(docId, attachmentId, [rev], attachment, type, [callback]); {% endhighlight %} @@ -15,7 +15,7 @@ #### Example Usage: {% include code/start.html id="attach1" type="callback" %} -{% highlight "js" %} +{% highlight js %} const attachment = new Blob(['Is there life on Mars?'], {type: 'text/plain'}); db.putAttachment('doc', 'att.txt', attachment, 'text/plain', function(err, res) { if (err) { return console.log(err); } @@ -25,7 +25,7 @@ {% include code/end.html %} {% include code/start.html id="attach1" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const attachment = new Blob(['Is there life on Mars?'], {type: 'text/plain'}); const result = await db.putAttachment('doc', 'att.txt', attachment, 'text/plain'); @@ -36,7 +36,7 @@ {% include code/end.html %} {% include code/start.html id="attach1" type="promise" %} -{% highlight "js" %} +{% highlight js %} const attachment = new Blob(['Is there life on Mars?'], {type: 'text/plain'}); db.putAttachment('doc', 'att.txt', attachment, 'text/plain').then(function (result) { // handle result @@ -48,7 +48,7 @@ #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok": true, "id": "doc", @@ -58,7 +58,7 @@ Within Node, you must use a `Buffer` instead of a `Blob`: -{% highlight "js" %} +{% highlight js %} const attachment = new Buffer('Is there life on Mars?'); {% endhighlight %} @@ -71,7 +71,7 @@ If you supply a string instead of a `Blob`/`Buffer`, then it will be assumed to be a base64-encoded string, and will be processed accordingly: {% include code/start.html id="attach3" type="callback" %} -{% highlight "js" %} +{% highlight js %} const attachment = "TGVnZW5kYXJ5IGhlYXJ0cywgdGVhciB1cyBhbGwgYXBhcnQKTWFrZS" + "BvdXIgZW1vdGlvbnMgYmxlZWQsIGNyeWluZyBvdXQgaW4gbmVlZA=="; @@ -83,7 +83,7 @@ {% include code/end.html %} {% include code/start.html id="attach3" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const attachment = "TGVnZW5kYXJ5IGhlYXJ0cywgdGVhciB1cyBhbGwgYXBhcnQKTWFrZS" + @@ -96,7 +96,7 @@ {% include code/end.html %} {% include code/start.html id="attach3" type="promise" %} -{% highlight "js" %} +{% highlight js %} const attachment = "TGVnZW5kYXJ5IGhlYXJ0cywgdGVhciB1cyBhbGwgYXBhcnQKTWFrZS" + "BvdXIgZW1vdGlvbnMgYmxlZWQsIGNyeWluZyBvdXQgaW4gbmVlZA=="; @@ -114,7 +114,7 @@ You can also inline attachments inside the document. The attachment data may be supplied as a base64-encoded string with the `content_type`: {% include code/start.html id="attach2" type="callback" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", @@ -134,7 +134,7 @@ {% include code/end.html %} {% include code/start.html id="attach2" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = { "_id": "doc", @@ -155,7 +155,7 @@ {% include code/end.html %} {% include code/start.html id="attach2" type="promise" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", @@ -180,7 +180,7 @@ You can also inline `Blob`s/`Buffer`s: {% include code/start.html id="attach4" type="callback" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", @@ -199,7 +199,7 @@ {% include code/end.html %} {% include code/start.html id="attach4" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = { "_id": "doc", @@ -219,7 +219,7 @@ {% include code/end.html %} {% include code/start.html id="attach4" type="promise" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", @@ -243,7 +243,7 @@ The inline approach allows you to save multiple attachments to the same document in a single shot: {% include code/start.html id="attach5" type="callback" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", @@ -276,7 +276,7 @@ {% include code/end.html %} {% include code/start.html id="attach5" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const doc = { "_id": "doc", @@ -310,7 +310,7 @@ {% include code/end.html %} {% include code/start.html id="attach5" type="promise" %} -{% highlight "js" %} +{% highlight js %} const doc = { "_id": "doc", "title": "Legendary Hearts", diff --git a/docs/_includes/api/sync.html b/docs/_includes/api/sync.html index 83b8586071..eb75ed15b7 100644 --- a/docs/_includes/api/sync.html +++ b/docs/_includes/api/sync.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="Sync a database" hash="sync" %} -{% highlight "js" %} +{% highlight js %} const sync = PouchDB.sync(src, target, [options]) {% endhighlight %} @@ -8,7 +8,7 @@ In other words, this code: -{% highlight "js" %} +{% highlight js %} PouchDB.replicate('mydb', 'http://localhost:5984/mydb'); PouchDB.replicate('http://localhost:5984/mydb', 'mydb'); {% endhighlight %} @@ -16,7 +16,7 @@ is equivalent to this code: -{% highlight "js" %} +{% highlight js %} PouchDB.sync('mydb', 'http://localhost:5984/mydb'); {% endhighlight %} @@ -28,7 +28,7 @@ Replication options such as `filter` passed to sync directly will be passed to both replications. Please refer to [replicate()](api.html#replication) for documentation on those options. #### Example Usage: -{% highlight "js" %} +{% highlight js %} const sync = PouchDB.sync('mydb', 'http://localhost:5984/mydb', { live: true, retry: true @@ -51,14 +51,14 @@ There is also a shorthand for syncing given existing PouchDB objects. This behaves the same as `PouchDB.sync()`: -{% highlight "js" %} +{% highlight js %} db.sync(remoteDB, [options]); {% endhighlight %} It is also possible to combine "one-way" replication and sync for performance reasons. When your PouchDB application starts up it could perform a one-off, one-way replication to completion and then initiate the two-way, continuous retryable sync: -{% highlight "js" %} +{% highlight js %} const url = 'http://localhost:5984/mydb'; const opts = { live: true, retry: true }; @@ -78,7 +78,7 @@ Change events in `sync` have an extra property `direction` which refers to the direction the change was going. Its value will either be `push` or `pull`. -{% highlight "js" %} +{% highlight js %} { direction: 'push', change: { ok: true, diff --git a/docs/_includes/api/view_cleanup.html b/docs/_includes/api/view_cleanup.html index 8ff0c66d23..4df285312d 100644 --- a/docs/_includes/api/view_cleanup.html +++ b/docs/_includes/api/view_cleanup.html @@ -1,6 +1,6 @@ {% include anchor.html edit="true" title="View cleanup" hash="view_cleanup" %} -{% highlight "js" %} +{% highlight js %} db.viewCleanup([callback]) {% endhighlight %} @@ -13,7 +13,7 @@ #### Example Usage: {% include code/start.html id="viewcleanup" type="callback" %} -{% highlight "js" %} +{% highlight js %} db.viewCleanup(function (err, result) { if (err) { return console.log(err); } // handle result @@ -22,7 +22,7 @@ {% include code/end.html %} {% include code/start.html id="viewcleanup" type="async" %} -{% highlight "js" %} +{% highlight js %} try { const result = await db.viewCleanup(); } catch (err) { @@ -32,7 +32,7 @@ {% include code/end.html %} {% include code/start.html id="viewcleanup" type="promise" %} -{% highlight "js" %} +{% highlight js %} db.viewCleanup().then(function (result) { // handle result }).catch(function (err) { @@ -42,6 +42,6 @@ {% include code/end.html %} #### Example Response: -{% highlight "js" %} +{% highlight js %} { "ok" : "true" } {% endhighlight %} \ No newline at end of file diff --git a/docs/download.md b/docs/download.md index e8d5264826..1663ce0d4a 100644 --- a/docs/download.md +++ b/docs/download.md @@ -6,7 +6,7 @@ sidebar: nav.html {% include anchor.html class="h3" title="Quick Start" hash="file" %} -{% highlight "html" %} +{% highlight html %} @@ -52,7 +52,7 @@ PouchDB is now installed in your app and ready to use! (In production, you shoul The rest of the work will be done inside `app.js`. We will start by creating a database to enter your todos. To create a database simply instantiate a new PouchDB object with the name of the database: -{% highlight "js" %} +{% highlight js %} // EDITING STARTS HERE (you don't need to edit anything above this line) const db = new PouchDB('todos'); @@ -65,7 +65,7 @@ You don't need to create a schema for the database. After giving it a name, you The first thing we shall do is start writing items to the database. The main input will call `addTodo` with the current text when the user presses `Enter`. We can complete this function with the following code: -{% highlight "js" %} +{% highlight js %} function addTodo(text) { const todo = { _id: new Date().toISOString(), @@ -88,7 +88,7 @@ The `callback` function will be called once the document has been written (or fa We have included a helper function `redrawTodosUI` that takes an array of todos to display, so all we need to do is read the todos from the database. Here we will simply read all the documents using `db.allDocs`. The `include_docs` option tells PouchDB to give us the data within each document, and the `descending` option tells PouchDB how to order the results based on their `_id` field, giving us newest first. -{% highlight "js" %} +{% highlight js %} function showTodos() { db.allDocs({include_docs: true, descending: true}, function(err, doc) { redrawTodosUI(doc.rows); @@ -102,7 +102,7 @@ Once you have included this code, you should be able to refresh the page to see We don't want to refresh the page to see new items. More typically you would update the UI manually when you write data to it, however, in PouchDB you may be syncing data remotely, so you want to make sure you update whenever the remote data changes. To do this we will call `db.changes` which subscribes to updates to the database, wherever they come from. You can enter this code between the `remoteCouch` and `addTodo` declaration: -{% highlight "js" %} +{% highlight js %} const remoteCouch = false; db.changes({ @@ -120,7 +120,7 @@ So every time an update happens to the database, we redraw the UI to show the ne When the user checks a checkbox, the `checkboxChanged` function will be called, so we'll fill in the code to edit the object and call `db.put`: -{% highlight "js" %} +{% highlight js %} function checkboxChanged(todo, event) { todo.completed = event.target.checked; db.put(todo); @@ -135,7 +135,7 @@ You can test that this works by checking a todo item and refreshing the page. It To delete an object you can call db.remove with the object. -{% highlight "js" %} +{% highlight js %} function deleteButtonPressed(todo) { db.remove(todo); } @@ -147,7 +147,7 @@ Similar to editing a document, both the `_id` and `_rev` properties are required `todoBlurred` is called when the user edits a document. Here we'll delete the document if the user has entered a blank title, and we'll update it otherwise. -{% highlight "js" %} +{% highlight js %} function todoBlurred(todo, event) { const trimmedText = event.target.value.trim(); if (!trimmedText) { @@ -169,14 +169,14 @@ To replicate directly with CouchDB, you need to make sure CORS is enabled. Only You can enable CORS in CouchDB using `curl` or the Futon web interface, but we've saved you some time by making a Node script called [add-cors-to-couchdb](https://github.com/pouchdb/add-cors-to-couchdb). Just run: -{% highlight "bash" %} +{% highlight bash %} $ npm install -g add-cors-to-couchdb $ add-cors-to-couchdb {% endhighlight %} Or if your database is not at `127.0.0.1:5984`: -{% highlight "bash" %} +{% highlight bash %} $ add-cors-to-couchdb http://me.example.com -u myusername -p mypassword {% endhighlight %} @@ -188,7 +188,7 @@ You can check that CORS is now enabled by visiting [http://localhost:5984/_utils Now we will have the todo list sync. Back in `app.js` we need to specify the address of the remote database. Remember to replace `user`, `pass` and `myname.example.com` with the credentials of your own CouchDB instance: -{% highlight "js" %} +{% highlight js %} // EDITING STARTS HERE (you don't need to edit anything above this line) const db = new PouchDB('todos'); @@ -197,7 +197,7 @@ const remoteCouch = 'http://user:pass@myname.example.com/todos'; Then we can implement the sync function like so: -{% highlight "js" %} +{% highlight js %} function sync() { syncDom.setAttribute('data-sync-state', 'syncing'); const opts = {live: true}; diff --git a/docs/index.md b/docs/index.md index fab1ae7749..00ca03567d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,7 +14,7 @@ title: PouchDB, the JavaScript Database that Syncs!
-{% highlight "js" %} +{% highlight js %} const db = new PouchDB('dbname'); db.put({ diff --git a/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md b/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md index eb923d7782..cd718fda74 100644 --- a/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md +++ b/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md @@ -13,7 +13,7 @@ We can't really help it. PouchDB is an abstraction over IndexedDB, WebSQL, Level When I think of elegant database APIs, however, I'm still struck by the simplicity of LocalStorage: -{% highlight "js" %} +{% highlight js %} if (!localStorage.foo) { localStorage.foo = 'bar'; }; @@ -30,7 +30,7 @@ For PouchDB, we can try to mitigate the complexity of asynchronous APIs with pro However, promisey code is still hard to read, because promises are basically a bolt-on replacement for language primitives like `try`, `catch`, and `return`: -{% highlight "js" %} +{% highlight js %} var db = new PouchDB('mydb'); db.post({}).then(function (result) { // post a new doc return db.get(result.id); // fetch the doc @@ -49,7 +49,7 @@ Until recently, this was the best we could hope for. But all of that changes wit What if I told you that, with ES7, you could rewrite the above code to look like this: -{% highlight "js" %} +{% highlight js %} let db = new PouchDB('mydb'); try { let result = await db.post({}); @@ -72,7 +72,7 @@ First, let's take a look at how ES7 is accomplishing this amazing feat. ES7 gives us a new kind of function, the `async function`. Inside of an `async function`, we have a new keyword, `await`, which we use to "wait for" a promise: -{% highlight "js" %} +{% highlight js %} async function myFunction() { let result = await somethingThatReturnsAPromise(); console.log(result); // cool, we have a result @@ -82,7 +82,7 @@ async function myFunction() { If the promise resolves, we can immediately interact with it on the next line. And if it rejects, then an error is thrown. So `try`/`catch` actually works again! -{% highlight "js" %} +{% highlight js %} async function myFunction() { try { await somethingThatReturnsAPromise(); @@ -104,7 +104,7 @@ First, consider a common idiom in PouchDB: we want to `get()` a document by `_id With promises, you'd have to write something like this: -{% highlight "js" %} +{% highlight js %} db.get('docid').catch(function (err) { if (err.name === 'not_found') { return {}; // new doc @@ -117,7 +117,7 @@ db.get('docid').catch(function (err) { With async functions, this becomes: -{% highlight "js" %} +{% highlight js %} let doc; try { doc = await db.get('docid'); @@ -143,7 +143,7 @@ Another, more insidious problem is that you have to be careful to wrap your code My advice is to ensure that your async functions are entirely surrounded by `try`/`catch`es, at least at the top level: -{% highlight "js" %} +{% highlight js %} async function createNewDoc() { let response = await db.post({}); // post a new doc return await db.get(response.id); // find by id @@ -165,7 +165,7 @@ Async functions get really impressive when it comes to iteration. For instance, Using standard ES6 promises, we'd have to roll our own promise chain: -{% highlight "js" %} +{% highlight js %} var promise = Promise.resolve(); var docs = [{}, {}, {}]; @@ -182,7 +182,7 @@ promise.then(function () { This works, but it sure is ugly. It's also error-prone, because if you accidentally do: -{% highlight "js" %} +{% highlight js %} docs.forEach(function (doc) { promise = promise.then(db.post(doc)); }); @@ -192,7 +192,7 @@ Then the promises will actually execute *concurrently*, which can lead to unexpe With ES7, though, we can just use a regular for-loop: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; for (let i = 0; i < docs.length; i++) { @@ -203,7 +203,7 @@ for (let i = 0; i < docs.length; i++) { This (very concise) code does the same thing as the promise chain! We can make it even shorter by using `for...of`: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; for (let doc of docs) { @@ -213,7 +213,7 @@ for (let doc of docs) { Note that you cannot use a `forEach()` loop here. If you were to naïvely write: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; // WARNING: this won't work @@ -234,7 +234,7 @@ This is because you cannot use `await` from within a normal function. You have t However, if you try to use an async function, then you will get a more subtle bug: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; // WARNING: this won't work @@ -264,7 +264,7 @@ If we do want to execute multiple promises concurrently, though, then this is pr Recall that with ES6 promises, we have `Promise.all()`. Let's use it to return an array of values from an array of promises: -{% highlight "js" %} +{% highlight js %} var docs = [{}, {}, {}]; return Promise.all(docs.map(function (doc) { @@ -276,7 +276,7 @@ return Promise.all(docs.map(function (doc) { In ES7, we can do this is a more straightforward way: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; let promises = docs.map((doc) => db.post(doc)); @@ -289,7 +289,7 @@ console.log(results); The most important parts are 1) creating the `promises` array, which starts invoking all the promises immediately, and 2) that we are `await`ing those promises within the main function. If we tried to use `Array.prototype.map`, then it wouldn't work: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; let promises = docs.map((doc) => db.post(doc)); @@ -306,7 +306,7 @@ The reason this doesn't work is because we are `await`ing inside of the sub-func If you don't mind using `Promise.all`, you can also use it to tidy up the code a bit: -{% highlight "js" %} +{% highlight js %} let docs = [{}, {}, {}]; let promises = docs.map((doc) => db.post(doc)); diff --git a/docs/posts/2015-04-05-filtered-replication.md b/docs/posts/2015-04-05-filtered-replication.md index 946093acd8..87548ccff7 100644 --- a/docs/posts/2015-04-05-filtered-replication.md +++ b/docs/posts/2015-04-05-filtered-replication.md @@ -31,7 +31,7 @@ To reproduce the examples you’ll need PouchDB v3.4.0, which contains some bugf The first step in implementing your server-side filtering solution is to create the design document. This is an example: -{% highlight "js" %} +{% highlight js %} { "_id": "_design/app", "filters": { @@ -61,7 +61,7 @@ We'll come back to this design document later. Now it's time to implement our cl * `filter`: can take either the string corresponding to the filter function (see example below), or a JS function (for client-side filtering). * `query_params`: takes a JS object. This object is what we find in the `req.query` object inside the design document function. Just what we need! -{% highlight "js" %} +{% highlight js %} localDB.sync(remoteDB, { live: true, retry: true, @@ -96,7 +96,7 @@ In PouchDB, this corresponds to `put()`ing a document with `_deleted: true`, rat The next gotcha deserves a bit more space. I find it very counter-intuitive, and my guess is that you'll feel the same. Since you're interested in two-way replication, you want the client to not only read data, but write data as well. What you expect is that saves on the local database will get replicated to the remote database. Let's look at some code: -{% highlight "js" %} +{% highlight js %} this.save = function (foobar) { return localDB.get(foobar._id).then(function (doc) { doc.someNiceField = foobar.someNiceField; @@ -109,7 +109,7 @@ In ORM parlance, this is a "connected scenario" update. You retrieve the documen If you followed this post step-by-step, however, this won't work. Why? To make two-way filtered replication work, the design document needs to be in both the remote database and the local database. To do this, we might decide to simply replicate the design document alongside the other documents. Hence our design document becomes: -{% highlight "js" %} +{% highlight js %} { "_id": "_design/app", "filters": { From e1570e5016bfd5bcba0ce65a51a37e9421487ba2 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 11:13:47 +0200 Subject: [PATCH 04/17] chore: move layouts to _includes, explicitly set layout file types, move 11ty config file to root --- docs/{_layouts => _includes}/2ColLeft.html | 2 +- docs/_includes/anchor.html | 2 +- docs/{_layouts => _includes}/default.html | 3 ++- docs/{_layouts => _includes}/guide.html | 4 ++-- docs/{_layouts => _includes}/post.html | 2 +- docs/adapters.md | 2 +- docs/api.html | 2 +- docs/blog/index.html | 2 +- docs/custom.md | 2 +- docs/download.md | 2 +- docs/errors.md | 2 +- docs/external.md | 2 +- docs/faq.md | 2 +- docs/getting-started.md | 2 +- docs/guides/async-code.md | 2 +- docs/guides/attachments.md | 2 +- docs/guides/bulk-operations.md | 2 +- docs/guides/changes.md | 2 +- docs/guides/compact-and-destroy.md | 2 +- docs/guides/conflicts.md | 2 +- docs/guides/databases.md | 2 +- docs/guides/documents.md | 2 +- docs/guides/index.md | 2 +- docs/guides/local-documents.md | 2 +- docs/guides/mango-queries.md | 2 +- docs/guides/queries.md | 2 +- docs/guides/replication.md | 2 +- docs/guides/setup-couchdb.md | 2 +- docs/guides/setup-pouchdb.md | 2 +- docs/guides/updating-deleting.md | 2 +- docs/index.md | 2 +- docs/learn.md | 2 +- docs/offline.md | 2 +- docs/posts/2014-04-01-pouchdb-2.1.0.md | 2 +- docs/posts/2014-04-01-welcome-to-the-pouchdb-blog.md | 2 +- .../posts/2014-04-14-pagination-strategies-with-pouchdb.md | 2 +- docs/posts/2014-05-01-pouchdb-2.2.0.md | 2 +- .../2014-05-01-secondary-indexes-have-landed-in-pouchdb.md | 2 +- docs/posts/2014-06-01-pouchdb-2.2.3.md | 2 +- .../2014-06-17-12-pro-tips-for-better-code-with-pouchdb.md | 2 +- docs/posts/2014-07-25-pouchdb-levels-up.md | 2 +- docs/posts/2014-08-12-pouchdb-3.0.0.md | 2 +- docs/posts/2014-08-16-pouchdb-3.0.1.md | 2 +- docs/posts/2014-08-20-pouchdb-3.0.2.md | 2 +- docs/posts/2014-08-29-pouchdb-3.0.3.md | 2 +- docs/posts/2014-09-04-pouchdb-3.0.4.md | 2 +- docs/posts/2014-09-07-pouchdb-3.0.5.md | 2 +- docs/posts/2014-09-22-3.0.6.md | 2 +- ...-learned-from-reading-and-writing-the-pouchdb-source.md | 2 +- docs/posts/2014-11-10-3.1.0.md | 2 +- docs/posts/2014-11-27-testing-pouchdb.md | 2 +- docs/posts/2014-12-04-3.2.0.md | 2 +- docs/posts/2014-12-11-the-pains-of-being-async-at-heart.md | 2 +- .../2015-01-05-pouchdb-3.2.1-you-can-always-be-faster.md | 2 +- docs/posts/2015-02-03-fix-up-look-sharp.md | 2 +- docs/posts/2015-02-14-a-quick-one.md | 2 +- .../2015-02-28-efficiently-managing-ui-state-in-pouchdb.md | 2 +- docs/posts/2015-03-05-taming-the-async-beast-with-es7.md | 2 +- docs/posts/2015-04-05-filtered-replication.md | 2 +- docs/posts/2015-04-07-better-late-than-never.md | 2 +- docs/posts/2015-05-07-pouchdb-3.5.0-vote-for-pouchdb.md | 2 +- docs/posts/2015-05-18-we-have-a-problem-with-promises.md | 2 +- docs/posts/2015-06-01-pouchdb-3.6.0.md | 2 +- docs/posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md | 2 +- docs/posts/2015-09-01-pouchdb-4.0.1-gotta-go-fast.md | 2 +- docs/posts/2015-09-12-pouchdb-4.0.2-a-little-extra.md | 2 +- .../2015-10-06-pouchdb-5.0.0-five-years-of-pouchdb.md | 2 +- docs/posts/2015-11-03-cover-all.md | 2 +- ...1-13-pouchdb-5.2.0-a-better-build-system-with-rollup.md | 2 +- .../2016-03-04-pouchdb-5.3.0-sqlite-support-in-node.md | 2 +- docs/posts/2016-04-28-prebuilt-databases-with-pouchdb.md | 2 +- docs/posts/2016-06-06-introducing-pouchdb-custom-builds.md | 2 +- docs/posts/2016-06-06-pouchdb-5.4.0.md | 2 +- docs/posts/2016-09-05-pouchdb-6.0.0.md | 2 +- docs/posts/2016-12-12-pouchdb-6.1.0.md | 2 +- docs/posts/2017-01-05-pouchdb-6.1.1.md | 2 +- docs/posts/2017-04-20-pouchdb-6.2.0.md | 2 +- docs/posts/2017-07-13-pouchdb-6.3.0.md | 2 +- docs/posts/2017-12-16-pouchdb-6.4.0.md | 2 +- docs/posts/2018-01-23-pouchdb-6.4.2.md | 2 +- docs/posts/2018-06-21-pouchdb-7.0.0.md | 2 +- docs/posts/2019-06-13-pouchdb-7.1.1.md | 2 +- docs/posts/2020-02-12-pouchdb-7.2.0.md | 2 +- docs/posts/2022-04-13-pouchdb-7.3.0.md | 2 +- docs/posts/2022-11-11-pouchdb-7.3.1.md | 2 +- docs/posts/2022-12-14-pouchdb-8.0.0.md | 2 +- docs/posts/2023-02-09-pouchdb-8.0.1.md | 2 +- docs/posts/2024-05-24-pouchdb-9.0.0.md | 2 +- docs/posts/2026-04-10-migration-to-nodesqlite.md | 2 +- docs/users.md | 2 +- docs/eleventy.config.js => eleventy.config.js | 7 +++++-- 91 files changed, 97 insertions(+), 93 deletions(-) rename docs/{_layouts => _includes}/2ColLeft.html (94%) rename docs/{_layouts => _includes}/default.html (99%) rename docs/{_layouts => _includes}/guide.html (89%) rename docs/{_layouts => _includes}/post.html (89%) rename docs/eleventy.config.js => eleventy.config.js (92%) diff --git a/docs/_layouts/2ColLeft.html b/docs/_includes/2ColLeft.html similarity index 94% rename from docs/_layouts/2ColLeft.html rename to docs/_includes/2ColLeft.html index a655349eca..555dd68399 100644 --- a/docs/_layouts/2ColLeft.html +++ b/docs/_includes/2ColLeft.html @@ -1,5 +1,5 @@ --- -layout: default +layout: default.html ---
diff --git a/docs/_includes/anchor.html b/docs/_includes/anchor.html index 341b970e1b..8e74e97954 100644 --- a/docs/_includes/anchor.html +++ b/docs/_includes/anchor.html @@ -3,4 +3,4 @@ {% else %} {% assign class = 'h2' %} {% endif %} -
{{ include.title }}{% if include.edit %}{% endif %}
+
{{ include.title | inlinemarkdown }}{% if include.edit %}{% endif %}
diff --git a/docs/_layouts/default.html b/docs/_includes/default.html similarity index 99% rename from docs/_layouts/default.html rename to docs/_includes/default.html index 63670b0804..ca44cc3c2e 100644 --- a/docs/_layouts/default.html +++ b/docs/_includes/default.html @@ -69,12 +69,13 @@
-

{{ title }}

+

{{ title }} {% if edit != false %} {% include edit_button.html %} {% endif %} +

{% if sub_title %}

{{ sub_title}}

{% endif %} diff --git a/docs/_layouts/guide.html b/docs/_includes/guide.html similarity index 89% rename from docs/_layouts/guide.html rename to docs/_includes/guide.html index 87669ad2d4..f46ac39d8e 100644 --- a/docs/_layouts/guide.html +++ b/docs/_includes/guide.html @@ -1,10 +1,10 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html --- {{ content }} -{% assign guides = collections.guides | sort: 'index' %} +{% assign guides = collections.guides | sort: 'data.index' %} {% for guide in guides %} {% if title == guide.data.title %} {% assign prev = guide.data.index | minus: 2 %} diff --git a/docs/_layouts/post.html b/docs/_includes/post.html similarity index 89% rename from docs/_layouts/post.html rename to docs/_includes/post.html index edb399b3cf..452730b6ff 100644 --- a/docs/_layouts/post.html +++ b/docs/_includes/post.html @@ -1,5 +1,5 @@ --- -layout: default +layout: default.html ---
diff --git a/docs/adapters.md b/docs/adapters.md index 82cc35f224..a14e0f3402 100644 --- a/docs/adapters.md +++ b/docs/adapters.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Adapters sidebar: nav.html --- diff --git a/docs/api.html b/docs/api.html index 52b0a3b4ee..d4dab2614f 100644 --- a/docs/api.html +++ b/docs/api.html @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: API Reference sidebar: api.html edit: false diff --git a/docs/blog/index.html b/docs/blog/index.html index 3cc79791c4..efce4eaff0 100644 --- a/docs/blog/index.html +++ b/docs/blog/index.html @@ -1,5 +1,5 @@ --- -layout: default +layout: default.html title: Blog edit: false pagination: diff --git a/docs/custom.md b/docs/custom.md index 613049e6f4..229c2cae4f 100644 --- a/docs/custom.md +++ b/docs/custom.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Custom Builds sidebar: nav.html --- diff --git a/docs/download.md b/docs/download.md index 1663ce0d4a..db01aac2ee 100644 --- a/docs/download.md +++ b/docs/download.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Download sidebar: nav.html --- diff --git a/docs/errors.md b/docs/errors.md index 946f24ad8b..32f4f88f4a 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Common Errors sidebar: nav.html --- diff --git a/docs/external.md b/docs/external.md index c0f26c1b5c..15f8c397de 100644 --- a/docs/external.md +++ b/docs/external.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Plugins and External Projects sidebar: nav.html --- diff --git a/docs/faq.md b/docs/faq.md index b277e6d58e..bd831ff784 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: FAQ sidebar: nav.html --- diff --git a/docs/getting-started.md b/docs/getting-started.md index ccb9be27d5..e9de582e38 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Getting Started Guide sidebar: nav.html --- diff --git a/docs/guides/async-code.md b/docs/guides/async-code.md index cbae358bbe..9f087c88c2 100644 --- a/docs/guides/async-code.md +++ b/docs/guides/async-code.md @@ -1,6 +1,6 @@ --- index: 6 -layout: guide +layout: guide.html title: Asynchronous code sidebar: guides_nav.html --- diff --git a/docs/guides/attachments.md b/docs/guides/attachments.md index dfb1c24c09..37c0fc37c7 100644 --- a/docs/guides/attachments.md +++ b/docs/guides/attachments.md @@ -1,6 +1,6 @@ --- index: 9 -layout: guide +layout: guide.html title: Working with attachments sidebar: guides_nav.html --- diff --git a/docs/guides/bulk-operations.md b/docs/guides/bulk-operations.md index fb487c6524..28ae8634fe 100644 --- a/docs/guides/bulk-operations.md +++ b/docs/guides/bulk-operations.md @@ -1,6 +1,6 @@ --- index: 8 -layout: guide +layout: guide.html title: Bulk operations sidebar: guides_nav.html --- diff --git a/docs/guides/changes.md b/docs/guides/changes.md index f724b35b59..0bc3168016 100644 --- a/docs/guides/changes.md +++ b/docs/guides/changes.md @@ -1,6 +1,6 @@ --- index: 12 -layout: guide +layout: guide.html title: Changes feed sidebar: guides_nav.html --- diff --git a/docs/guides/compact-and-destroy.md b/docs/guides/compact-and-destroy.md index fa7888393a..2c9ed1a9d2 100644 --- a/docs/guides/compact-and-destroy.md +++ b/docs/guides/compact-and-destroy.md @@ -1,6 +1,6 @@ --- index: 15 -layout: guide +layout: guide.html title: Compacting and destroying sidebar: guides_nav.html --- diff --git a/docs/guides/conflicts.md b/docs/guides/conflicts.md index 2a9ba317d3..60898fe779 100644 --- a/docs/guides/conflicts.md +++ b/docs/guides/conflicts.md @@ -1,6 +1,6 @@ --- index: 11 -layout: guide +layout: guide.html title: Conflicts sidebar: guides_nav.html --- diff --git a/docs/guides/databases.md b/docs/guides/databases.md index bab8a1adb4..6e1052799c 100644 --- a/docs/guides/databases.md +++ b/docs/guides/databases.md @@ -1,6 +1,6 @@ --- index: 4 -layout: guide +layout: guide.html title: Working with databases sidebar: guides_nav.html --- diff --git a/docs/guides/documents.md b/docs/guides/documents.md index 5c438d65cd..4b3676e775 100644 --- a/docs/guides/documents.md +++ b/docs/guides/documents.md @@ -1,6 +1,6 @@ --- index: 5 -layout: guide +layout: guide.html title: Working with documents sidebar: guides_nav.html --- diff --git a/docs/guides/index.md b/docs/guides/index.md index 04cada5790..b22939bcdb 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -1,6 +1,6 @@ --- index: 1 -layout: guide +layout: guide.html nav: Intro title: Introduction to PouchDB sidebar: guides_nav.html diff --git a/docs/guides/local-documents.md b/docs/guides/local-documents.md index 5fb4294ac7..e54a6c9158 100644 --- a/docs/guides/local-documents.md +++ b/docs/guides/local-documents.md @@ -1,6 +1,6 @@ --- index: 16 -layout: guide +layout: guide.html title: Local documents sidebar: guides_nav.html --- diff --git a/docs/guides/mango-queries.md b/docs/guides/mango-queries.md index 1339454cbb..71ada9e0e4 100644 --- a/docs/guides/mango-queries.md +++ b/docs/guides/mango-queries.md @@ -1,6 +1,6 @@ --- index: 13 -layout: guide +layout: guide.html title: Mango queries sidebar: guides_nav.html --- diff --git a/docs/guides/queries.md b/docs/guides/queries.md index 3236fbb710..46bcfb409a 100644 --- a/docs/guides/queries.md +++ b/docs/guides/queries.md @@ -1,6 +1,6 @@ --- index: 14 -layout: guide +layout: guide.html title: Map/reduce queries sidebar: guides_nav.html --- diff --git a/docs/guides/replication.md b/docs/guides/replication.md index 0b40099131..4f6a724205 100644 --- a/docs/guides/replication.md +++ b/docs/guides/replication.md @@ -1,6 +1,6 @@ --- index: 10 -layout: guide +layout: guide.html title: Replication sidebar: guides_nav.html --- diff --git a/docs/guides/setup-couchdb.md b/docs/guides/setup-couchdb.md index ee293a58ad..08bc33c002 100644 --- a/docs/guides/setup-couchdb.md +++ b/docs/guides/setup-couchdb.md @@ -1,6 +1,6 @@ --- index: 2 -layout: guide +layout: guide.html title: Setting up CouchDB sidebar: guides_nav.html --- diff --git a/docs/guides/setup-pouchdb.md b/docs/guides/setup-pouchdb.md index 938edbab50..06dc934c87 100644 --- a/docs/guides/setup-pouchdb.md +++ b/docs/guides/setup-pouchdb.md @@ -1,6 +1,6 @@ --- index: 3 -layout: guide +layout: guide.html title: Setting up PouchDB sidebar: guides_nav.html --- diff --git a/docs/guides/updating-deleting.md b/docs/guides/updating-deleting.md index e4a3894340..ba3b8b6c82 100644 --- a/docs/guides/updating-deleting.md +++ b/docs/guides/updating-deleting.md @@ -1,6 +1,6 @@ --- index: 7 -layout: guide +layout: guide.html nav: Updating/deleting documents title: Updating and deleting documents sidebar: guides_nav.html diff --git a/docs/index.md b/docs/index.md index 00ca03567d..6cb3de42f8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ --- -layout: default +layout: default.html title: PouchDB, the JavaScript Database that Syncs! ---
diff --git a/docs/learn.md b/docs/learn.md index 6535eb7a6c..0b6e4a3409 100644 --- a/docs/learn.md +++ b/docs/learn.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: About PouchDB sidebar: nav.html --- diff --git a/docs/offline.md b/docs/offline.md index ead364418e..105fbc1a23 100644 --- a/docs/offline.md +++ b/docs/offline.md @@ -1,5 +1,5 @@ --- -layout: default +layout: default.html title: Looks like you're offline... edit: false --- diff --git a/docs/posts/2014-04-01-pouchdb-2.1.0.md b/docs/posts/2014-04-01-pouchdb-2.1.0.md index 2071b8072b..38e044d5f5 100644 --- a/docs/posts/2014-04-01-pouchdb-2.1.0.md +++ b/docs/posts/2014-04-01-pouchdb-2.1.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 2.1.0 diff --git a/docs/posts/2014-04-01-welcome-to-the-pouchdb-blog.md b/docs/posts/2014-04-01-welcome-to-the-pouchdb-blog.md index b3df50b13f..9794ab879c 100644 --- a/docs/posts/2014-04-01-welcome-to-the-pouchdb-blog.md +++ b/docs/posts/2014-04-01-welcome-to-the-pouchdb-blog.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Welcome to the PouchDB blog diff --git a/docs/posts/2014-04-14-pagination-strategies-with-pouchdb.md b/docs/posts/2014-04-14-pagination-strategies-with-pouchdb.md index 42072f5a41..bebb0e974e 100644 --- a/docs/posts/2014-04-14-pagination-strategies-with-pouchdb.md +++ b/docs/posts/2014-04-14-pagination-strategies-with-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Pagination strategies with PouchDB diff --git a/docs/posts/2014-05-01-pouchdb-2.2.0.md b/docs/posts/2014-05-01-pouchdb-2.2.0.md index e56e81a12d..db7464bae6 100644 --- a/docs/posts/2014-05-01-pouchdb-2.2.0.md +++ b/docs/posts/2014-05-01-pouchdb-2.2.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 2.2.0 diff --git a/docs/posts/2014-05-01-secondary-indexes-have-landed-in-pouchdb.md b/docs/posts/2014-05-01-secondary-indexes-have-landed-in-pouchdb.md index 720117ff05..8661423c4d 100644 --- a/docs/posts/2014-05-01-secondary-indexes-have-landed-in-pouchdb.md +++ b/docs/posts/2014-05-01-secondary-indexes-have-landed-in-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Secondary indexes have landed in PouchDB diff --git a/docs/posts/2014-06-01-pouchdb-2.2.3.md b/docs/posts/2014-06-01-pouchdb-2.2.3.md index e7c6f09b8d..51d34f20ac 100644 --- a/docs/posts/2014-06-01-pouchdb-2.2.3.md +++ b/docs/posts/2014-06-01-pouchdb-2.2.3.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 2.2.3 diff --git a/docs/posts/2014-06-17-12-pro-tips-for-better-code-with-pouchdb.md b/docs/posts/2014-06-17-12-pro-tips-for-better-code-with-pouchdb.md index 72583e558b..579f58854a 100644 --- a/docs/posts/2014-06-17-12-pro-tips-for-better-code-with-pouchdb.md +++ b/docs/posts/2014-06-17-12-pro-tips-for-better-code-with-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: 12 pro tips for better code with PouchDB diff --git a/docs/posts/2014-07-25-pouchdb-levels-up.md b/docs/posts/2014-07-25-pouchdb-levels-up.md index 434b955908..dba5ecc51a 100644 --- a/docs/posts/2014-07-25-pouchdb-levels-up.md +++ b/docs/posts/2014-07-25-pouchdb-levels-up.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB levels up diff --git a/docs/posts/2014-08-12-pouchdb-3.0.0.md b/docs/posts/2014-08-12-pouchdb-3.0.0.md index fcede66eea..b84b2be14c 100644 --- a/docs/posts/2014-08-12-pouchdb-3.0.0.md +++ b/docs/posts/2014-08-12-pouchdb-3.0.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.0 diff --git a/docs/posts/2014-08-16-pouchdb-3.0.1.md b/docs/posts/2014-08-16-pouchdb-3.0.1.md index 0e243e6442..423cb5dea0 100644 --- a/docs/posts/2014-08-16-pouchdb-3.0.1.md +++ b/docs/posts/2014-08-16-pouchdb-3.0.1.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.1 diff --git a/docs/posts/2014-08-20-pouchdb-3.0.2.md b/docs/posts/2014-08-20-pouchdb-3.0.2.md index 946b37242c..b895af0cb6 100644 --- a/docs/posts/2014-08-20-pouchdb-3.0.2.md +++ b/docs/posts/2014-08-20-pouchdb-3.0.2.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.2 diff --git a/docs/posts/2014-08-29-pouchdb-3.0.3.md b/docs/posts/2014-08-29-pouchdb-3.0.3.md index 150cd390b8..e1ab7cf70d 100644 --- a/docs/posts/2014-08-29-pouchdb-3.0.3.md +++ b/docs/posts/2014-08-29-pouchdb-3.0.3.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.3 diff --git a/docs/posts/2014-09-04-pouchdb-3.0.4.md b/docs/posts/2014-09-04-pouchdb-3.0.4.md index fc6fec8ae6..1b3fc4f936 100644 --- a/docs/posts/2014-09-04-pouchdb-3.0.4.md +++ b/docs/posts/2014-09-04-pouchdb-3.0.4.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.4: Night of the Living Attachments diff --git a/docs/posts/2014-09-07-pouchdb-3.0.5.md b/docs/posts/2014-09-07-pouchdb-3.0.5.md index b8319a76ad..fcc37dd3e9 100644 --- a/docs/posts/2014-09-07-pouchdb-3.0.5.md +++ b/docs/posts/2014-09-07-pouchdb-3.0.5.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.5: Turtles All the Way Down diff --git a/docs/posts/2014-09-22-3.0.6.md b/docs/posts/2014-09-22-3.0.6.md index 514cbe7203..781bb5e568 100644 --- a/docs/posts/2014-09-22-3.0.6.md +++ b/docs/posts/2014-09-22-3.0.6.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.0.6: Safari Madness diff --git a/docs/posts/2014-10-26-10-things-i-learned-from-reading-and-writing-the-pouchdb-source.md b/docs/posts/2014-10-26-10-things-i-learned-from-reading-and-writing-the-pouchdb-source.md index b17172de48..acd7eef4ab 100644 --- a/docs/posts/2014-10-26-10-things-i-learned-from-reading-and-writing-the-pouchdb-source.md +++ b/docs/posts/2014-10-26-10-things-i-learned-from-reading-and-writing-the-pouchdb-source.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: 10 things I learned from reading (and writing) the PouchDB source diff --git a/docs/posts/2014-11-10-3.1.0.md b/docs/posts/2014-11-10-3.1.0.md index 23bb46c88a..4a0456bc35 100644 --- a/docs/posts/2014-11-10-3.1.0.md +++ b/docs/posts/2014-11-10-3.1.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.1.0: A Guide to Recognizing Your Marsupials (The PouchDB Guide) diff --git a/docs/posts/2014-11-27-testing-pouchdb.md b/docs/posts/2014-11-27-testing-pouchdb.md index b0a2b2db91..c25f9bc051 100644 --- a/docs/posts/2014-11-27-testing-pouchdb.md +++ b/docs/posts/2014-11-27-testing-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: How we test PouchDB diff --git a/docs/posts/2014-12-04-3.2.0.md b/docs/posts/2014-12-04-3.2.0.md index 651bb04e36..37d0c6cd79 100644 --- a/docs/posts/2014-12-04-3.2.0.md +++ b/docs/posts/2014-12-04-3.2.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.2.0: To code is human, to debug is divine diff --git a/docs/posts/2014-12-11-the-pains-of-being-async-at-heart.md b/docs/posts/2014-12-11-the-pains-of-being-async-at-heart.md index 10ff7b1a0e..55a7e58564 100644 --- a/docs/posts/2014-12-11-the-pains-of-being-async-at-heart.md +++ b/docs/posts/2014-12-11-the-pains-of-being-async-at-heart.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: The Pains Of Being Async At Heart diff --git a/docs/posts/2015-01-05-pouchdb-3.2.1-you-can-always-be-faster.md b/docs/posts/2015-01-05-pouchdb-3.2.1-you-can-always-be-faster.md index ef97084cc8..6e2f3b555d 100644 --- a/docs/posts/2015-01-05-pouchdb-3.2.1-you-can-always-be-faster.md +++ b/docs/posts/2015-01-05-pouchdb-3.2.1-you-can-always-be-faster.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.2.1: You can always be faster diff --git a/docs/posts/2015-02-03-fix-up-look-sharp.md b/docs/posts/2015-02-03-fix-up-look-sharp.md index 277f1e86f7..4e3a66ffb6 100644 --- a/docs/posts/2015-02-03-fix-up-look-sharp.md +++ b/docs/posts/2015-02-03-fix-up-look-sharp.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.3.0: Fix Up, Look Sharp author: Dale Harvey diff --git a/docs/posts/2015-02-14-a-quick-one.md b/docs/posts/2015-02-14-a-quick-one.md index a14717ee09..ead8a32e85 100644 --- a/docs/posts/2015-02-14-a-quick-one.md +++ b/docs/posts/2015-02-14-a-quick-one.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.3.1: A quick one while he's away author: Nolan Lawson diff --git a/docs/posts/2015-02-28-efficiently-managing-ui-state-in-pouchdb.md b/docs/posts/2015-02-28-efficiently-managing-ui-state-in-pouchdb.md index 609dde61a2..86c7f6304e 100644 --- a/docs/posts/2015-02-28-efficiently-managing-ui-state-in-pouchdb.md +++ b/docs/posts/2015-02-28-efficiently-managing-ui-state-in-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Efficiently managing UI state with PouchDB diff --git a/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md b/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md index cd718fda74..ee1ec9ae7d 100644 --- a/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md +++ b/docs/posts/2015-03-05-taming-the-async-beast-with-es7.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Taming the asynchronous beast with ES7 diff --git a/docs/posts/2015-04-05-filtered-replication.md b/docs/posts/2015-04-05-filtered-replication.md index 87548ccff7..8b67ad0496 100644 --- a/docs/posts/2015-04-05-filtered-replication.md +++ b/docs/posts/2015-04-05-filtered-replication.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Filtered replication: from Couch to Pouch and back diff --git a/docs/posts/2015-04-07-better-late-than-never.md b/docs/posts/2015-04-07-better-late-than-never.md index 2b9bd7a1f8..d68c7af7df 100644 --- a/docs/posts/2015-04-07-better-late-than-never.md +++ b/docs/posts/2015-04-07-better-late-than-never.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.4.0: Better late than never author: Dale Harvey diff --git a/docs/posts/2015-05-07-pouchdb-3.5.0-vote-for-pouchdb.md b/docs/posts/2015-05-07-pouchdb-3.5.0-vote-for-pouchdb.md index 900d6c4d66..ac7d436a1b 100644 --- a/docs/posts/2015-05-07-pouchdb-3.5.0-vote-for-pouchdb.md +++ b/docs/posts/2015-05-07-pouchdb-3.5.0-vote-for-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.5.0: Vote for PouchDB author: Dale Harvey diff --git a/docs/posts/2015-05-18-we-have-a-problem-with-promises.md b/docs/posts/2015-05-18-we-have-a-problem-with-promises.md index 0763e11214..d971dc4973 100644 --- a/docs/posts/2015-05-18-we-have-a-problem-with-promises.md +++ b/docs/posts/2015-05-18-we-have-a-problem-with-promises.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: We have a problem with promises author: Nolan Lawson diff --git a/docs/posts/2015-06-01-pouchdb-3.6.0.md b/docs/posts/2015-06-01-pouchdb-3.6.0.md index b30431fe8d..6c4c0bdc4a 100644 --- a/docs/posts/2015-06-01-pouchdb-3.6.0.md +++ b/docs/posts/2015-06-01-pouchdb-3.6.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 3.6.0 author: Nolan Lawson diff --git a/docs/posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md b/docs/posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md index e251383df7..4405efda86 100644 --- a/docs/posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md +++ b/docs/posts/2015-08-03-pouchdb-4.0.0-ballast-overboard.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 4.0.0 - Ballast Overboard author: Dale Harvey diff --git a/docs/posts/2015-09-01-pouchdb-4.0.1-gotta-go-fast.md b/docs/posts/2015-09-01-pouchdb-4.0.1-gotta-go-fast.md index f92606f579..58a68abee6 100644 --- a/docs/posts/2015-09-01-pouchdb-4.0.1-gotta-go-fast.md +++ b/docs/posts/2015-09-01-pouchdb-4.0.1-gotta-go-fast.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 4.0.1 - Gotta Go Fast author: Nolan Lawson diff --git a/docs/posts/2015-09-12-pouchdb-4.0.2-a-little-extra.md b/docs/posts/2015-09-12-pouchdb-4.0.2-a-little-extra.md index 7a652b6ae8..08c93ba7a8 100644 --- a/docs/posts/2015-09-12-pouchdb-4.0.2-a-little-extra.md +++ b/docs/posts/2015-09-12-pouchdb-4.0.2-a-little-extra.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 4.0.2 - A Little Extra author: Nolan Lawson diff --git a/docs/posts/2015-10-06-pouchdb-5.0.0-five-years-of-pouchdb.md b/docs/posts/2015-10-06-pouchdb-5.0.0-five-years-of-pouchdb.md index cc0584c752..db730a51c3 100644 --- a/docs/posts/2015-10-06-pouchdb-5.0.0-five-years-of-pouchdb.md +++ b/docs/posts/2015-10-06-pouchdb-5.0.0-five-years-of-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 5.0.0 - Five years of PouchDB author: Nolan Lawson diff --git a/docs/posts/2015-11-03-cover-all.md b/docs/posts/2015-11-03-cover-all.md index 669dc2c066..f574ad32b4 100644 --- a/docs/posts/2015-11-03-cover-all.md +++ b/docs/posts/2015-11-03-cover-all.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 5.1.0 - Cover all the things author: Dale Harvey diff --git a/docs/posts/2016-01-13-pouchdb-5.2.0-a-better-build-system-with-rollup.md b/docs/posts/2016-01-13-pouchdb-5.2.0-a-better-build-system-with-rollup.md index 50b711ec43..292fef41ab 100644 --- a/docs/posts/2016-01-13-pouchdb-5.2.0-a-better-build-system-with-rollup.md +++ b/docs/posts/2016-01-13-pouchdb-5.2.0-a-better-build-system-with-rollup.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 5.2.0: A better build system with Rollup author: Nolan Lawson diff --git a/docs/posts/2016-03-04-pouchdb-5.3.0-sqlite-support-in-node.md b/docs/posts/2016-03-04-pouchdb-5.3.0-sqlite-support-in-node.md index 71aa24541b..ba6aae354f 100644 --- a/docs/posts/2016-03-04-pouchdb-5.3.0-sqlite-support-in-node.md +++ b/docs/posts/2016-03-04-pouchdb-5.3.0-sqlite-support-in-node.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 5.3.0: SQLite support in Node author: Nolan Lawson diff --git a/docs/posts/2016-04-28-prebuilt-databases-with-pouchdb.md b/docs/posts/2016-04-28-prebuilt-databases-with-pouchdb.md index 774e0e1168..a8ab136fbb 100644 --- a/docs/posts/2016-04-28-prebuilt-databases-with-pouchdb.md +++ b/docs/posts/2016-04-28-prebuilt-databases-with-pouchdb.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Prebuilt databases with PouchDB author: Nolan Lawson diff --git a/docs/posts/2016-06-06-introducing-pouchdb-custom-builds.md b/docs/posts/2016-06-06-introducing-pouchdb-custom-builds.md index 6458f84ac2..31c0052219 100644 --- a/docs/posts/2016-06-06-introducing-pouchdb-custom-builds.md +++ b/docs/posts/2016-06-06-introducing-pouchdb-custom-builds.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: Introducing PouchDB custom builds author: Nolan Lawson diff --git a/docs/posts/2016-06-06-pouchdb-5.4.0.md b/docs/posts/2016-06-06-pouchdb-5.4.0.md index 094a7dc034..c8bf37d44b 100644 --- a/docs/posts/2016-06-06-pouchdb-5.4.0.md +++ b/docs/posts/2016-06-06-pouchdb-5.4.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 5.4.0 author: Nolan Lawson diff --git a/docs/posts/2016-09-05-pouchdb-6.0.0.md b/docs/posts/2016-09-05-pouchdb-6.0.0.md index ccf2cfb6fe..d5f3efd453 100644 --- a/docs/posts/2016-09-05-pouchdb-6.0.0.md +++ b/docs/posts/2016-09-05-pouchdb-6.0.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.0.0: Labour Day author: Dale Harvey diff --git a/docs/posts/2016-12-12-pouchdb-6.1.0.md b/docs/posts/2016-12-12-pouchdb-6.1.0.md index 9c42937dc2..c344b69f5d 100644 --- a/docs/posts/2016-12-12-pouchdb-6.1.0.md +++ b/docs/posts/2016-12-12-pouchdb-6.1.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.1.0 author: Nolan Lawson diff --git a/docs/posts/2017-01-05-pouchdb-6.1.1.md b/docs/posts/2017-01-05-pouchdb-6.1.1.md index f2bc8f0880..b749327b3d 100644 --- a/docs/posts/2017-01-05-pouchdb-6.1.1.md +++ b/docs/posts/2017-01-05-pouchdb-6.1.1.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.1.1 author: Dale Harvey diff --git a/docs/posts/2017-04-20-pouchdb-6.2.0.md b/docs/posts/2017-04-20-pouchdb-6.2.0.md index 073cabc9c7..db343fa94c 100644 --- a/docs/posts/2017-04-20-pouchdb-6.2.0.md +++ b/docs/posts/2017-04-20-pouchdb-6.2.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.2.0 author: Garren Smith diff --git a/docs/posts/2017-07-13-pouchdb-6.3.0.md b/docs/posts/2017-07-13-pouchdb-6.3.0.md index ea0e195e6d..e4c51f6bb7 100644 --- a/docs/posts/2017-07-13-pouchdb-6.3.0.md +++ b/docs/posts/2017-07-13-pouchdb-6.3.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.3.0 author: Will Holley diff --git a/docs/posts/2017-12-16-pouchdb-6.4.0.md b/docs/posts/2017-12-16-pouchdb-6.4.0.md index 8e3636c56e..4c2d1cc0a0 100644 --- a/docs/posts/2017-12-16-pouchdb-6.4.0.md +++ b/docs/posts/2017-12-16-pouchdb-6.4.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.4.0 author: Dale Harvey diff --git a/docs/posts/2018-01-23-pouchdb-6.4.2.md b/docs/posts/2018-01-23-pouchdb-6.4.2.md index f8942e991b..ce78b0519a 100644 --- a/docs/posts/2018-01-23-pouchdb-6.4.2.md +++ b/docs/posts/2018-01-23-pouchdb-6.4.2.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 6.4.2 - Long live WebSQL author: Dale Harvey diff --git a/docs/posts/2018-06-21-pouchdb-7.0.0.md b/docs/posts/2018-06-21-pouchdb-7.0.0.md index e3ac945194..615ebf6cf8 100644 --- a/docs/posts/2018-06-21-pouchdb-7.0.0.md +++ b/docs/posts/2018-06-21-pouchdb-7.0.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 7.0 - 17.5% less PouchDB author: Dale Harvey diff --git a/docs/posts/2019-06-13-pouchdb-7.1.1.md b/docs/posts/2019-06-13-pouchdb-7.1.1.md index 465bcbe391..d52ff4d88c 100644 --- a/docs/posts/2019-06-13-pouchdb-7.1.1.md +++ b/docs/posts/2019-06-13-pouchdb-7.1.1.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 7.1.1 - Bug fixes and dependency updates author: Garren Smith diff --git a/docs/posts/2020-02-12-pouchdb-7.2.0.md b/docs/posts/2020-02-12-pouchdb-7.2.0.md index 9dbb23c54b..506fce42fd 100644 --- a/docs/posts/2020-02-12-pouchdb-7.2.0.md +++ b/docs/posts/2020-02-12-pouchdb-7.2.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 7.2.1 - New indexeddb adapter author: Gareth Bowen diff --git a/docs/posts/2022-04-13-pouchdb-7.3.0.md b/docs/posts/2022-04-13-pouchdb-7.3.0.md index 9f38f056bb..c28bbd8bd4 100644 --- a/docs/posts/2022-04-13-pouchdb-7.3.0.md +++ b/docs/posts/2022-04-13-pouchdb-7.3.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 7.3.0 author: Alba Herrerías diff --git a/docs/posts/2022-11-11-pouchdb-7.3.1.md b/docs/posts/2022-11-11-pouchdb-7.3.1.md index a0bbb87f23..0e5f7f34de 100644 --- a/docs/posts/2022-11-11-pouchdb-7.3.1.md +++ b/docs/posts/2022-11-11-pouchdb-7.3.1.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 7.3.1 author: Alba Herrerías diff --git a/docs/posts/2022-12-14-pouchdb-8.0.0.md b/docs/posts/2022-12-14-pouchdb-8.0.0.md index c64a6212b2..c03f7d5033 100644 --- a/docs/posts/2022-12-14-pouchdb-8.0.0.md +++ b/docs/posts/2022-12-14-pouchdb-8.0.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 8.0.0 — Modernizing PouchDB author: Alba Herrerías diff --git a/docs/posts/2023-02-09-pouchdb-8.0.1.md b/docs/posts/2023-02-09-pouchdb-8.0.1.md index 19184520a9..63b12206f5 100644 --- a/docs/posts/2023-02-09-pouchdb-8.0.1.md +++ b/docs/posts/2023-02-09-pouchdb-8.0.1.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 8.0.1 author: Alba Herrerías diff --git a/docs/posts/2024-05-24-pouchdb-9.0.0.md b/docs/posts/2024-05-24-pouchdb-9.0.0.md index 920bbe3029..ec93381bd0 100644 --- a/docs/posts/2024-05-24-pouchdb-9.0.0.md +++ b/docs/posts/2024-05-24-pouchdb-9.0.0.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB 9.0.0 author: Alba Herrerías diff --git a/docs/posts/2026-04-10-migration-to-nodesqlite.md b/docs/posts/2026-04-10-migration-to-nodesqlite.md index 3d651cdaa9..9f3fbbb8be 100644 --- a/docs/posts/2026-04-10-migration-to-nodesqlite.md +++ b/docs/posts/2026-04-10-migration-to-nodesqlite.md @@ -1,5 +1,5 @@ --- -layout: post +layout: post.html title: PouchDB has a new adapter - nodesqlite author: Alba Herrerías diff --git a/docs/users.md b/docs/users.md index 8d1d4a8ec4..5b147c3bee 100644 --- a/docs/users.md +++ b/docs/users.md @@ -1,5 +1,5 @@ --- -layout: 2ColLeft +layout: 2ColLeft.html title: Who's using PouchDB? sidebar: nav.html --- diff --git a/docs/eleventy.config.js b/eleventy.config.js similarity index 92% rename from docs/eleventy.config.js rename to eleventy.config.js index 0f3f2ddd76..0fd3131ac8 100644 --- a/docs/eleventy.config.js +++ b/eleventy.config.js @@ -4,6 +4,9 @@ const LINEBREAK_PLACEHOLDER = '---linebreak-placeholder---'; module.exports = eleventyConfig => { process.env.TZ = 'UTC'; + // Turn off extensionless layouts + // https://www.11ty.dev/docs/layouts/#omitting-the-layouts-file-extension + eleventyConfig.setLayoutResolution(false); eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-syntaxhighlight")); eleventyConfig.addPassthroughCopy('asf.md'); @@ -74,8 +77,8 @@ module.exports = eleventyConfig => { return { dir: { - includes: '_includes', - layouts: '_layouts', + input: './docs', + output: "docs/_site" }, }; }; From a45047913185855aa0fc20502e29bf5cb11d2db3 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 11:16:46 +0200 Subject: [PATCH 05/17] fix: fixed, updated and simplified the build-site script No longer maxes out CPUs and no more orphaned node processes --- bin/build-site.js | 91 ++++++++++------------------------------------- 1 file changed, 18 insertions(+), 73 deletions(-) diff --git a/bin/build-site.js b/bin/build-site.js index 7a7387c0b2..339e64cba0 100755 --- a/bin/build-site.js +++ b/bin/build-site.js @@ -6,53 +6,18 @@ const { promisify } = require('node:util'); const exec = promisify(require('node:child_process').exec); var fs = require('fs'); -const Path = require('node:path'); -var replace = require('replace'); -var cssmin = require('cssmin'); -const terser = require('terser'); - -const POUCHDB_CSS = resolvePath('docs/static/css/pouchdb.css'); -const POUCHDB_LESS = resolvePath('docs/src/less/pouchdb/pouchdb.less'); - -process.chdir('docs'); +process.chdir('./'); async function buildCSS() { - fs.mkdirSync(__dirname + '/../docs/static/css', { recursive:true }); - const cmd = [ resolvePath('node_modules/less/bin/lessc'), POUCHDB_LESS ].join(' '); - const { stdout } = await exec(cmd); - const minifiedCss = cssmin(stdout); - fs.writeFileSync(POUCHDB_CSS, minifiedCss); - console.log('Updated:', POUCHDB_CSS); + await exec('npm run build:less'); + console.log('=> Rebuilt CSS'); } async function buildEleventy() { - await exec('npx @11ty/eleventy'); + await exec('eleventy'); await checkForUnprocessedCurlies(); console.log('=> Rebuilt eleventy'); - - highlightEs6(); - console.log('=> Highlighted ES6'); - - const srcPath = resolvePath('docs/src/code.js'); - const targetPath = resolvePath('docs/_site/static/js/code.min.js'); - const src = fs.readFileSync(srcPath, { encoding:'utf8' }); - const mangle = { toplevel: true }; - const output = { ascii_only: true }; - const { code, error } = terser.minify(src, { mangle, output }); - if (error) { - if (process.env.BUILD) { - throw error; - } else { - console.log( - `Javascript minification failed on line ${error.line} col ${error.col}:`, - error.message, - ); - } - } else { - fs.writeFileSync(targetPath, code); - console.log('Minified javascript.'); - } } async function checkForUnprocessedCurlies() { @@ -77,34 +42,14 @@ async function checkForUnprocessedCurlies() { } } -function highlightEs6() { - const path = resolvePath('docs/_site'); - - // TODO: this is a fragile and hacky way to get - // 'async' and 'await' to highlight correctly - // in blog posts & documentation. - replace({ - regex: '(await|async|of)', - replacement: '$1', - paths: [path], - recursive: true - }); -} - -function onError(err) { - console.error(err); - process.exit(1); -} - -function buildEverything() { - return Promise.resolve() - .then(buildCSS) - .then(buildEleventy) - .catch(onError); -} - -function resolvePath(projectLocalPath) { - return Path.resolve(__dirname, '..', projectLocalPath); +async function buildEverything() { + try { + await buildCSS(); + await buildEleventy(); + } catch (error) { + console.error(error); + process.exit(1); + } } if (!process.env.BUILD) { @@ -113,23 +58,23 @@ if (!process.env.BUILD) { const watchGlob = (path, fn) => globWatcher(path, () => fn().catch(console.log)); // Simpler ways of blacklisting certain paths here would be very welcome. - fs.readdirSync('.') + fs.readdirSync('./docs') .forEach(path => { if (path === '_site') { return; } - if (fs.statSync(path).isDirectory()) { - watchGlob(`${path}/**`, buildEleventy); + if (fs.statSync(`./docs/${path}`).isDirectory()) { + watchGlob(`./docs/${path}/**`, buildEleventy); } else { - watchGlob(path, buildEleventy); + watchGlob(`./docs/${path}`, buildEleventy); } }); - watchGlob('src/less/**', buildCSS); + watchGlob('./docs/src/less/**', buildCSS); - http_server.createServer({root: '_site', cache: '-1'}).listen(4000); + http_server.createServer({root: './docs/_site', cache: '-1'}).listen(4000); console.log('Server address: http://localhost:4000'); } From baf6bd6941b8d36d0cbd38414cbf1f7abb5a9292 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 11:26:23 +0200 Subject: [PATCH 06/17] fix: edit button link and position --- docs/_includes/default.html | 2 +- docs/_includes/edit_button.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_includes/default.html b/docs/_includes/default.html index ca44cc3c2e..5177ac83c9 100644 --- a/docs/_includes/default.html +++ b/docs/_includes/default.html @@ -71,7 +71,7 @@

{{ title }} {% if edit != false %} - + {% include edit_button.html %} {% endif %} diff --git a/docs/_includes/edit_button.html b/docs/_includes/edit_button.html index 801ef54442..20d90dc82f 100644 --- a/docs/_includes/edit_button.html +++ b/docs/_includes/edit_button.html @@ -1,4 +1,4 @@ -{% assign pagePath = page.inputPath | replace: "./", "" %} +{% assign pagePath = page.inputPath | replace: "./", "" | replace: "docs/", "" %} Date: Mon, 4 May 2026 11:29:33 +0200 Subject: [PATCH 07/17] chore: format code.js --- docs/src/code.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/src/code.js b/docs/src/code.js index 6015637e03..0e08b0bec6 100644 --- a/docs/src/code.js +++ b/docs/src/code.js @@ -1,4 +1,4 @@ -function codeWrap(){ +function codeWrap() { "use strict"; var DEFAULT_TYPE = 'promise'; @@ -7,10 +7,10 @@ function codeWrap(){ var codeIds = $codes - .map(function(div){ - return div.attributes["data-code-id"].value + .map(function (div) { + return div.attributes["data-code-id"].value; }) - .filter(function(item, index, inputArray){ + .filter(function (item, index, inputArray) { // Each code block has multiple versions so let's only grab one. return inputArray.indexOf(item) === index; }); @@ -18,7 +18,7 @@ function codeWrap(){ wrap(); setAll(); - $('[data-code-tablist] [href]').on('click', function(e){ + $('[data-code-tablist] [href]').on('click', function (e) { var href = $(this).attr('href'); setAll(href.replace('#', '')); @@ -28,7 +28,7 @@ function codeWrap(){ e.preventDefault(); }); - function wrap(){ + function wrap() { var codeTpl = '' + '' + '
{{tabPanes}}
'; codeIds - .forEach(function(id){ + .forEach(function (id) { var $code = $("[data-code-id='" + id + "']"); - var paneHtml = $code.get().map(function(div){ + var paneHtml = $code.get().map(function (div) { return div.outerHTML; }).join(''); @@ -62,16 +62,16 @@ function codeWrap(){ $('[data-code-hide]').addClass('hide'); } - function setAll(type){ + function setAll(type) { // We default to callback so no need to do anything the first time. var firstTime = !localStorage.getItem('codeStyle'); - if(firstTime){ + if (firstTime) { localStorage.setItem('codeStyle', DEFAULT_TYPE); } type = type || localStorage.getItem('codeStyle'); - if(typeof type === "undefined" || type === null) { + if (typeof type === "undefined" || type === null) { return; } @@ -86,22 +86,22 @@ function codeWrap(){ var setHeights = []; - function setEqualHeights(){ - if(setHeights.length > 0){ + function setEqualHeights() { + if (setHeights.length > 0) { return; } codeIds - .forEach(function(id){ + .forEach(function (id) { var $code = $("[data-code-id='" + id + "']"); var paneHeight = 0; - $code.get().forEach(function(div){ + $code.get().forEach(function (div) { var originalDisplay = div.style.display; div.style.display = 'block'; var clientHeight = div.clientHeight; div.style.display = originalDisplay; - if(clientHeight > paneHeight){ + if (clientHeight > paneHeight) { paneHeight = clientHeight; } }); @@ -113,7 +113,7 @@ function codeWrap(){ codeWrap(); function addCodeCopyButtons() { - if (!navigator.clipboard.writeText) return; + if (!navigator.clipboard.writeText) {return;} function copyCodeFor(codeElement) { return () => { From a5c265f4f5d1450088866f21d83a004f4edde382 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 11:48:53 +0200 Subject: [PATCH 08/17] chore: move 11ty syntac highlighter plugin to dev dependencies --- package-lock.json | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1edf8f7c92..70ad46353e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "7.0.0-prerelease", "license": "Apache-2.0", "dependencies": { - "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "@neighbourhoodie/websql": "2.0.4", "double-ended-queue": "2.1.0-0", "fetch-cookie": "2.2.0", @@ -30,6 +29,7 @@ }, "devDependencies": { "@11ty/eleventy": "3.1.2", + "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "add-cors-to-couchdb": "0.0.6", "body-parser": "1.20.3", "browserify": "16.4.0", @@ -368,6 +368,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-5.0.2.tgz", "integrity": "sha512-T6xVVRDJuHlrFMHbUiZkHjj5o1IlLzZW+1IL9eUsyXFU7rY2ztcYhZew/64vmceFFpQwzuSfxQOXxTJYmKkQ+A==", + "dev": true, "license": "MIT", "dependencies": { "prismjs": "^1.30.0" @@ -8950,6 +8951,7 @@ "version": "1.30.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", "integrity": "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" diff --git a/package.json b/package.json index f44fb0ce6e..bb686e022a 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "url": "https://github.com/apache/pouchdb.git" }, "dependencies": { - "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "@neighbourhoodie/websql": "2.0.4", "double-ended-queue": "2.1.0-0", "fetch-cookie": "2.2.0", @@ -59,6 +58,7 @@ }, "devDependencies": { "@11ty/eleventy": "3.1.2", + "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.2", "add-cors-to-couchdb": "0.0.6", "body-parser": "1.20.3", "browserify": "16.4.0", From 2d9d414aefefaf310db305941bb21a6ac942d06b Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 13:58:58 +0200 Subject: [PATCH 09/17] fix: reinstate code.js minification for the site, plus fixes for the code copy button --- docs/src/code.js | 8 +++++--- eleventy.config.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/docs/src/code.js b/docs/src/code.js index 0e08b0bec6..017b3a143f 100644 --- a/docs/src/code.js +++ b/docs/src/code.js @@ -134,8 +134,10 @@ function addCodeCopyButtons() { function addButton(txt, parent) { const btn = document.createElement('button'); btn.style.position = 'absolute'; - btn.style.top = '11.5px'; - btn.style.right = '11.5px'; + btn.style.top = '6px'; + btn.style.right = '6px'; + btn.style.borderRadius = '5px'; + btn.style.padding = '4px 10px 3px'; btn.textContent = txt; btn.classList.add('btnCopyCode'); @@ -145,7 +147,7 @@ function addCodeCopyButtons() { } document - .querySelectorAll('pre[data-copybutton]') + .querySelectorAll('pre[class^=language]') .forEach(codeElement => { codeElement.style.position = 'relative'; diff --git a/eleventy.config.js b/eleventy.config.js index 0fd3131ac8..c47bf58f64 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1,4 +1,6 @@ const markdownIt = require('markdown-it'); +const Terser = require("terser"); +const through = require('through2'); const LINEBREAK_PLACEHOLDER = '---linebreak-placeholder---'; @@ -9,8 +11,34 @@ module.exports = eleventyConfig => { eleventyConfig.setLayoutResolution(false); eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-syntaxhighlight")); - eleventyConfig.addPassthroughCopy('asf.md'); - eleventyConfig.addPassthroughCopy('static'); + eleventyConfig.addPassthroughCopy('./docs/asf.md'); + eleventyConfig.addPassthroughCopy('./docs/static'); + eleventyConfig.addPassthroughCopy( + { + "./docs/src/code.js": "static/js/code.min.js", + }, + { + transform: function(src, dest, stats) { + let buffer = ''; + + return through( + function (chunk, enc, done) { + buffer += chunk.toString(); + done(); + }, + function (done) { + // INFO: this usage is very specific to the pinned Terser 4.8.0, + // if Terser is ever updated, this will break. + const result = Terser.minify(buffer) + if (result.error) { + console.log('Error minifying code.js:', result.error) + } + done(null, result.code) + } + ); + } + } + ); eleventyConfig.setLiquidOptions({ jekyllInclude: true, From d8d09cf595d37f89db684184ad0a5a90e819bb17 Mon Sep 17 00:00:00 2001 From: Alex Feyerke Date: Mon, 4 May 2026 14:02:04 +0200 Subject: [PATCH 10/17] refactor: remove stickyfill, since position sticky is widely available now. --- docs/_includes/default.html | 5 ----- docs/manifest.appcache.liquid | 1 - docs/src/less/pouchdb/navs.less | 2 +- docs/static/js/stickyfill.min.js | 8 -------- 4 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 docs/static/js/stickyfill.min.js diff --git a/docs/_includes/default.html b/docs/_includes/default.html index 5177ac83c9..5965ba0196 100644 --- a/docs/_includes/default.html +++ b/docs/_includes/default.html @@ -216,13 +216,8 @@ -