mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 08:12:39 +00:00
use same theme endpoint for user and static themes
`getThemeBundle()` rework no longer needs two separate endpoints
This commit is contained in:
@@ -175,10 +175,7 @@ const BrewRenderer = (props)=>{
|
|||||||
|
|
||||||
// Loads the theme bundle and parses it out. Called when the iFrame is first mounted, and when a new theme is selected
|
// Loads the theme bundle and parses it out. Called when the iFrame is first mounted, and when a new theme is selected
|
||||||
const loadAllBrewStylesAndSnippets = ()=>{
|
const loadAllBrewStylesAndSnippets = ()=>{
|
||||||
const rendererPath = isStaticTheme(props.renderer, props.theme) ? `/${props.renderer}/` : '/';
|
fetch(`${window.location.protocol}//${window.location.host}/theme/${props.renderer}/${props.theme}`).then((response)=>response.json()).then((themeBundle)=>{
|
||||||
|
|
||||||
// Load the themeBundle from the endpoint as an object
|
|
||||||
fetch(`${window.location.protocol}//${window.location.host}/theme${rendererPath}${props.theme}`).then((response)=>response.json()).then((themeBundle)=>{
|
|
||||||
themeBundle.joinedStyles = themeBundle.styles.map(style => `<style>${style}</style>`).join('\n\n'); //DOMPurify.sanitize(joinedStyles, purifyConfig);
|
themeBundle.joinedStyles = themeBundle.styles.map(style => `<style>${style}</style>`).join('\n\n'); //DOMPurify.sanitize(joinedStyles, purifyConfig);
|
||||||
setState((prevState)=>({
|
setState((prevState)=>({
|
||||||
...prevState,
|
...prevState,
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ app.get('/robots.txt', (req, res)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
// Path for User Themes
|
|
||||||
app.get('/theme/:id', asyncHandler(getThemeBundle));
|
|
||||||
// Path for Static Themes
|
|
||||||
app.get('/theme/:renderer/:id', asyncHandler(getThemeBundle));
|
app.get('/theme/:renderer/:id', asyncHandler(getThemeBundle));
|
||||||
|
|
||||||
//Home page
|
//Home page
|
||||||
|
|||||||
Reference in New Issue
Block a user