Skip to content

Commit

Permalink
Merge pull request #167 from Planet-NULLCAST/development
Browse files Browse the repository at this point in the history
Merge development to main
  • Loading branch information
akhilalekha authored Jun 25, 2021
2 parents 586a0a3 + 3db7df3 commit 6552f23
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
56 changes: 34 additions & 22 deletions component/layout/BlogPost/BlogPost.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import styles from "./BlogPost.module.scss";
import Link from "next/link";
import Slider from "react-slick";
import { useState, useEffect } from "react";

export default function BlogPost(props) {
const createMarkup = (props) => {
return { __html: props };
const createMarkup = (value) => {
return { __html: value };
};
const [headings, setHeadings] = useState();
useEffect(() => {
// const htmlString = String(createMarkup(props.html).__html);
// console.log(htmlString);
// const res = htmlString.match(/<h2[^>]+>(.*?)<\/h2>/g);
// console.log({ res });
// const res2 = res.map((i) => i.match(/\>(.*?)\</));
// console.log({ res2 });
const h2Tags = Array.from(
document.getElementById("component").getElementsByTagName("h2")
).map((item) => {
return {
id: item.id,
text: item.innerHTML
};
});
// console.log({ h2Tags });
setHeadings(h2Tags);
}, []);

return (
<>
Expand Down Expand Up @@ -79,25 +99,14 @@ export default function BlogPost(props) {
<div className={styles.index}>
<h3>Page Index</h3>
<ol>
<li>
<Link href="#post1">
<a className="linkUnderline">What is null?</a>
</Link>
</li>
<li>
<Link href="#post2">
<a className="linkUnderline">
Why do we need null safety?
</a>
</Link>
</li>
<li>
<Link href="#post3">
<a className="linkUnderline">
Declaring Non-Nullable Variables
</a>
</Link>
</li>
{headings &&
headings.map((heading) => (
<li key={heading.id}>
<a href={`#${heading.id}`}>
<p className="linkUnderline">{heading.text}</p>
</a>
</li>
))}
</ol>
</div>
<div className={styles.social}>
Expand Down Expand Up @@ -169,7 +178,10 @@ export default function BlogPost(props) {
</div>
</div>
<div className={styles.postContent}>
<div dangerouslySetInnerHTML={createMarkup(props.html)} />
<div
dangerouslySetInnerHTML={createMarkup(props.html)}
id="component"
/>
{/*
<p>He wrote this in 2007, but it is still valid today, especially in the case of tech startups.
Expand Down
2 changes: 1 addition & 1 deletion component/layout/BlogPost/SectionAuthor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function SectionAuthor(props) {
<div className="flex items-center justify-between mb-7">
<h2>About the Author</h2>
<span>
<Link href="#">
<Link href={`${username}/u`}>
<a className={`${styles.profileLink} linkUnderline`}>
View Profile
</a>
Expand Down
4 changes: 3 additions & 1 deletion component/layout/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default function Profile({ onLogout }) {

// Effects
useEffect(() => {
getIsAdmin();
if (userCookie?.role === "admin") {
getIsAdmin();
}
}, []);

// Functions
Expand Down
1 change: 0 additions & 1 deletion pages/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import TagService from "../services/TagService";
import { useState } from "react";

export async function getServerSideProps(context) {
const clickNo = 0;
const tagsArray = await TagService.getTags();
// console.log(tagsArray);
try {
Expand Down
Empty file added pages/forgot-password.js
Empty file.

0 comments on commit 6552f23

Please sign in to comment.