-
Notifications
You must be signed in to change notification settings - Fork 11
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 #126 from bem/browser
Themekit in browser
- Loading branch information
Showing
17 changed files
with
218 additions
and
447 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Config } from './config' | ||
import { enhanceWhitepaperConfig } from './enhance-whitepaper-config' | ||
import { loadSources } from './load-sources' | ||
import { loadTheme } from './loadTheme' | ||
import { loadMappers } from './mappers' | ||
import { Data } from './types' | ||
|
||
export async function loadData(config: Config): Promise<Data> { | ||
const result = [] | ||
|
||
for (const entry in config.entry) { | ||
const theme = await loadTheme(config.entry[entry]) | ||
for (const platform of theme.platforms) { | ||
result.push({ | ||
sources: await loadSources(theme.sources, platform), | ||
mapper: await loadMappers(theme.mappers), | ||
whitepaper: enhanceWhitepaperConfig(theme.whitepaper, platform), | ||
output: config.output, | ||
entry, | ||
platform, | ||
}) | ||
} | ||
} | ||
|
||
return result | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import YAML from 'yaml' | ||
|
||
type Format = 'json' | 'yaml' | 'yml' | ||
|
||
/** | ||
* Parse content by format. | ||
* | ||
* @param content - Raw content | ||
* @param format - Parsing format | ||
*/ | ||
export function parseContent(content: string, format: Format): any { | ||
switch (format) { | ||
case 'json': | ||
try { | ||
return JSON.parse(content) | ||
} catch (_e) { | ||
return content | ||
} | ||
case 'yml': | ||
case 'yaml': | ||
return YAML.parse(content) | ||
default: | ||
throw new Error( | ||
`Unexpected format "${format}" for parsing, please choose json or yaml format.`, | ||
) | ||
} | ||
} |
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
Oops, something went wrong.