Files
zitadel/site/src/routes/[slug].json.js
Max Peintner 2c517d6278 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
2020-08-11 09:53:09 +02:00

27 lines
861 B
JavaScript

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'
});
}