-
-
Notifications
You must be signed in to change notification settings - Fork 70
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 (#72)
- Loading branch information
1 parent
b848f84
commit 0f1cda1
Showing
31 changed files
with
1,504 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI - Docs | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
ci-docs: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: packages/docs | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
corepack: true | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm i | ||
working-directory: ./ | ||
|
||
- name: Build the lib | ||
run: pnpm build |
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,4 @@ | ||
export const config = { | ||
baseApiUrl: import.meta.env.VITE_BASE_API_URL ?? window.location.origin, | ||
documentationBaseUrl: import.meta.env.VITE_DOCUMENTATION_BASE_URL ?? 'https://docs.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,41 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { buildDocUrl, joinUrlParts } from './docs.models'; | ||
|
||
describe('docs models', () => { | ||
describe('buildDocUrl', () => { | ||
test('it creates a url to the documentation', () => { | ||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
|
||
baseUrl: 'https://docs.enclosed.cc', | ||
}), | ||
).to.eql('https://docs.enclosed.cc/test'); | ||
}); | ||
|
||
test('it uses the default base url', () => { | ||
expect(buildDocUrl({ path: '/test' })).to.eql('https://docs.enclosed.cc/test'); | ||
}); | ||
|
||
test('it handles clashing slashes', () => { | ||
expect( | ||
buildDocUrl({ | ||
path: '/test', | ||
baseUrl: 'https://docs.enclosed.cc/', | ||
}), | ||
).to.eql('https://docs.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,19 @@ | ||
import { config } from '../config/config'; | ||
|
||
export { buildDocUrl, joinUrlParts }; | ||
|
||
function joinUrlParts(...parts: string[]): string { | ||
return parts.map(part => part.replace(/(^\/|\/$)/g, '')).join('/'); | ||
} | ||
|
||
function buildDocUrl({ | ||
path, | ||
baseUrl = config.documentationBaseUrl, | ||
}: { | ||
path: string; | ||
baseUrl?: string; | ||
}): string { | ||
const url = joinUrlParts(baseUrl, path); | ||
|
||
return url; | ||
} |
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,135 @@ | ||
import { defineConfig } from 'vitepress'; | ||
import { getPlausibleScripts } from './plausible'; | ||
|
||
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: [ | ||
['meta', { name: 'author', content: 'Corentin Thomasset' }], | ||
['meta', { name: 'keywords', content: 'Enclosed, notes, secure, private, encrypted, self-hosted' }], | ||
['link', { rel: 'icon', href: '/favicon.ico' }], | ||
['link', { rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }], | ||
['link', {rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png'}], | ||
['link', {rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png'}], | ||
|
||
['meta', {name: 'theme-color', content: '#ffffff'}], | ||
|
||
|
||
|
||
['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')}], | ||
|
||
...getPlausibleScripts(), | ||
], | ||
|
||
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,17 @@ | ||
import { HeadConfig } from "vitepress"; | ||
|
||
const isPlausibleEnabled = process.env.VITE_IS_PLAUSIBLE_ENABLED === 'true'; | ||
const plausibleDomain = String(process.env.VITE_PLAUSIBLE_DOMAIN); | ||
const plausibleScriptSrc = String(process.env.VITE_PLAUSIBLE_SCRIPT_SRC); | ||
|
||
export { getPlausibleScripts }; | ||
|
||
function getPlausibleScripts(): HeadConfig[] { | ||
if (!isPlausibleEnabled || !plausibleDomain) { | ||
return []; | ||
} | ||
|
||
return [ | ||
['script', { async: '', defer: '', 'data-domain': plausibleDomain, src: plausibleScriptSrc }], | ||
]; | ||
} |
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 |
Oops, something went wrong.