Skip to content

Commit

Permalink
fix: dont show footer if themeConfig.footer is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed May 16, 2019
1 parent d03ff70 commit 8d068da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 10 additions & 4 deletions packages/docusaurus-theme-classic/src/theme/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function Footer() {
themeConfig: {footer},
} = siteConfig;

if (!footer) {
return null;
}

const {copyright, links = [], logo} = footer;

return (
Expand All @@ -30,15 +34,17 @@ function Footer() {
<div className="container">
{links && links.length > 0 && (
<div className="row footer__links">
{links.map(linkItem => (
<div className="col">
{links.map((linkItem, i) => (
<div key={`linkItem-${i}`} className="col">
{linkItem.title != null ? (
<h4 className="footer__title">{linkItem.title}</h4>
) : null}
{linkItem.items != null && linkItem.items.length > 0 ? (
{linkItem.items != null &&
Array.isArray(linkItem.items) &&
linkItem.items.length > 0 ? (
<ul className="footer__items">
{linkItem.items.map(item => (
<li className="footer__item">
<li key={item.href || item.to} className="footer__item">
<Link
className="footer__link-item"
{...item}
Expand Down
8 changes: 3 additions & 5 deletions packages/docusaurus/src/server/load/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

const fs = require('fs-extra');
const _ = require('lodash');
const importFresh = require('import-fresh');
const path = require('path');
const {CONFIG_FILE_NAME} = require('../../constants');

Expand Down Expand Up @@ -37,14 +38,11 @@ function formatFields(fields) {
return fields.map(field => `'${field}'`).join(', ');
}

function loadConfig(siteDir, deleteCache = true) {
function loadConfig(siteDir) {
const configPath = path.resolve(siteDir, CONFIG_FILE_NAME);
if (deleteCache) {
delete require.cache[configPath];
}
let loadedConfig = {};
if (fs.existsSync(configPath)) {
loadedConfig = require(configPath); // eslint-disable-line
loadedConfig = importFresh(configPath);
}

const missingFields = REQUIRED_FIELDS.filter(
Expand Down
4 changes: 4 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module.exports = {
label: 'Feedback',
to: 'feedback',
},
{
label: 'Discord',
href: 'https://discordapp.com/invite/docusaurus',
},
],
},
{
Expand Down

0 comments on commit 8d068da

Please sign in to comment.