mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-05 10:28:52 +00:00
feat(documentation): svelte app as document generator (#566)
* check in full site application * rm unused assets components * change base css * i18n * new doc workflow * fix crosslink to doc in github * nav, console link, assets, console brand * edit configjs server * rm go struct references * cleanup input output bindings * working dir * export path * always trigger * rel paths * cname * rev workdir * fix fallbacklanguage, home on large screens * remove mit from site
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import send from '@polka/send';
|
||||
import { locale } from 'svelte-i18n';
|
||||
|
||||
import { LANGUAGES } from '../../config.js';
|
||||
import { INIT_OPTIONS } from '../i18n.js';
|
||||
import generate_docs from '../utils/generate_docs.js';
|
||||
|
||||
let json;
|
||||
|
||||
export function get(req, res) {
|
||||
if (!json || process.env.NODE_ENV !== 'production') {
|
||||
const { slug } = req.params;
|
||||
locale.subscribe(localecode => {
|
||||
console.log('sublocale: ' + localecode, LANGUAGES);
|
||||
if (!LANGUAGES.includes(localecode)) {
|
||||
console.log(INIT_OPTIONS);
|
||||
localecode = INIT_OPTIONS.initialLocale || 'en';
|
||||
}
|
||||
json = JSON.stringify(generate_docs('docs/', slug, localecode)); // TODO it errors if I send the non-stringified value
|
||||
});
|
||||
}
|
||||
|
||||
send(res, 200, json, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<script context="module">
|
||||
export async function preload({params}) {
|
||||
const {lang, slug} = params;
|
||||
const sections = await this.fetch(`${slug}.json`).then(r => r.json());
|
||||
const tags = [];
|
||||
return { sections, slug, tags };
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import manifest from '../../static/manifest.json';
|
||||
import Docs from "../components/Docs.svelte";
|
||||
export let slug;
|
||||
export let sections;
|
||||
export let tags;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{manifest.name} • {slug}</title>
|
||||
|
||||
{#each tags as { name, content }, i}
|
||||
<meta name={name} content={content} />
|
||||
{/each}
|
||||
</svelte:head>
|
||||
|
||||
<Docs {sections} project="zitadel/site" dir="{slug}"/>
|
||||
@@ -0,0 +1,71 @@
|
||||
<script>
|
||||
const dev = process.env.NODE_ENV === 'development';
|
||||
|
||||
export let status;
|
||||
export let error;
|
||||
|
||||
// we don't want to use <svelte:window bind:online> here,
|
||||
// because we only care about the online state when
|
||||
// the page first loads
|
||||
let online = typeof navigator !== 'undefined'
|
||||
? navigator.onLine
|
||||
: true;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
padding: var(--top-offset) var(--side-nav) 6rem var(--side-nav);
|
||||
}
|
||||
|
||||
h1, p { margin: 0 auto }
|
||||
|
||||
h1 {
|
||||
font-size: 2.8em;
|
||||
font-weight: 300;
|
||||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
|
||||
p { margin: 1em auto }
|
||||
|
||||
.error {
|
||||
background-color: #da106e;
|
||||
color: white;
|
||||
padding: 12px 16px;
|
||||
font: 600 16px/1.7 var(--font);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* @media (min-width: 480px) {
|
||||
h1 { font-size: 4em }
|
||||
} */
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>{status}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="container">
|
||||
{#if online}
|
||||
<h1>Yikes!</h1>
|
||||
|
||||
{#if error.message}
|
||||
<p class="error">{status}: {error.message}</p>
|
||||
{:else}
|
||||
<p class="error">Encountered a {status} error</p>
|
||||
{/if}
|
||||
|
||||
{#if dev && error.stack}
|
||||
<pre>{error.stack}</pre>
|
||||
{:else}
|
||||
{#if status >= 500}
|
||||
<p>Please try reloading the page.</p>
|
||||
{/if}
|
||||
|
||||
<p>If the error persists, let us know or raise an issue on <a href="https://github.com/caos/site">GitHub</a>. Thanks!</p>
|
||||
{/if}
|
||||
{:else}
|
||||
<h1>It looks like you're offline</h1>
|
||||
|
||||
<p>Reload the page once you've found the internet.</p>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script>
|
||||
import { stores } from "@sapper/app";
|
||||
import Icon from "../components/Icon.svelte";
|
||||
import Nav from "../components/Nav.svelte";
|
||||
import NavItem from "../components/NavItem.svelte";
|
||||
import manifest from '../../static/manifest.json';
|
||||
|
||||
export let segment;
|
||||
const { page } = stores();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
main {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
padding: var(--nav-h) 0 0 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<Nav {segment} title="{manifest.name}" logo="logos/zitadel-logo-oneline-darkdesign.svg"></Nav>
|
||||
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script context="module">
|
||||
export async function preload(page, session) {
|
||||
const {params} = page;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import Split from "../components/Split.svelte";
|
||||
import Section from '../components/Section.svelte';
|
||||
import { _ } from 'svelte-i18n';
|
||||
</script>
|
||||
|
||||
<style>
|
||||
h2 {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.caos-back {
|
||||
position: absolute;
|
||||
top: 80px;
|
||||
height: 60vh;
|
||||
right: 0;
|
||||
}
|
||||
.section {
|
||||
width: 100%;
|
||||
margin-top: 70vh;
|
||||
min-height: 80vh;
|
||||
}
|
||||
@media screen and (min-width: 768px) {
|
||||
.caos-back {
|
||||
right: 0;
|
||||
height: 70vh;
|
||||
}
|
||||
.section {
|
||||
width: 50%;
|
||||
margin-top: 50px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>
|
||||
Caos • Documentation
|
||||
</title>
|
||||
</svelte:head>
|
||||
|
||||
<img class="caos-back" src="logos/zitadel-logo-solo-darkdesign.svg" alt="caos logo">
|
||||
|
||||
<Section>
|
||||
<div class="section">
|
||||
<h2>{$_('title')}</h2>
|
||||
<p>{$_('description')}</p>
|
||||
<p>{$_('description2')}</p>
|
||||
<p>{$_('description3')}</p>
|
||||
|
||||
<a href="/get_started" >{$_('button')}</a>
|
||||
</div>
|
||||
</Section>
|
||||
Reference in New Issue
Block a user