generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from eea/develop
fix(toc): make it work, refs #265201
- Loading branch information
Showing
13 changed files
with
128 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Jest configuration variables | ||
# - possible values: ON, OFF | ||
JEST_USE_SETUP=ON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const projectRootPath = fs.realpathSync(__dirname + '/../../../'); | ||
|
||
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto'); | ||
let configFile; | ||
if (fs.existsSync(`${projectRootPath}/tsconfig.json`)) | ||
configFile = `${projectRootPath}/tsconfig.json`; | ||
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`)) | ||
configFile = `${projectRootPath}/jsconfig.json`; | ||
|
||
if (configFile) { | ||
const jsConfig = require(configFile).compilerOptions; | ||
const pathsConfig = jsConfig.paths; | ||
if (pathsConfig['@plone/volto']) | ||
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`; | ||
} | ||
|
||
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`); | ||
const reg = new AddonConfigurationRegistry(projectRootPath); | ||
|
||
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons | ||
const addonAliases = Object.keys(reg.packages).map((o) => [ | ||
o, | ||
reg.packages[o].modulePath, | ||
]); | ||
|
||
const addonExtenders = reg.getEslintExtenders().map((m) => require(m)); | ||
|
||
const defaultConfig = { | ||
extends: `${voltoPath}/.eslintrc`, | ||
settings: { | ||
'import/resolver': { | ||
alias: { | ||
map: [ | ||
['@plone/volto', '@plone/volto/src'], | ||
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'], | ||
...addonAliases, | ||
['@package', `${__dirname}/src`], | ||
['@root', `${__dirname}/src`], | ||
['~', `${__dirname}/src`], | ||
], | ||
extensions: ['.js', '.jsx', '.json'], | ||
}, | ||
'babel-plugin-root-import': { | ||
rootPathSuffix: 'src', | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'react/jsx-no-target-blank': [ | ||
'error', | ||
{ | ||
allowReferrer: true, | ||
}, | ||
], | ||
} | ||
}; | ||
|
||
const config = addonExtenders.reduce( | ||
(acc, extender) => extender.modify(acc), | ||
defaultConfig, | ||
); | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.vscode/ | ||
.history | ||
.eslintrc.js | ||
.nyc_output | ||
project | ||
coverage | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/customizations/volto/components/manage/Blocks/ToC/variations/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import DefaultTocRenderer from './DefaultTocRenderer'; | ||
import HorizontalMenu from './HorizontalMenu'; | ||
|
||
const ToCVariations = [ | ||
{ | ||
id: 'default', | ||
title: 'Listing (default)', | ||
view: DefaultTocRenderer, | ||
isDefault: true, | ||
}, | ||
{ | ||
id: 'horizontalMenu', | ||
title: 'Horizontal Menu', | ||
view: HorizontalMenu, | ||
}, | ||
]; | ||
|
||
export default ToCVariations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters