Skip to content

Commit 57f8c9c

Browse files
committed
Centralize routes.json (navigation bar data) at the top level
1 parent f41e64c commit 57f8c9c

File tree

3 files changed

+80
-79
lines changed

3 files changed

+80
-79
lines changed

_layout/foot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<script src="/libs/collapse/collapse.js"></script>
66
<script src="/libs/pure/ui.min.js"></script>
77
<!-- head and footer-nav -->
8-
<script src="/libs/nav/head.js"></script>
8+
<script src="/libs/nav/head.js" type="module"></script>
99
<!-- landing page -->
1010
<script src="/libs/landing/landing.js"></script>
1111
<!-- navigation bar -->

_libs/nav/head.js

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,4 @@
1-
2-
const navItems = [
3-
{ name: 'Home', href: '/', sections: [], sectionItemWidth: '', id: 'home' },
4-
{
5-
name: 'Data Basics', // Category name to be shown in navigation bar
6-
id: 'data', // id to be manipulated with js
7-
href: '/info/data', // in case it should link anywhere
8-
sections: [ // list items to be shown in its dropdown and where they link to
9-
{ name: 'Loading Data', href: '/data/loading/' },
10-
{ name: 'Data Frames', href: '/data/dataframe/' },
11-
{ name: 'Categorical Arrays', href: '/data/categorical/' },
12-
{ name: 'Scientific Type', href: '/data/scitype/' },
13-
{ name: 'Data processing', href: '/data/processing/' },
14-
],
15-
sectionItemWidth: 'short-item'
16-
},
17-
{
18-
name: 'Getting Started',
19-
id: 'getting-started',
20-
href: '/info/getting-started',
21-
sections: [
22-
{ name: 'Choosing a model', href: '/getting-started/choosing-a-model/' },
23-
{ name: 'Fit, predict, transform', href: '/getting-started/fit-and-predict/' },
24-
{ name: 'Model tuning', href: '/getting-started/model-tuning/' },
25-
{ name: 'Ensembles', href: '/getting-started/ensembles/' },
26-
{ name: 'Ensembles (2)', href: '/getting-started/ensembles-2/' },
27-
{ name: 'Composing models', href: '/getting-started/composing-models/' },
28-
{ name: 'Stacking', href: '/getting-started/stacking/' },
29-
],
30-
sectionItemWidth: 'medium-item'
31-
},
32-
{
33-
name: 'Intro to Stats Learning',
34-
id: 'stats-learning',
35-
href: '/info/isl',
36-
sections: [
37-
{ name: 'Lab 2', href: '/isl/lab-2/' },
38-
{ name: 'Lab 3', href: '/isl/lab-3/' },
39-
{ name: 'Lab 4', href: '/isl/lab-4/' },
40-
{ name: 'Lab 5', href: '/isl/lab-5/' },
41-
{ name: 'Lab 6b', href: '/isl/lab-6b/' },
42-
{ name: 'Lab 8', href: '/isl/lab-8/' },
43-
{ name: 'Lab 9', href: '/isl/lab-9/' },
44-
{ name: 'Lab 10', href: '/isl/lab-10/' },
45-
],
46-
sectionItemWidth: 'long-item'
47-
},
48-
49-
{
50-
name: 'End to End',
51-
id: 'end-to-end',
52-
href: '/info/end-to-end',
53-
sections: [
54-
{ name: 'Telco Churn', href: '/end-to-end/telco/' },
55-
{ name: 'AMES', href: '/end-to-end/AMES/' },
56-
{ name: 'Wine', href: '/end-to-end/wine/' },
57-
{ name: 'Crabs (XGB)', href: '/end-to-end/crabs-xgb/' },
58-
{ name: 'Horse', href: '/end-to-end/horse/' },
59-
{ name: 'King County Houses', href: '/end-to-end/HouseKingCounty/' },
60-
{ name: 'Airfoil', href: '/end-to-end/airfoil' },
61-
{ name: 'Boston (lgbm)', href: '/end-to-end/boston-lgbm' },
62-
{ name: 'Using GLM.jl', href: '/end-to-end/glm/' },
63-
{ name: 'Power Generation', href: '/end-to-end/powergen/' },
64-
{ name: 'Boston (Flux)', href: '/end-to-end/boston-flux' },
65-
{ name: 'Breast Cancer', href: '/end-to-end/breastcancer' },
66-
{ name: 'Credit Fraud', href: '/end-to-end/creditfraud' },
67-
],
68-
sectionItemWidth: 'long-item'
69-
},
70-
{
71-
name: 'Advanced',
72-
id: 'advanced',
73-
href: '#!',
74-
sections: [{ name: 'Ensembles (3)', href: '/advanced/ensembles-3' }],
75-
sectionItemWidth: 'medium-item'
76-
},
77-
];
1+
import navItems from '../../routes.json' assert {type: 'json'};
782

