Added some markup to the Articles
This commit is contained in:
		| @@ -27,9 +27,9 @@ import { get } from '@public/api/api'; | ||||
| const TestBlogArticle = id => { | ||||
|   return { | ||||
|     id, handle: 'test-blog-article', title: 'My Title', | ||||
|     image: 'photo.jpg', | ||||
|     image: 'blogs/dombot-redevelopment/banner.jpg', | ||||
|     shortDescription: "Some short description that goes here too so let's write.", | ||||
|     description: "This is my longer example description lorem ipsum dolor sit amet." | ||||
|     description: "This is my longer example description lorem ipsum dolor sit amet.\nNewline\n\nNew Paragraph\n\nhttps://hyperlink.com" | ||||
|   } | ||||
| }; | ||||
|  | ||||
|   | ||||
							
								
								
									
										44
									
								
								public/objects/content/Content.jsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								public/objects/content/Content.jsx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| // Copyright (c) 2018 Dominic Masters | ||||
| // | ||||
| // MIT License | ||||
| // | ||||
| // Permission is hereby granted, free of charge, to any person obtaining | ||||
| // a copy of this software and associated documentation files (the | ||||
| // "Software"), to deal in the Software without restriction, including | ||||
| // without limitation the rights to use, copy, modify, merge, publish, | ||||
| // distribute, sublicense, and/or sell copies of the Software, and to | ||||
| // permit persons to whom the Software is furnished to do so, subject to | ||||
| // the following conditions: | ||||
| // | ||||
| // The above copyright notice and this permission notice shall be | ||||
| // included in all copies or substantial portions of the Software. | ||||
| // | ||||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
| // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||||
| // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||||
| // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||||
| // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
|  | ||||
| import React, { Fragment } from 'react'; | ||||
| import { Paragraph } from './../typography/Typography'; | ||||
|  | ||||
| const DoLine = content => { | ||||
|   //TODO: Support things like hyperlinks etc. | ||||
|   return <Fragment>{ content }</Fragment> | ||||
| }; | ||||
|  | ||||
| const DoNewline = content => <Fragment>{ DoLine(content) }<br /></Fragment>; | ||||
| const DoParagraph = content => <Paragraph children={ content.split('\n').map(e => DoNewline(e)) } />; | ||||
|  | ||||
| export default props => { | ||||
|   let { content, children } = props; | ||||
|   content = content || children || ""; | ||||
|  | ||||
|   return ( | ||||
|     <Fragment> | ||||
|       { content.split('\n\n').map(e => DoParagraph(e)) } | ||||
|     </Fragment> | ||||
|   ); | ||||
| }; | ||||
| @@ -23,17 +23,19 @@ | ||||
|  | ||||
| import React from 'react'; | ||||
|  | ||||
| import Content from './../Content'; | ||||
| import Styles from './ContentBox.scss'; | ||||
|  | ||||
| export default (props) => { | ||||
|   let newProps = {...props}; | ||||
|   let { className, box } = props; | ||||
|   let { className, box, content } = props; | ||||
|  | ||||
|   delete newProps.box; | ||||
|   ["box","content"].forEach(e => delete newProps[e]); | ||||
|  | ||||
|   let clazz = "o-content-box"; | ||||
|   if(box) clazz += " is-box" | ||||
|   if(className) clazz += ` ${className}`; | ||||
|   if(content) newProps.children = <Content content={content} /> | ||||
|  | ||||
|   return <div {...newProps} className={clazz} />; | ||||
| }; | ||||
|   | ||||
| @@ -23,7 +23,7 @@ | ||||
|  | ||||
| import React from 'react'; | ||||
|  | ||||
| const Heading = (props) => { | ||||
| const Heading = props => { | ||||
|   let { level, size, className } = props; | ||||
|  | ||||
|   level = level || 1; | ||||
| @@ -33,8 +33,8 @@ const Heading = (props) => { | ||||
|   let clazz = `o-heading o-heading--${size}`; | ||||
|   if(className) clazz += ` ${className}`; | ||||
|   return <CustomTag {...props} className={clazz} />; | ||||
| } | ||||
| export default Heading; | ||||
| }; | ||||
|  | ||||
|  | ||||
| const Heading1 = (props) => { return <Heading {...props} level="1" />; }; | ||||
| const Heading2 = (props) => { return <Heading {...props} level="2" />; }; | ||||
| @@ -43,6 +43,7 @@ const Heading4 = (props) => { return <Heading {...props} level="4" />; }; | ||||
| const Heading5 = (props) => { return <Heading {...props} level="5" />; }; | ||||
| const Heading6 = (props) => { return <Heading {...props} level="6" />; }; | ||||
|  | ||||
| export default Heading; | ||||
| export { | ||||
|   Heading1, Heading2, Heading3, Heading4, Heading5, Heading6 | ||||
| }; | ||||
|   | ||||
| @@ -23,7 +23,6 @@ | ||||
|  | ||||
| import React from 'react'; | ||||
|  | ||||
| export default (props) => { | ||||
|   let { className } = props; | ||||
|   return <p {...props} className={"o-paragraph"+(className?` ${className}`: "")} />; | ||||
| export default props => { | ||||
|   return <p {...props} className={`o-paragraph ${props.className||""}`} />; | ||||
| }; | ||||
|   | ||||
| @@ -70,11 +70,10 @@ export default withArticleTemplate(withLanguage(props => { | ||||
|           </div> | ||||
|  | ||||
|           {/* Description */} | ||||
|           <ContentBox box itemProp="description" className="p-article-page__description"> | ||||
|             <Paragraph> | ||||
|               { article.description || article.shortDescription } | ||||
|             </Paragraph> | ||||
|           </ContentBox> | ||||
|           <ContentBox | ||||
|             box itemProp="description" className="p-article-page__description" | ||||
|             content={ article.description || article.shortDescription } | ||||
|           /> | ||||
|         </article> | ||||
|       </PageBoundary> | ||||
|     ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user