eleventy-plugin-mdlite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git ls-tree:*)",
5
+ "mcp__plugin_context7_context7__resolve-library-id",
6
+ "mcp__plugin_context7_context7__query-docs",
7
+ "Bash(npm install:*)",
8
+ "Bash(npm test:*)",
9
+ "mcp__plugin_context-mode_context-mode__fetch_and_index",
10
+ "mcp__plugin_context-mode_context-mode__search"
11
+ ]
12
+ }
13
+ }
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Antithesis Operations LLC
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # eleventy-plugin-mdlite
2
+
3
+ Eleventy plugin that copies raw markdown files to your output directory and generates a SQLite index of all pages.
4
+
5
+ ## Features
6
+
7
+ - **Raw markdown output** — copies your `.md` source files alongside the rendered HTML so they're accessible at clean URLs (e.g. `/docs/foo.md`)
8
+ - **SQLite index** — generates a `sqlite.db` with FTS5 full-text search containing every page's URL, title, tags, and content
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ npm install eleventy-plugin-mdlite
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ In your Eleventy config file (e.g. `eleventy.config.js`):
19
+
20
+ ```js
21
+ import mdlitePlugin from "eleventy-plugin-mdlite";
22
+
23
+ export default function (eleventyConfig) {
24
+ eleventyConfig.addPlugin(mdlitePlugin);
25
+ }
26
+ ```
27
+
28
+ ### Options
29
+
30
+ | Option | Default | Description |
31
+ | ------------ | ------------- | ---------------------------------------------------------------------------- |
32
+ | `dbFilename` | `"sqlite.db"` | Name of the SQLite database file written to the output directory |
33
+ | `pathPrefix` | `"/"` | Only index pages whose URL starts with this prefix; database is placed there |
34
+
35
+ ```js
36
+ eleventyConfig.addPlugin(mdlitePlugin, {
37
+ dbFilename: "index.db",
38
+ pathPrefix: "/docs",
39
+ });
40
+ ```
41
+
42
+ ## SQLite Schema
43
+
44
+ The generated database contains a `pages` table and a `pages_fts` FTS5 virtual table for full-text search:
45
+
46
+ | Column | Type | Description |
47
+ | --------- | ------------------ | ---------------------------- |
48
+ | `path` | `TEXT PRIMARY KEY` | Page URL (e.g. `/docs/foo/`) |
49
+ | `title` | `TEXT` | Title from frontmatter |
50
+ | `tags` | `TEXT` | JSON array of tags, or null |
51
+ | `content` | `TEXT NOT NULL` | Raw markdown source |
52
+
53
+ ## Requirements
54
+
55
+ - Eleventy 3.x (`@11ty/eleventy ^3.0.0`)
56
+ - Node.js with ESM support
57
+
58
+ ## License
59
+
60
+ ISC
package/index.js ADDED
@@ -0,0 +1,101 @@
1
+ import { readFile, writeFile, mkdir, rm } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import Database from "better-sqlite3";
4
+
5
+ function createSchema(db) {
6
+ db.exec(`
7
+ CREATE TABLE pages (
8
+ path TEXT PRIMARY KEY,
9
+ title TEXT,
10
+ tags TEXT,
11
+ content TEXT NOT NULL
12
+ )
13
+ `);
14
+
15
+ // https://sqlite.org/fts5.html
16
+ db.exec(`
17
+ CREATE VIRTUAL TABLE pages_fts USING fts5(
18
+ title,
19
+ content,
20
+ content='pages',
21
+ content_rowid='rowid',
22
+ tokenize='porter unicode61',
23
+ prefix='2 3'
24
+ )
25
+ `);
26
+
27
+ db.exec(`
28
+ CREATE TRIGGER pages_ai AFTER INSERT ON pages BEGIN
29
+ INSERT INTO pages_fts(rowid, title, content)
30
+ VALUES (new.rowid, new.title, new.content);
31
+ END
32
+ `);
33
+ }
34
+
35
+ export default function mdlitePlugin(eleventyConfig, options = {}) {
36
+ const { dbFilename = "sqlite.db", pathPrefix = "/" } = options;
37
+ // Normalize to "/prefix/" form so startsWith() works on URLs.
38
+ // "docs", "/docs", "/docs/" all become "/docs/"; "/" stays as "/".
39
+ const normalizedPrefix =
40
+ pathPrefix === "/"
41
+ ? "/"
42
+ : "/" + pathPrefix.replace(/^\/|\/$/g, "") + "/";
43
+ const pageDataByInputPath = new Map();
44
+
45
+ eleventyConfig.addCollection("__mdlite_capture", (collectionApi) => {
46
+ for (const item of collectionApi.getAll()) {
47
+ pageDataByInputPath.set(item.inputPath, item.data);
48
+ }
49
+ return [];
50
+ });
51
+
52
+ eleventyConfig.on("eleventy.after", async ({ directories, results }) => {
53
+ const outputDir = directories.output;
54
+
55
+ // Filter to markdown inputs with valid output under pathPrefix
56
+ const mdResults = results.filter((r) => {
57
+ return (
58
+ r.inputPath.endsWith(".md") &&
59
+ r.outputPath &&
60
+ r.url.startsWith(normalizedPrefix)
61
+ );
62
+ });
63
+
64
+ const dbDir =
65
+ normalizedPrefix === "/"
66
+ ? outputDir
67
+ : join(outputDir, normalizedPrefix.slice(1, -1));
68
+ const dbPath = join(dbDir, dbFilename);
69
+ await mkdir(dbDir, { recursive: true });
70
+ await rm(dbPath, { force: true });
71
+
72
+ const db = new Database(dbPath);
73
+ createSchema(db);
74
+
75
+ const insert = db.prepare(
76
+ "INSERT INTO pages (path, title, tags, content) VALUES (?, ?, ?, ?)",
77
+ );
78
+
79
+ for (const result of mdResults) {
80
+ const data = pageDataByInputPath.get(result.inputPath) || {};
81
+ const raw = await readFile(result.inputPath, "utf8");
82
+ const tags = Array.isArray(data.tags) ? JSON.stringify(data.tags) : null;
83
+
84
+ // Copy raw markdown to output: /docs/foo/ → _site/docs/foo.md
85
+ let mdOutputPath;
86
+ if (result.url.endsWith("/")) {
87
+ const trimmed = result.url.slice(0, -1) || "/index";
88
+ mdOutputPath = join(outputDir, trimmed + ".md");
89
+ } else {
90
+ mdOutputPath = join(outputDir, result.url + ".md");
91
+ }
92
+ await mkdir(dirname(mdOutputPath), { recursive: true });
93
+ await writeFile(mdOutputPath, raw);
94
+
95
+ insert.run(result.url, data.title ?? null, tags, raw);
96
+ }
97
+
98
+ db.exec("VACUUM");
99
+ db.close();
100
+ });
101
+ }
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "eleventy-plugin-mdlite",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Eleventy plugin that copies raw markdown to output and generates a SQLite index",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "node --test test/plugin.test.js"
9
+ },
10
+ "dependencies": {
11
+ "better-sqlite3": "^11.0.0"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "peerDependencies": {
15
+ "@11ty/eleventy": "^3.0.0"
16
+ }
17
+ }
@@ -0,0 +1,5 @@
1
+ import mdlitePlugin from "../../index.js";
2
+
3
+ export default function (eleventyConfig) {
4
+ eleventyConfig.addPlugin(mdlitePlugin);
5
+ }
@@ -0,0 +1,5 @@
1
+ import mdlitePlugin from "../../index.js";
2
+
3
+ export default function (eleventyConfig) {
4
+ eleventyConfig.addPlugin(mdlitePlugin, { pathPrefix: "docs" });
5
+ }
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Draft Post
3
+ layout: false
4
+ draft: true
5
+ ---
6
+
7
+ # Draft
8
+
9
+ This is a draft post.
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Foo
3
+ layout: false
4
+ tags: docs
5
+ ---
6
+
7
+ # Foo
8
+
9
+ This is the foo page with some **bold** text.
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Home
3
+ layout: false
4
+ ---
5
+
6
+ # Welcome
7
+
8
+ This is the home page.
@@ -0,0 +1,181 @@
1
+ import { describe, it, before, after } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFile, rm, access, stat } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+ import Eleventy from "@11ty/eleventy";
6
+ import Database from "better-sqlite3";
7
+
8
+ const fixturesDir = new URL("./fixtures/", import.meta.url).pathname;
9
+ const inputDir = join(fixturesDir, "src");
10
+ const outputDir = join(fixturesDir, "_site");
11
+
12
+ describe("eleventy-plugin-mdlite", () => {
13
+ before(async () => {
14
+ await rm(outputDir, { recursive: true, force: true });
15
+
16
+ const elev = new Eleventy(inputDir, outputDir, {
17
+ configPath: join(fixturesDir, "eleventy.config.js"),
18
+ quietMode: true,
19
+ });
20
+ await elev.write();
21
+ });
22
+
23
+ after(async () => {
24
+ await rm(outputDir, { recursive: true, force: true });
25
+ });
26
+
27
+ describe("markdown copy", () => {
28
+ it("copies index.md to output root", async () => {
29
+ const content = await readFile(join(outputDir, "index.md"), "utf8");
30
+ assert.ok(content.includes("# Welcome"));
31
+ });
32
+
33
+ it("copies nested markdown to correct path", async () => {
34
+ const content = await readFile(join(outputDir, "docs/foo.md"), "utf8");
35
+ assert.ok(content.includes("# Foo"));
36
+ });
37
+
38
+ it("preserves frontmatter in copied files", async () => {
39
+ const content = await readFile(join(outputDir, "docs/foo.md"), "utf8");
40
+ assert.ok(content.startsWith("---"));
41
+ assert.ok(content.includes("title: Foo"));
42
+ });
43
+ });
44
+
45
+ describe("sqlite database", () => {
46
+ let db;
47
+
48
+ before(() => {
49
+ db = new Database(join(outputDir, "sqlite.db"), { readonly: true });
50
+ });
51
+
52
+ after(() => {
53
+ db.close();
54
+ });
55
+
56
+ it("creates sqlite.db in output", async () => {
57
+ await access(join(outputDir, "sqlite.db"));
58
+ });
59
+
60
+ it("has pages table with correct schema", () => {
61
+ const cols = db.pragma("table_info(pages)").map((c) => c.name);
62
+ assert.deepEqual(cols, ["path", "title", "tags", "content"]);
63
+ });
64
+
65
+ it("contains expected page rows", () => {
66
+ const rows = db.prepare("SELECT path FROM pages ORDER BY path").all();
67
+ const paths = rows.map((r) => r.path);
68
+ assert.ok(paths.includes("/"));
69
+ assert.ok(paths.includes("/docs/foo/"));
70
+ });
71
+
72
+ it("stores full raw markdown including frontmatter", () => {
73
+ const row = db
74
+ .prepare("SELECT content FROM pages WHERE path = ?")
75
+ .get("/");
76
+ assert.ok(row.content.includes("# Welcome"));
77
+ assert.ok(row.content.includes("---"));
78
+ assert.ok(row.content.includes("title: Home"));
79
+ });
80
+
81
+ it("stores tags as JSON array", () => {
82
+ const row = db
83
+ .prepare("SELECT tags FROM pages WHERE path = ?")
84
+ .get("/docs/foo/");
85
+ assert.deepEqual(JSON.parse(row.tags), ["docs"]);
86
+ });
87
+
88
+ it("stores null tags when page has no tags", () => {
89
+ const row = db.prepare("SELECT tags FROM pages WHERE path = ?").get("/");
90
+ assert.equal(row.tags, null);
91
+ });
92
+
93
+ it("supports full-text search", () => {
94
+ const rows = db
95
+ .prepare(
96
+ "SELECT p.path FROM pages p JOIN pages_fts f ON p.rowid = f.rowid WHERE pages_fts MATCH ? ORDER BY rank",
97
+ )
98
+ .all("Welcome");
99
+ assert.ok(rows.some((r) => r.path === "/"));
100
+ });
101
+
102
+ it("supports porter stemming", () => {
103
+ // "Welcomed" should match content containing "Welcome" via stemming
104
+ const rows = db
105
+ .prepare(
106
+ "SELECT p.path FROM pages p JOIN pages_fts f ON p.rowid = f.rowid WHERE pages_fts MATCH ?",
107
+ )
108
+ .all("Welcomed");
109
+ assert.ok(rows.some((r) => r.path === "/"));
110
+ });
111
+
112
+ it("supports prefix queries", () => {
113
+ const rows = db
114
+ .prepare(
115
+ "SELECT p.path FROM pages p JOIN pages_fts f ON p.rowid = f.rowid WHERE pages_fts MATCH ?",
116
+ )
117
+ .all("Wel*");
118
+ assert.ok(rows.some((r) => r.path === "/"));
119
+ });
120
+ });
121
+ });
122
+
123
+ describe("eleventy-plugin-mdlite with pathPrefix", () => {
124
+ const prefixedOutputDir = join(fixturesDir, "_site_prefixed");
125
+
126
+ before(async () => {
127
+ await rm(prefixedOutputDir, { recursive: true, force: true });
128
+
129
+ const elev = new Eleventy(inputDir, prefixedOutputDir, {
130
+ configPath: join(fixturesDir, "eleventy.config.prefixed.js"),
131
+ quietMode: true,
132
+ });
133
+ await elev.write();
134
+ });
135
+
136
+ after(async () => {
137
+ await rm(prefixedOutputDir, { recursive: true, force: true });
138
+ });
139
+
140
+ it("places sqlite.db inside the prefixed subdirectory", async () => {
141
+ await access(join(prefixedOutputDir, "docs", "sqlite.db"));
142
+ });
143
+
144
+ it("does not place sqlite.db in the output root", async () => {
145
+ await assert.rejects(access(join(prefixedOutputDir, "sqlite.db")));
146
+ });
147
+
148
+ describe("sqlite database", () => {
149
+ let db;
150
+
151
+ before(() => {
152
+ db = new Database(join(prefixedOutputDir, "docs", "sqlite.db"), {
153
+ readonly: true,
154
+ });
155
+ });
156
+
157
+ after(() => {
158
+ db.close();
159
+ });
160
+
161
+ it("only contains pages under the prefix", () => {
162
+ const rows = db.prepare("SELECT path FROM pages ORDER BY path").all();
163
+ const paths = rows.map((r) => r.path);
164
+ assert.ok(paths.includes("/docs/foo/"));
165
+ assert.ok(!paths.includes("/"), "root page should be excluded");
166
+ });
167
+
168
+ it("does not copy markdown files outside the prefix", async () => {
169
+ // index.md at root should still exist (eleventy writes it) but
170
+ // the plugin should not have indexed it
171
+ const rows = db.prepare("SELECT COUNT(*) as count FROM pages").get();
172
+ // only docs/foo and docs/draft-post
173
+ for (const r of db.prepare("SELECT path FROM pages").all()) {
174
+ assert.ok(
175
+ r.path.startsWith("/docs/"),
176
+ `${r.path} should start with /docs/`,
177
+ );
178
+ }
179
+ });
180
+ });
181
+ });