793
// first get info on whether hosted or not
804
const origin = window.location.origin;
@@ -130,7 +54,7 @@ navItems.forEach((item) => {
13054

13155
// add a final li as searchform
13256
let formAction = (hosted) ? origin + "/DataScienceTutorials.jl" + "/search/index.html" : "/search/index.html";
133-
searchForm = `
57+
let searchForm = `
13458
<li>
13559
<form id="lunrSearchForm" name="lunrSearchForm" style="margin-left: 1.5rem; margin-right: -2rem;">
13660
<input class="search-input" name="q" placeholder="Search..." type="text">

routes.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[
2+
{ "name": "Home", "href": "/", "sections": [], "sectionItemWidth": "", "id": "home" },
3+
{
4+
"name": "Data Basics",
5+
"id": "data",
6+
"href": "/info/data",
7+
"sections": [
8+
{ "name": "Loading Data", "href": "/data/loading/" },
9+
{ "name": "Data Frames", "href": "/data/dataframe/" },
10+
{ "name": "Categorical Arrays", "href": "/data/categorical/" },
11+
{ "name": "Scientific Type", "href": "/data/scitype/" },
12+
{ "name": "Data processing", "href": "/data/processing/" }
13+
],
14+
"sectionItemWidth": "short-item"
15+
},
16+
{
17+
"name": "Getting Started",
18+
"id": "getting-started",
19+
"href": "/info/getting-started",
20+
"sections": [
21+
{ "name": "Choosing a model", "href": "/getting-started/choosing-a-model/" },
22+
{ "name": "Fit, predict, transform", "href": "/getting-started/fit-and-predict/" },
23+
{ "name": "Model tuning", "href": "/getting-started/model-tuning/" },
24+
{ "name": "Ensembles", "href": "/getting-started/ensembles/" },
25+
{ "name": "Ensembles (2)", "href": "/getting-started/ensembles-2/" },
26+
{ "name": "Composing models", "href": "/getting-started/composing-models/" },
27+
{ "name": "Stacking", "href": "/getting-started/stacking/" }
28+
],
29+
"sectionItemWidth": "medium-item"
30+
},
31+
{
32+
"name": "Intro to Stats Learning",
33+
"id": "stats-learning",
34+
"href": "/info/isl",
35+
"sections": [
36+
{ "name": "Lab 2", "href": "/isl/lab-2/" },
37+
{ "name": "Lab 3", "href": "/isl/lab-3/" },
38+
{ "name": "Lab 4", "href": "/isl/lab-4/" },
39+
{ "name": "Lab 5", "href": "/isl/lab-5/" },
40+
{ "name": "Lab 6b", "href": "/isl/lab-6b/" },
41+
{ "name": "Lab 8", "href": "/isl/lab-8/" },
42+
{ "name": "Lab 9", "href": "/isl/lab-9/" },
43+
{ "name": "Lab 10", "href": "/isl/lab-10/" }
44+
],
45+
"sectionItemWidth": "long-item"
46+
},
47+
48+
{
49+
"name": "End to End",
50+
"id": "end-to-end",
51+
"href": "/info/end-to-end",
52+
"sections": [
53+
{ "name": "Telco Churn", "href": "/end-to-end/telco/" },
54+
{ "name": "AMES", "href": "/end-to-end/AMES/" },
55+
{ "name": "Wine", "href": "/end-to-end/wine/" },
56+
{ "name": "Crabs (XGB)", "href": "/end-to-end/crabs-xgb/" },
57+
{ "name": "Horse", "href": "/end-to-end/horse/" },
58+
{ "name": "King County Houses", "href": "/end-to-end/HouseKingCounty/" },
59+
{ "name": "Airfoil", "href": "/end-to-end/airfoil" },
60+
{ "name": "Boston (lgbm)", "href": "/end-to-end/boston-lgbm" },
61+
{ "name": "Using GLM.jl", "href": "/end-to-end/glm/" },
62+
{ "name": "Power Generation", "href": "/end-to-end/powergen/" },
63+
{ "name": "Boston (Flux)", "href": "/end-to-end/boston-flux" },
64+
{ "name": "Breast Cancer", "href": "/end-to-end/breastcancer" },
65+
{ "name": "Credit Fraud", "href": "/end-to-end/creditfraud" }
66+
],
67+
"sectionItemWidth": "long-item"
68+
},
69+
{
70+
"name": "Advanced",
71+
"id": "advanced",
72+
"href": "#!",
73+
"sections": [{ "name": "Ensembles (3)", "href": "/advanced/ensembles-3" }],
74+
"sectionItemWidth": "medium-item"
75+
}
76+
]
77+

0 commit comments

Comments
 (0)