From 9bdf471eb7bb4b257a5520b39dc2aa320d827231 Mon Sep 17 00:00:00 2001 From: Roman Dvornov Date: Mon, 4 Nov 2024 16:39:58 +0100 Subject: [PATCH] Setup Discovery.js app --- gh-pages.config.cjs | 10 ++++++++++ gh-pages.extensions.js | 16 ++++++++++++++++ package.json | 11 +++++++++-- src/extensions/modelfree.ts | 8 +++----- src/main/app.ts | 5 ++--- 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 gh-pages.config.cjs create mode 100644 gh-pages.extensions.js diff --git a/gh-pages.config.cjs b/gh-pages.config.cjs new file mode 100644 index 0000000..062fc04 --- /dev/null +++ b/gh-pages.config.cjs @@ -0,0 +1,10 @@ +module.exports = { + name: 'Discovery.js', + version: require('./package.json').version, + description: 'Explore, analyze, share', + view: { + assets: [ + './gh-pages.extensions.js' + ] + } +}; diff --git a/gh-pages.extensions.js b/gh-pages.extensions.js new file mode 100644 index 0000000..14be2e0 --- /dev/null +++ b/gh-pages.extensions.js @@ -0,0 +1,16 @@ +import modelfree from './src/extensions/modelfree.js'; +import upload from './src/extensions/upload.js'; +import * as navButtons from './src/nav/buttons.js'; + +discovery.apply([ + modelfree, + upload.setup({ clipboard: true }), + navButtons.uploadFile, + navButtons.unloadData +]); + +discovery.nav.primary.append({ + name: 'github', + href: 'https://github.com/discoveryjs/discovery', + external: true +}); diff --git a/package.json b/package.json index ef88975..496c272 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,14 @@ "author": "Roman Dvornov (https://github.com/lahmatiy)", "license": "MIT", "repository": "discoveryjs/discovery", - "keywords": [], + "keywords": [ + "json", + "jsonxl", + "query", + "processing", + "visualization", + "analysis" + ], "type": "module", "main": "lib/lib.js", "unpkg": "dist/discovery.js", @@ -39,7 +46,7 @@ "build:preloader": "npm run build:preloader:js && npm run build:preloader:css", "build:preloader:js": "esbuild src/preloader.ts --outfile=dist/discovery-preloader.js --bundle --define:global=window --format=esm --minify --sourcemap=external", "build:preloader:css": "esbuild src/preloader.css --outfile=dist/discovery-preloader.css --bundle --minify --loader:.svg=dataurl", - "build-gh-pages": "npm run transpile && discovery-build -o .gh-pages --clean", + "build-gh-pages": "npm run transpile && discovery-build -c gh-pages.config.cjs -o .gh-pages --clean --single-file --no-dev", "transpile": "node scripts/transpile.js", "prepublishOnly": "npm run transpile && npm run build", "cypress": "npx cypress open", diff --git a/src/extensions/modelfree.ts b/src/extensions/modelfree.ts index d5a4068..15a42f2 100644 --- a/src/extensions/modelfree.ts +++ b/src/extensions/modelfree.ts @@ -3,11 +3,9 @@ import { ViewModel } from '../main/view-model.js'; export default (host: ViewModel) => { let defaultPageId = ''; - host.nav.primary.append({ - name: 'github', - href: 'https://github.com/discoveryjs/discovery', - external: true - }); + host.nav.remove('index-page'); + host.nav.remove('discovery-page'); + host.on('data', () => { if (host.defaultPageId !== host.discoveryPageId) { defaultPageId = host.defaultPageId; diff --git a/src/main/app.ts b/src/main/app.ts index 836b205..5d15dcb 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -46,6 +46,8 @@ export class App< constructor(options: Partial = {}) { const extensions: typeof options.extensions = []; + extensions.push(navButtons.indexPage); + extensions.push(navButtons.discoveryPage); extensions.push(navButtons.darkmodeToggle); if (coalesceOption(options.router, true)) { @@ -54,9 +56,6 @@ export class App< if (options.mode === 'modelfree') { extensions.push(modelfree); - } else { - extensions.push(navButtons.indexPage); - extensions.push(navButtons.discoveryPage); } if (coalesceOption(options.upload, false)) {