Skip to content

Commit

Permalink
Setup Discovery.js app
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Nov 4, 2024
1 parent fd0289a commit 9bdf471
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
10 changes: 10 additions & 0 deletions gh-pages.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
name: 'Discovery.js',
version: require('./package.json').version,
description: 'Explore, analyze, share',
view: {
assets: [
'./gh-pages.extensions.js'
]
}
};
16 changes: 16 additions & 0 deletions gh-pages.extensions.js
Original file line number Diff line number Diff line change
@@ -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
});
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"author": "Roman Dvornov <[email protected]> (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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions src/extensions/modelfree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class App<
constructor(options: Partial<Options> = {}) {
const extensions: typeof options.extensions = [];

extensions.push(navButtons.indexPage);
extensions.push(navButtons.discoveryPage);
extensions.push(navButtons.darkmodeToggle);

if (coalesceOption(options.router, true)) {
Expand All @@ -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)) {
Expand Down

0 comments on commit 9bdf471

Please sign in to comment.