-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): added documentation website
- Loading branch information
1 parent
b848f84
commit 178747e
Showing
24 changed files
with
1,478 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ logs | |
!.env.example | ||
|
||
.wrangler | ||
coverage | ||
coverage | ||
cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
VITE_BASE_API_URL=http://localhost:8787 | ||
VITE_BASE_API_URL=http://localhost:8787 | ||
VITE_FALLBACK_DOCUMENTATION_URL=http://localhost:3001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ gitignore | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
User-agent: * | ||
Disallow: / | ||
Allow: /$ | ||
Allow: /og-image.png | ||
Allow: /og-image.png | ||
Allow: /docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const config = { | ||
baseApiUrl: import.meta.env.VITE_BASE_API_URL ?? window.location.origin, | ||
isBundledWithDocumentation: import.meta.env.VITE_IS_BUNDLED_WITH_DOCUMENTATION === 'true', | ||
fallbackDocumentationUrl: import.meta.env.VITE_FALLBACK_DOCUMENTATION_URL ?? 'https://enclosed.cc', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { buildDocUrl, joinUrlParts } from './docs.models'; | ||
|
||
describe('docs models', () => { | ||
describe('buildDocUrl', () => { | ||
test('if the app is bundled with documentation, we use the same origin', () => { | ||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
isBundledWithDocumentation: true, | ||
currentOrigin: 'http://localhost', | ||
fallbackDocumentationUrl: 'https://enclosed.cc/', | ||
}), | ||
).to.eql('http://localhost/docs/test'); | ||
}); | ||
|
||
test('if the app is not bundled with documentation, we use the fallback URL', () => { | ||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
isBundledWithDocumentation: false, | ||
currentOrigin: 'http://localhost', | ||
fallbackDocumentationUrl: 'https://enclosed.cc/', | ||
}), | ||
).to.eql('https://enclosed.cc/test'); | ||
|
||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
isBundledWithDocumentation: false, | ||
currentOrigin: 'http://localhost', | ||
fallbackDocumentationUrl: 'https://enclosed.cc/docs', | ||
}), | ||
).to.eql('https://enclosed.cc/docs/test'); | ||
}); | ||
|
||
test('with resilience to trailing slashes', () => { | ||
expect( | ||
buildDocUrl({ | ||
path: 'test', | ||
isBundledWithDocumentation: false, | ||
currentOrigin: 'http://localhost', | ||
fallbackDocumentationUrl: 'https://enclosed.cc/', | ||
}), | ||
).to.eql('https://enclosed.cc/test'); | ||
|
||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
isBundledWithDocumentation: false, | ||
currentOrigin: 'http://localhost', | ||
fallbackDocumentationUrl: 'https://enclosed.cc/', | ||
}), | ||
).to.eql('https://enclosed.cc/test'); | ||
}); | ||
}); | ||
|
||
describe('joinUrlParts', () => { | ||
test('it merges url parts and trim slashes', () => { | ||
expect(joinUrlParts('/part1/', '/part2/', 'part3', 'part4/')).to.eql('part1/part2/part3/part4'); | ||
expect(joinUrlParts('/part1/part2/', 'part3', 'part4/')).to.eql('part1/part2/part3/part4'); | ||
expect(joinUrlParts('')).to.eql(''); | ||
}); | ||
|
||
test('multiple slashes inside a part are preserved', () => { | ||
expect(joinUrlParts('/part1//part2/', '/part3/')).to.eql('part1//part2/part3'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { config } from '../config/config'; | ||
|
||
export { buildDocUrl, joinUrlParts }; | ||
|
||
function joinUrlParts(...parts: string[]): string { | ||
return parts.map(part => part.replace(/(^\/|\/$)/g, '')).join('/'); | ||
} | ||
|
||
function buildDocUrl({ | ||
path, | ||
currentOrigin = window.location.origin, | ||
isBundledWithDocumentation = config.isBundledWithDocumentation, | ||
fallbackDocumentationUrl = config.fallbackDocumentationUrl, | ||
}: { | ||
path: string; | ||
currentOrigin?: string; | ||
isBundledWithDocumentation?: boolean; | ||
fallbackDocumentationUrl?: string; | ||
}): string { | ||
const origin = isBundledWithDocumentation ? joinUrlParts(currentOrigin, 'docs') : fallbackDocumentationUrl; | ||
|
||
return joinUrlParts(origin, path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { defineConfig } from 'vitepress'; | ||
|
||
const basePath = process.env.DOCS_BASE_PATH; // undefined for root / | ||
|
||
const createAbsoluteUrl = (path: string) => 'https://enclosed.cc/' + path.replace(/(^\/$)/g, ''); | ||
|
||
// https://vitepress.dev/reference/site-config | ||
export default defineConfig({ | ||
title: 'Enclosed', | ||
description: 'Send private and secure notes', | ||
base: basePath, | ||
lang: 'en-US', | ||
lastUpdated: true, | ||
srcDir: './src', | ||
outDir: './dist', | ||
|
||
markdown: { | ||
theme: { | ||
dark: 'github-dark', | ||
light: 'github-light', | ||
}, | ||
}, | ||
|
||
head: [ | ||
['link', { rel: 'icon', href: '/favicon.ico' }], | ||
['meta', { name: 'author', content: 'Corentin Thomasset' }], | ||
['meta', { name: 'keywords', content: 'Enclosed, notes, secure, private, encrypted, self-hosted' }], | ||
|
||
['meta', {name: 'og:title', content: 'Enclosed documentation'}], | ||
['meta', {name: 'og:description', content: 'Send private and secure notes'}], | ||
['meta', {name: 'og:image', content: createAbsoluteUrl('og-image.png')}], | ||
['meta', {name: 'og:url', content: 'https://enclosed.cc'}], | ||
['meta', {name: 'og:type', content: 'website'}], | ||
['meta', {name: 'og:site_name', content: 'Enclosed'}], | ||
['meta', {name: 'og:locale', content: 'en_US'}], | ||
|
||
['meta', {name: 'twitter:card', content: 'summary'}], | ||
['meta', {name: 'twitter:site', content: '@cthmsst'}], | ||
['meta', {name: 'twitter:creator', content: '@cthmsst'}], | ||
['meta', {name: 'twitter:title', content: 'Enclosed documentation'}], | ||
['meta', {name: 'twitter:description', content: 'Send private and secure notes'}], | ||
['meta', {name: 'twitter:image', content: createAbsoluteUrl('og-image.png')}], | ||
], | ||
|
||
themeConfig: { | ||
|
||
logo: { | ||
light: '/logo-light.svg', | ||
dark: '/logo-dark.svg', | ||
alt: 'Logo', | ||
}, | ||
|
||
siteTitle: 'Enclosed - DOCS', | ||
|
||
// https://vitepress.dev/reference/default-theme-config | ||
nav: [ | ||
{ text: 'Enclosed App', link: 'https://enclosed.cc' }, | ||
], | ||
|
||
sidebar: [ | ||
{ | ||
text: 'Enclosed', | ||
items: [ | ||
{ text: 'Introduction', link: '/' }, | ||
{ text: 'How it works?', link: '/how-it-works' }, | ||
], | ||
}, | ||
{ | ||
text: 'Self hosting', | ||
items: [ | ||
{ text: 'Using Docker', link: '/self-hosting/docker' }, | ||
{ text: 'Using Docker Compose', link: '/self-hosting/docker-compose' }, | ||
{ text: 'Configuration', link: '/self-hosting/configuration' }, | ||
], | ||
}, | ||
{ | ||
text: 'Integrations', | ||
items: [ | ||
{ text: 'CLI', link: '/integrations/cli' }, | ||
{ text: 'NPM package', link: '/integrations/npm-package' }, | ||
] | ||
}, | ||
], | ||
|
||
|
||
footer: { | ||
copyright: 'Copyright © 2024-present Corentin Thomasset', | ||
}, | ||
|
||
editLink: { | ||
pattern: 'https://github.com/CorentinTh/enclosed/edit/main/packages/docs/src/:path', | ||
text: 'Edit this page on GitHub', | ||
}, | ||
|
||
socialLinks: [ | ||
{ icon: 'github', link: 'https://github.com/CorentinTh/enclosed', ariaLabel: 'GitHub' }, | ||
{ icon: 'twitter', link: 'https://twitter.com/cthmsst', ariaLabel: 'Twitter' }, | ||
], | ||
|
||
search: { | ||
provider: 'local', | ||
|
||
options: { | ||
detailedView: true, | ||
|
||
miniSearch: { | ||
/** | ||
* @type {Pick<import('minisearch').Options, 'extractField' | 'tokenize' | 'processTerm'>} | ||
*/ | ||
options: { | ||
}, | ||
/** | ||
* @type {import('minisearch').SearchOptions} | ||
*/ | ||
searchOptions: { | ||
fuzzy: 0.3, | ||
prefix: true, | ||
boost: { title: 4, text: 2, titles: 1 }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
:root { | ||
--vp-c-brand-1: #000000; | ||
--vp-c-brand-2: #000000; | ||
} | ||
|
||
.dark { | ||
--vp-c-brand-1: #ffffff; | ||
--vp-c-brand-2: #ffffff; | ||
|
||
--vp-c-text-1: rgba(255, 255, 245, 0.92); | ||
--vp-c-text-2: rgba(235, 235, 245, 0.6); | ||
--vp-c-text-3: rgba(235, 235, 245, 0.38); | ||
} | ||
|
||
|
||
.VPSocialLink span{ | ||
height: 18px !important; | ||
width: 18px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import DefaultTheme from 'vitepress/theme' | ||
import './custom.css' | ||
|
||
export default DefaultTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@enclosed/docs", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"packageManager": "pnpm@9.9.0", | ||
"description": "Documentation website for Enclosed.", | ||
"author": "Corentin Thomasset <corentinth@proton.me> (https://corentin.tech)", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/CorentinTh/enclosed" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "vitepress dev --port 3001", | ||
"build": "vitepress build", | ||
"preview": "vitepress preview" | ||
}, | ||
"keywords": [], | ||
"devDependencies": { | ||
"vitepress": "^1.3.4" | ||
} | ||
} |
Oops, something went wrong.