const path = require('path');
const Prism = require('prismjs');
const loadLanguages = require('prismjs/components/');

loadLanguages(['php']);

require('dotenv').config({
    path: path.resolve(__dirname, '../../saturn/.env'),
});

const APP_NAME = process.env.APP_NAME || 'Sharp';
const APP_URL = process.env.APP_URL || 'https://sharp.code16.fr';
const DOCS_VERSION = process.env.DOCS_VERSION || '7.0';
const DOCS_MAIN_URL = process.env.DOCS_MAIN_URL || APP_URL;
const DOCS_HOME_URL = process.env.DOCS_MAIN_URL || '/';

module.exports = {
    title: APP_NAME,
    base: '/docs/',
    head: [
        ['link', { rel: 'icon', type:'image/png', href: '/favicon.png' }],
        ['link', { rel: 'icon', type:'image/svg+xml', href: '/favicon.svg' }],
    ],
    themeConfig: {
        nav: [
            process.env.DOCS_ENABLE_VERSIONING === 'true' && {
                text: DOCS_VERSION,
                items: JSON.parse(process.env.DOCS_VERSION_ITEMS || '[]')
                    .map(item => ({ ...item, target: '_self' })),
            },
            { text: 'Home', link: DOCS_HOME_URL, target: '_self' },
            { text: 'Documentation', link: '/guide/' },
            { text: 'Demo', link: `${DOCS_MAIN_URL}/sharp/` },
            { text: 'Github', link:'https://github.com/code16/sharp' },
            {
                text: 'Links',
                items: [
                    { text: 'Medium', link:'https://medium.com/code16/tagged/sharp' },
                    { text: 'Discord', link:'https://discord.com/invite/sFBT5c3XZz' },
                ]
            }
        ].filter(Boolean),
        sidebar: {
            '/guide/': [
                {
                    title: 'Introduction',
                    collapsable: false,
                    children: [
                        '',
                        'authentication',
                    ]
                },
                {
                    title: 'Entity Lists',
                    collapsable: false,
                    children: [
                        'building-entity-list',
                        'filters',
                        'commands',
                        'entity-states',
                        'reordering-instances',
                    ]
                },
                {
                    title: 'Entity Forms',
                    collapsable: false,
                    children: [
                        'building-entity-form',
                        'multiforms',
                        'single-form',
                        'custom-form-fields'
                    ]
                },
                {
                    title: 'Entity Shows',
                    collapsable: false,
                    children: [
                        'building-entity-show',
                        'single-show',
                        'custom-show-fields'
                    ]
                },
                {
                    title: 'Dashboards',
                    collapsable: false,
                    children: [
                        'dashboard',
                        ...[
                            'graph',
                            'panel',
                            'ordered-list',
                        ].map(page => `dashboard-widgets/${page}`),
                    ],
                },
                {
                    title: 'Generalities',
                    collapsable: false,
                    children: [
                        'building-menu',
                        'sharp-breadcrumb',
                        'entity-authorizations',
                        'how-to-transform-data',
                        'link-to',
                        'context',
                        'sharp-built-in-solution-for-uploads',
                        'form-data-localization',
                        'testing-with-sharp',
                        'artisan-generators',
                        'style-visual-theme'
                    ]
                },
                {
                    title: 'Form fields',
                    collapsable: false,
                    children: [
                        'text',
                        'textarea',
                        'markdown',
                        'wysiwyg',
                        'number',
                        'html',
                        'check',
                        'date',
                        'upload',
                        'select',
                        'autocomplete',
                        'tags',
                        'list',
                        'autocomplete-list',
                        'geolocation',
                    ].map(page => `form-fields/${page}`),
                },
                {
                    title: 'Show fields',
                    collapsable: false,
                    children: [
                        'text',
                        'picture',
                        'list',
                        'file',
                        'embedded-entity-list',
                    ].map(page => `show-fields/${page}`),
                },
                {
                    title: 'Migrations guide',
                    collapsable: false,
                    children: [
                        'upgrading/6.0',
                        'upgrading/5.0',
                        'upgrading/4.2',
                        'upgrading/4.1.3',
                        'upgrading/4.1',
                    ],
                },
            ]
        },
        algolia: {
            apiKey: 'd88cea985d718328d4b892ff6a05dba8',
            indexName: 'code16_sharp',
            // debug: true,
            algoliaOptions: {
                hitsPerPage: 5,
            },
        }
    },
    markdown: {
        extendMarkdown: md => {
            md.renderer.rules['code_inline'] = (tokens, idx, options, env, slf) => {
                let token = tokens[idx];
                return '<code class="inline">' +
                    Prism.highlight(token.content, Prism.languages.php) +
                '</code>';
            };
        }
    },
    scss: {
        implementation: require('sass'),
    }
};

@@ -235,31 +235,14 @@
 nst 
-APP_NAME = process.env.
+%7B%0A    
 APP_
@@ -250,18 +250,17 @@
 AME 
-%7C%7C
+=
  'Sharp'
 ;%0Aco
@@ -259,46 +259,22 @@
 arp'
-;%0Aconst APP_URL = process.env.
+,%0A    
 APP_URL 
 %7C%7C '
@@ -269,18 +269,17 @@
 APP_URL 
-%7C%7C
+=
  'https:
@@ -300,43 +300,52 @@
 .fr'
-;%0Aconst DOCS_VERSION = process.env.
+,%0A    DOCS_ENABLE_VERSIONING = 'false',%0A    
 DOCS
@@ -357,52 +357,52 @@
 ION 
-%7C%7C
+=
  '7.0'
-;%0Aconst DOCS_MAIN_URL = process.env.
+,%0A    DOCS_VERSION_ITEMS = '%5B%5D',%0A    
 DOCS
@@ -415,18 +415,17 @@
 URL 
-%7C%7C
+=
  APP_URL
 ;%0Aco
@@ -420,17 +420,63 @@
  APP_URL
-;
+,%0A    DOCS_ALGOLIA_TAG = 'v7'%0A%7D = process.env;%0A
 %0Aconst D
@@ -490,28 +490,16 @@
 E_URL = 
-process.env.
 DOCS_MAI
@@ -792,28 +792,16 @@
         
-process.env.
 DOCS_ENA
@@ -905,20 +905,8 @@
 rse(
-process.env.
 DOCS
@@ -5732,16 +5732,76 @@
 age: 5,%0A
+                facetFilters: %5B%60tags:$%7BDOCS_ALGOLIA_TAG%7D%60%5D,%0A
         

handle DOCS_ALGOLIA_TAGS