mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
docs(new docs site): removes old sphinx doc site with gatsby (#10784)
* Remove old apache sphinx doc site with refreshed gatsby * remove rando * add licenses * excluing .mdx files from license checks * fixes * Clean up sphinx references * Addressed comments * colors and tweaks * more fixes * add dummy docs/requirements.txt to satisfy stupid fossa * cp .prettierrc * more licenses * minor touchups * reqs * removing old videos * add github buttons * prettier * tweaks * Eugenia/Fix some of the images and modified some of database pages * add subheadernav * add side headers nav and more responsive design for docs * update resources page and other styling updates * linting * tweaks * removing windows and align:center * update resources * remove links and and card hearder * lots of styling tweaks * Tweaks and minor improvements * lint * fix CI * trigger pre-comimt * rererefix CI Co-authored-by: Maxime Beauchemin <maximebeauchemin@gmail.com> Co-authored-by: Eugenia Moreno <eugenia@Eugenias-MBP.fios-router.home> Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
committed by
GitHub
parent
7cd96edcdf
commit
85a916036c
101
docs/src/utils.js
Normal file
101
docs/src/utils.js
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* eslint no-undef: "error" */
|
||||
const getPathName = (path) => path.replace(/[/]+/g, '');
|
||||
|
||||
export const getCurrentPath = () => (typeof window !== 'undefined' ? getPathName(window.location.pathname) : '');
|
||||
// get active menus
|
||||
export const getActiveMenuItem = (items) => {
|
||||
let selectedKey;
|
||||
let openKey;
|
||||
let headings = [];
|
||||
const path = getCurrentPath();
|
||||
items.forEach(
|
||||
({
|
||||
menu, id: itemId, route: itemRoute, headings: itemHeadings,
|
||||
}) => {
|
||||
if (menu) {
|
||||
menu.forEach(({ id: menuId, route, headings: subHeadings }) => {
|
||||
if (getPathName(route) === path) {
|
||||
selectedKey = menuId;
|
||||
openKey = itemId;
|
||||
headings = subHeadings;
|
||||
}
|
||||
});
|
||||
} else if (itemRoute) {
|
||||
if (getPathName(itemRoute) === path) {
|
||||
selectedKey = itemId;
|
||||
openKey = itemId;
|
||||
headings = itemHeadings;
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
return { openKey, selectedKey, headings };
|
||||
};
|
||||
|
||||
// TODO implement versioned dox?
|
||||
/* const getVersionedDocs = (v, menus) => {
|
||||
//menus.filter(doc =>
|
||||
const stack = [...menus];
|
||||
while(stack.length > 0) {
|
||||
let temp = stack.shift();
|
||||
if (Array.isArray(temp.menu)){
|
||||
|
||||
} else newlist.push(temp);
|
||||
}
|
||||
} */
|
||||
|
||||
// flattens ordered menu
|
||||
const listOrderedMenu = (menus) => {
|
||||
const newlist = [];
|
||||
const stack = [...menus];
|
||||
while (stack.length > 0) {
|
||||
const temp = stack.shift();
|
||||
if (Array.isArray(temp.menu)) {
|
||||
const sortedMenu = temp.menu.sort((a, b) => a.index - b.index);
|
||||
stack.unshift(...sortedMenu);
|
||||
} else newlist.push(temp);
|
||||
}
|
||||
return newlist;
|
||||
};
|
||||
|
||||
// functionality for prev and next button
|
||||
export const getPreviousAndNextUrls = (menus) => {
|
||||
const items = listOrderedMenu(menus);
|
||||
let prevUrl;
|
||||
let nextUrl;
|
||||
const path = getCurrentPath();
|
||||
|
||||
items.forEach(({ route }, index) => {
|
||||
if (getPathName(route) === path) {
|
||||
if (items[index - 1]) {
|
||||
prevUrl = items[index - 1].route;
|
||||
}
|
||||
if (items[index + 1]) {
|
||||
nextUrl = items[index + 1].route;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return [prevUrl, nextUrl];
|
||||
};
|
||||
|
||||
export const getCurrentMenu = () => {};
|
||||
Reference in New Issue
Block a user