Skip to content

Commit

Permalink
Merge pull request #34 from hllywluis/fix/abstract-conversion
Browse files Browse the repository at this point in the history
Abstract text to HTML conversion to postcard.tsx
  • Loading branch information
mergify[bot] committed Mar 3, 2022
2 parents 8867b36 + 2ef37fd commit c7d3303
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
8 changes: 7 additions & 1 deletion components/postcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export default function Postcard({
views,
replies,
}) {
const showdown = require("showdown")
const converter = new showdown.Converter({
strikethrough: true,
omitExtraWLInCodeBlocks: true,
})

return (
<Card className="h-100 bg-light border rounded-3">
<Card.Body>
Expand All @@ -24,7 +30,7 @@ export default function Postcard({
</Card.Subtitle>
</div>
<hr />
<Card.Text>{Parse(text)}</Card.Text>
<Card.Text>{Parse(converter.makeHtml(text))}</Card.Text>
</Card.Body>
<Card.Footer className="text-left">
<div className="row">
Expand Down
48 changes: 21 additions & 27 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ export async function getServerSideProps(req) {
}

export default function Home({ user }) {
const showdown = require("showdown")
const converter = new showdown.Converter({
strikethrough: true,
omitExtraWLInCodeBlocks: true,
})

const { data: session } = useSession()
const [currentGreeting, setCurrentGreeting] = useState("")
const _ = require("lodash")
Expand Down Expand Up @@ -137,14 +131,14 @@ export default function Home({ user }) {
author="Luis Bauza"
username="luis"
klepton="kleptonix"
text={converter.makeHtml(
text={
"##### Make yourself at home!\n" +
'Kleptonix allows developers (like you and I) to quickly and easily get in touch with others to create something new. Communities are denoted by "Kleptons," and each Klepton has a different topic. It fits in with the site\'s name, after all!\n' +
"##### How do I subscribe to a Klepton?\n" +
"You'll first want to head to the Klepton's page. Since this website is under construction, Kleptons themselves haven't been implemented yet.\n" +
"##### When will the website be finished?\n" +
"There's always something new to add or a bug to fix. I don't anticipate development ever finishing but most functionality should be implemented within the next few years (this is a side project, after all)."
)}
'Kleptonix allows developers (like you and I) to quickly and easily get in touch with others to create something new. Communities are denoted by "Kleptons," and each Klepton has a different topic. It fits in with the site\'s name, after all!\n' +
"##### How do I subscribe to a Klepton?\n" +
"You'll first want to head to the Klepton's page. Since this website is under construction, Kleptons themselves haven't been implemented yet.\n" +
"##### When will the website be finished?\n" +
"There's always something new to add or a bug to fix. I don't anticipate development ever finishing but most functionality should be implemented within the next few years (this is a side project, after all)."
}
views={1}
replies={1}
/>
Expand All @@ -155,12 +149,12 @@ export default function Home({ user }) {
author="John Doe"
username="jdoe"
klepton="javascript"
text={converter.makeHtml(
text={
"##### What is JavaScript?\n" +
'JavaScript is a programming language designed to make your life easier. In fact, this website is made using a subset of JavaScript called TypeScript. You can think of it like an "extension" of JavaScript that allows for more control over types and keeps applications running more reliably.\n' +
"##### Why should I care?\n" +
"In addition to being one of the most widely used languages on the Web, JavaScript is also used for certain desktop applications. Node.js allows developers to create desktop applications using JavaScript. Making web applications becomes much easier and faster using this language. If this website is made using JavaScript, just imagine what you might be able to create using it!"
)}
'JavaScript is a programming language designed to make your life easier. In fact, this website is made using a subset of JavaScript called TypeScript. You can think of it like an "extension" of JavaScript that allows for more control over types and keeps applications running more reliably.\n' +
"##### Why should I care?\n" +
"In addition to being one of the most widely used languages on the Web, JavaScript is also used for certain desktop applications. Node.js allows developers to create desktop applications using JavaScript. Making web applications becomes much easier and faster using this language. If this website is made using JavaScript, just imagine what you might be able to create using it!"
}
views={0}
replies={0}
/>
Expand All @@ -175,13 +169,13 @@ export default function Home({ user }) {
author="Bryan Grigorie"
username="bgregz"
klepton="python"
text={converter.makeHtml(
text={
"##### What is Python?\n" +
"Python is one of the most popular programming languages. It's used to make Flask applications, and it's used to make Django applications. I use it everyday at work, and I've also made Django apps in the past for school.\n" +
"##### Why is Python so popular?\n" +
"You'll probably use Python in your job too, if you're not already using it. It's a great language to learn, and it's a great language to use. I've used Python for a lot of things, and I'm pretty sure I'll use it again. It's one of those languages that I don't think will ever die down in popularity, unless something even more efficient becomes available.\n\n" +
"For those that are still learning programming, Python is a great starter language."
)}
"Python is one of the most popular programming languages. It's used to make Flask applications, and it's used to make Django applications. I use it everyday at work, and I've also made Django apps in the past for school.\n" +
"##### Why is Python so popular?\n" +
"You'll probably use Python in your job too, if you're not already using it. It's a great language to learn, and it's a great language to use. I've used Python for a lot of things, and I'm pretty sure I'll use it again. It's one of those languages that I don't think will ever die down in popularity, unless something even more efficient becomes available.\n\n" +
"For those that are still learning programming, Python is a great starter language."
}
views={0}
replies={0}
/>
Expand All @@ -196,10 +190,10 @@ export default function Home({ user }) {
author="John Doe"
username="jdoe"
klepton="rust"
text={converter.makeHtml(
text={
"##### What is Rust?\n" +
"Rust is a programming language. We don't need to talk about it."
)}
"Rust is a programming language. We don't need to talk about it."
}
views={0}
replies={0}
/>
Expand Down

0 comments on commit c7d3303

Please sign in to comment.