fix icons

This commit is contained in:
Aaron Carlino 2019-11-12 17:05:31 +13:00
parent 0cc0587897
commit 2586cfa9b0
5 changed files with 17 additions and 10 deletions

View File

@ -51,7 +51,7 @@ module.exports = {
resolve: `gatsby-plugin-purgecss`, resolve: `gatsby-plugin-purgecss`,
options: { options: {
printRejected: false, printRejected: false,
whitelist: ['.algolia-autocomplete'], whitelist: ['algolia-autocomplete'],
ignore: ['prismjs/','docsearch.js/', 'src/theme/assets/search/algolia.css'], ignore: ['prismjs/','docsearch.js/', 'src/theme/assets/search/algolia.css'],
//purgeOnly : ['components/', '/main.css', 'bootstrap/'], //purgeOnly : ['components/', '/main.css', 'bootstrap/'],
} }

View File

@ -4,14 +4,15 @@ import { Link } from 'gatsby';
import { getChildren, getSiblings } from '../utils/nodes'; import { getChildren, getSiblings } from '../utils/nodes';
const createCards = (children: SilverstripeDocument[]): ReactElement[] => { const createCards = (children: SilverstripeDocument[]): ReactElement[] => {
return children.map(({ summary, slug, title, icon }) => { return children.map(({ summary, slug, title, icon, iconBrand }) => {
const iconClass = iconBrand ? `fab fa-${iconBrand}` : `fas fa-${icon || 'file-alt'}`
return ( return (
<div className="col-12 col-lg-6 py-3" key={slug}> <div className="col-12 col-lg-6 py-3" key={slug}>
<div className="card shadow-sm"> <div className="card shadow-sm">
<div className="card-body"> <div className="card-body">
<h5 className="card-title mb-3"> <h5 className="card-title mb-3">
<span className="theme-icon-holder card-icon-holder mr-2"> <span className="theme-icon-holder card-icon-holder mr-2">
<i className={`fas fa-${icon || 'file-alt'}`}></i> <i className={iconClass}></i>
</span> </span>
<span className="card-title-text">{title}</span> <span className="card-title-text">{title}</span>
</h5> </h5>

View File

@ -9,16 +9,21 @@ interface HeaderProps {
} }
const handleNavigate = (e: any): void => { const handleNavigate = (e: any): void => {
if (typeof window === 'undefined') {
return;
}
const currentNode = getCurrentNode(); const currentNode = getCurrentNode();
const ver = e.target.value; const ver = e.target.value;
if (currentNode) { if (currentNode) {
const newPath = currentNode.slug.replace(/^\/en\/[0-9]+\//, `/en/${ver}/`); const newPath = currentNode.slug.replace(/^\/en\/[0-9]+\//, `/en/${ver}/`);
const otherNode = getNodes().find(n => n.slug === newPath); const otherNode = getNodes().find(n => n.slug === newPath);
// This has to be a hard refresh, because the sidebar needs to unmount
if (otherNode) { if (otherNode) {
navigate(otherNode.slug); window.location.href = otherNode.slug;
} else { } else {
navigate(`/en/${ver}`); window.location.href = `/en/${ver}`;
} }
} }
} }

View File

@ -25,10 +25,11 @@ export interface SilverstripeDocument {
slug: string; slug: string;
isIndex: boolean; isIndex: boolean;
filePath: string; filePath: string;
introduction: string; introduction?: string;
icon: string; icon?: string;
hideChildren: boolean; iconBrand?: string;
hideSelf: boolean; hideChildren?: boolean;
hideSelf?: boolean;
parentSlug: string; parentSlug: string;
summary: string; summary: string;
fileTitle: string; fileTitle: string;

View File

@ -4,7 +4,6 @@ import { HierarchyQuery, SilverstripeDocument } from '../types';
import sortFiles from './sortFiles'; import sortFiles from './sortFiles';
let __nodes: SilverstripeDocument[] | undefined; let __nodes: SilverstripeDocument[] | undefined;
let __path: string | null = null;
let __currentNode: SilverstripeDocument | null = null; let __currentNode: SilverstripeDocument | null = null;
let __currentVersion: string | null = null; let __currentVersion: string | null = null;
let __home: SilverstripeDocument | null = null; let __home: SilverstripeDocument | null = null;
@ -27,6 +26,7 @@ const getNodes = (): SilverstripeDocument[] => {
isIndex isIndex
introduction introduction
icon icon
iconBrand
hideChildren hideChildren
slug slug
parentSlug parentSlug