0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Removed CSS splitting from homebrew.api.js and back to newPage.jsx.

This commit is contained in:
G.Ambatte
2021-06-21 19:46:54 +12:00
parent ad0e4a2099
commit a74916d593
2 changed files with 10 additions and 9 deletions

View File

@@ -136,10 +136,18 @@ const NewPage = createClass({
console.log('saving new brew');
const brew = this.state.brew;
// Split out CSS to Style if CSS codefence exists
if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
const index = brew.text.indexOf('```\n\n');
brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
brew.text = brew.text.slice(index + 5);
};
if(this.state.saveGoogle) {
const res = await request
.post('/api/newGoogle/')
.send(this.state.brew)
.send(brew)
.catch((err)=>{
console.log(err.status === 401
? 'Not signed in!'
@@ -153,7 +161,7 @@ const NewPage = createClass({
window.location = `/edit/${brew.googleId}${brew.editId}`;
} else {
request.post('/api')
.send(this.state.brew)
.send(brew)
.end((err, res)=>{
if(err){
this.setState({

View File

@@ -31,13 +31,6 @@ const newBrew = (req, res)=>{
const brew = req.body;
// Split out CSS to Style if CSS codefence exists
if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
const index = brew.text.indexOf('```\n\n');
brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
brew.text = brew.text.slice(index + 5);
};
if(!brew.title) {
brew.title = getGoodBrewTitle(brew.text);
}