Skip to content

Commit a23cdc4

Browse files
authored
Merge pull request #166 from jaredwray/adding-in-testing-for-mega-site
mega site update
2 parents ef42ae9 + 32f6023 commit a23cdc4

28 files changed

+143
-26
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docula",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Beautiful Website for Your Projects",
55
"type": "module",
66
"exports": "./dist/index.js",
@@ -31,6 +31,7 @@
3131
"clean": "rimraf ./dist ./coverage ./node_modules ./package-lock.json ./yarn.lock ./pnpm-lock.yaml ./site/README.md ./site-output",
3232
"build": "rimraf ./dist && tsc",
3333
"build-site": "rimraf ./site/README.md && node bin/docula.mjs build -s ./site -o ./site-output",
34+
"serve-mega": "rimraf ./test/fixtures/mega-page-site/site-output && node bin/docula.mjs serve -s ./test/fixtures/mega-page-site",
3435
"test": "xo --fix && vitest run --coverage",
3536
"serve": "rimraf ./site/README.md && node bin/docula.mjs serve -s ./site -o ./site-output",
3637
"prepare": "npm run build"

src/builder.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ export class DoculaBuilder {
257257
const sitemapPath = `${data.outputPath}/sitemap.xml`;
258258
const urls = [{url: data.siteUrl}, {url: `${data.siteUrl}/releases`}];
259259

260+
// Add all the document urls
261+
for (const document of data.documents ?? []) {
262+
let {urlPath} = document;
263+
if (urlPath.endsWith('index.html')) {
264+
urlPath = urlPath.slice(0, -10);
265+
}
266+
267+
urls.push({url: `${data.siteUrl}${urlPath}`});
268+
}
269+
260270
let xml = '<?xml version="1.0" encoding="UTF-8"?>';
261271
xml += '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
262272

@@ -488,8 +498,15 @@ export class DoculaBuilder {
488498
const matterData = matter.default(documentContent);
489499
const markdownContent = this.removeFrontmatter(documentContent);
490500
const documentsFolderIndex = documentPath.lastIndexOf('/docs/');
491-
const urlPath = documentPath.slice(documentsFolderIndex).replace('.md', '.html');
492-
const isRoot = urlPath.split('/').length === 3;
501+
let urlPath = documentPath.slice(documentsFolderIndex).replace('.md', '/index.html');
502+
let isRoot = urlPath.split('/').length === 3;
503+
if (!documentPath.slice(documentsFolderIndex + 6).includes('/')) {
504+
isRoot = true;
505+
const filePath = documentPath.slice(documentsFolderIndex + 6);
506+
if (filePath === 'index.md') {
507+
urlPath = documentPath.slice(documentsFolderIndex).replace('.md', '.html');
508+
}
509+
}
493510

494511
return {
495512
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

test/builder.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ describe('DoculaBuilder', () => {
413413
const builder = new DoculaBuilder();
414414
const documentsPath = 'test/fixtures/mega-page-site/docs';
415415
const documents = builder.getDocumentInDirectory(documentsPath);
416-
expect(documents.length).toBe(2);
416+
expect(documents.length).toBe(3);
417417
});
418418
it('should get all the documents from the mega fixtures', () => {
419419
const builder = new DoculaBuilder();
@@ -427,7 +427,7 @@ describe('DoculaBuilder', () => {
427427
};
428428
const documentsPath = 'test/fixtures/mega-page-site/docs';
429429
const documents = builder.getDocuments(documentsPath, doculaData);
430-
expect(documents.length).toBe(20);
430+
expect(documents.length).toBe(21);
431431
});
432432
});
433433

test/fixtures/mega-page-site/docs/caching/caching-express.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: 'Utilizing Keyv for Caching in Express: A Step-by-Step Guide'
3-
navTitle: 'Caching with Express'
2+
title: 'How to Implement Caching with Express'
3+
sidebarTitle: 'Caching with Express'
4+
parent: 'Caching'
45
---
56

6-
# Utilizing Keyv for Caching in Express: A Step-by-Step Guide
7+
# How to Implement Caching with Express
78

89
## What is Express?
910
Express is a minimal Node.js web application framework. Its APIs provide web and mobile application functionality. Its simplicity enables users to quickly create a robust API in a familiar environment with enhanced features, including Robust routing, high performance, HTTP helpers, support for 14+ view template engines, content negotiation, and an executable for generating applications quickly.

test/fixtures/mega-page-site/docs/caching/caching-fastify.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: 'Utilizing Keyv for Caching in Fastify: A Step-by-Step Guide'
3-
navTitle: 'Caching with Fastify'
4-
section: 'caching'
2+
title: 'How to Implement Caching with Fastify'
3+
sidebarTitle: 'Caching with Fastify'
4+
parent: 'Caching'
55
---
66

7-
# Utilizing Keyv for Caching in Fastify: A Step-by-Step Guide
7+
# How to Implement Caching with Fastify
88

99
## What is Fastify?
1010
Fastify is a web framework that provides a powerful plugin-based developer experience (inspired by Hapi and Express) with minimal overhead and is one of the fastest frameworks available, serving up to 30k requests per second. It is fully extensible via hooks, plugins, and decorators. Being schema-based, Fastify compiles schemas very efficiently. A TypeScript type declaration file is also maintained to support the growing TypeScript community.

test/fixtures/mega-page-site/docs/caching/caching-javascript.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: 'Utilizing Keyv for Caching in Javascript: A Step-by-Step Guide'
3-
navTitle: 'Caching in Javascript'
2+
title: 'How to Implement Caching in Javascript'
3+
sidebarTitle: 'Caching in Javascript'
4+
parent: 'Caching'
45
---
56

6-
# Utilizing Keyv for Caching in Javascript: A Step-by-Step Guide
7+
# How to Implement Caching in Javascript
78

89
## What is a Cache?
910
A cache is a short-term, high-speed data storage layer that stores a subset of data, enabling it to be retrieved faster than accessing it from its primary storage location. Caching allows you to reuse previously retrieved data efficiently.

test/fixtures/mega-page-site/docs/caching/caching-koa.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: 'Utilizing Keyv for Caching in Koa: A Step-by-Step Guide'
3-
navTitle: 'Caching with Koa'
2+
title: 'How to Implement Caching with Koa'
3+
sidebarTitle: 'Caching with Koa'
4+
parent: 'Caching'
45
---
56

6-
# Utilizing Keyv for Caching in Koa: A Step-by-Step Guide
7+
# How to Implement Caching with Koa
78

89
## What is Koa?
910
Koa is a web framework from the team behind Express that offers a smaller, more expressive, more robust foundation for APIs and web applications. Koa's use of async functions removes the need for callbacks and increases error handling. A Koa Context combines a node request and response object into a single object providing numerous helpful methods for writing APIs and web apps.

test/fixtures/mega-page-site/docs/caching/caching-nestjs.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 'Utilizing Keyv for Caching in NestJS: A Step-by-Step Guide'
3-
navTitle: 'Caching in Nest.js'
3+
sidebarTitle: 'Caching in Nest.js'
4+
parent: 'Caching'
45
---
56

67
# Utilizing Keyv for Caching in NestJS: A Step-by-Step Guide

test/fixtures/mega-page-site/docs/caching/caching-node.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 'Utilizing Keyv for Caching in Node.js: A Step-by-Step Guide'
3-
navTitle: 'Caching in Node.js'
3+
sidebarTitle: 'Caching in Node.js'
4+
parent: 'Caching'
45
---
56

67
# Utilizing Keyv for Caching in Node.js: A Step-by-Step Guide

test/fixtures/mega-page-site/docs/compression/compress-brotli.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/compress-brotli'
3+
sidebarTitle: '@keyv/compress-brotli'
4+
parent: 'Compression'
35
---
46

57
# @keyv/compress-brotli

test/fixtures/mega-page-site/docs/compression/compress-gzip.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/compress-gzip'
3+
sidebarTitle: '@keyv/compress-gzip'
4+
parent: 'Compression'
35
---
46

57
# @keyv/compress-gzip

test/fixtures/mega-page-site/docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'Getting Started Guide'
3-
order: 0
3+
order: 1
44
---
55

66
# Getting Started Guide

test/fixtures/mega-page-site/docs/keyv.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
title: 'Keyv API'
3-
order: 1
3+
order: 2
44
---
55

6+
7+
68
> Simple key-value storage with support for multiple backends
79
810
[![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)

test/fixtures/mega-page-site/docs/storage-adapters/etcd.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/etcd'
3+
sidebarTitle: '@keyv/etcd'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/etcd

test/fixtures/mega-page-site/docs/storage-adapters/memcache.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/memcache'
3+
sidebarTitle: '@keyv/memcache'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/memcache

test/fixtures/mega-page-site/docs/storage-adapters/mongo.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/mongo'
3+
sidebarTitle: '@keyv/mongo'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/mongo

test/fixtures/mega-page-site/docs/storage-adapters/mysql.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/mysql'
3+
sidebarTitle: '@keyv/mysql'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/mysql

test/fixtures/mega-page-site/docs/storage-adapters/offline.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/offline'
3+
sidebarTitle: '@keyv/offline'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/offline

test/fixtures/mega-page-site/docs/storage-adapters/postgres.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/postgres'
3+
sidebarTitle: '@keyv/postgres'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/postgres

test/fixtures/mega-page-site/docs/storage-adapters/redis.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/redis'
3+
sidebarTitle: '@keyv/redis'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/redis

test/fixtures/mega-page-site/docs/storage-adapters/serialize.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/serialize'
3+
sidebarTitle: '@keyv/serialize'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/serialize

test/fixtures/mega-page-site/docs/storage-adapters/sqlite.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/sqlite'
3+
sidebarTitle: '@keyv/sqlite'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/sqlite

test/fixtures/mega-page-site/docs/storage-adapters/tiered.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: '@keyv/tiered'
3+
sidebarTitle: '@keyv/tiered'
4+
parent: 'Storage Adapters'
35
---
46

57
# @keyv/tiered
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: 'Test Suite'
3+
permalink: /docs/test-suite/
4+
order: 6
5+
---
6+
7+
# @keyv/test-suite
8+
9+
> Test suite for Keyv API compliance
10+
11+
[![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
12+
[![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
13+
[![npm](https://img.shields.io/npm/v/@keyv/test-suite.svg)](https://www.npmjs.com/package/@keyv/test-suite)
14+
[![npm](https://img.shields.io/npm/dm/@keyv/test-suite)](https://npmjs.com/package/@keyv/test-suite)
15+
16+
Complete [AVA](https://github.com/avajs/ava) test suite to test a [Keyv](https://github.com/jaredwray/keyv) storage adapter for API compliance.
17+
18+
## Usage
19+
20+
### Install
21+
22+
Install AVA, Keyv and `@keyv/test-suite` as development dependencies.
23+
24+
```shell
25+
npm install --save-dev ava keyv @keyv/test-suite
26+
```
27+
28+
Then update `keyv` and `@keyv/test-suite` versions to `*` in `package.json` to ensure you're always testing against the latest version.
29+
30+
### Create Test File
31+
32+
`test.js`
33+
34+
```js
35+
import test from 'ava';
36+
import keyvTestSuite from '@keyv/test-suite';
37+
import Keyv from 'keyv';
38+
import KeyvStore from './';
39+
40+
const store = () => new KeyvStore();
41+
keyvTestSuite(test, Keyv, store);
42+
```
43+
44+
Where `KeyvStore` is your storage adapter.
45+
46+
Set your test script in `package.json` to `ava`.
47+
```json
48+
"scripts": {
49+
"test": "ava"
50+
}
51+
```
52+
53+
## Example for Storage Adapters
54+
55+
Take a look at [keyv-redis](https://github.com/jaredwray/keyv-redis) for an example of an existing storage adapter using `@keyv/test-suite`.
56+
57+
## Testing Compression Adapters
58+
59+
If you're testing a compression adapter, you can use the `keyvCompresstionTests` method instead of `keyvTestSuite`.
60+
61+
```js
62+
const {keyvCompresstionTests} = require('@keyv/test-suite');
63+
const KeyvGzip = require('@keyv/compress-gzip');
64+
65+
keyvCompresstionTests(test, new KeyvGzip());
66+
```
67+
68+
## License
69+
70+
MIT © Jared Wray

test/fixtures/mega-page-site/docula.config.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module.exports.options = {
77
siteDescription: 'Beautiful Website for Your Projects',
88
siteUrl: 'https://docula.org',
99
sections: [
10-
{ name: 'Caching', path: 'caching', order: 1 },
11-
{ name: 'Compression', path: 'compression', order: 2 },
10+
{ name: 'Caching', path: 'caching', order: 5 },
11+
{ name: 'Compression', path: 'compression', order: 4 },
1212
{ name: 'Storage Adapters', path: 'storage-adapters', order: 3 },
1313
],
1414
};

test/fixtures/mega-page-site/logo.png

-10.2 KB
Binary file not shown.
-4.52 KB
Binary file not shown.

test/fixtures/mega-page-site/robots.txt

-2
This file was deleted.

0 commit comments

Comments
 (0)