Skip to content

Commit

Permalink
dynamic page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
thedannywahl committed Feb 27, 2024
1 parent aa026bf commit 3def771
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions isp-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const routes = [];
ParentBrands.map((brand) => {
routes.push({
path: `${brand.route}`,
element: <Markdown readme={brand.readme} />,
element: <Markdown readme={brand.readme} brand={brand.brandName} />,
errorElement: <ErrorPage />,
children: [
{
path: ":language",
element: <Markdown readme={brand.readme} />,
element: <Markdown readme={brand.readme} brand={brand.brandName} />,
},
],
});
Expand Down
9 changes: 6 additions & 3 deletions isp-site/src/routes/markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ import { getStrings, getLang } from "utils/langs";
import { Explorer } from "utils/explorer";

// Page
export default function Markdown({ readme }) {
export default function Markdown({ readme, brand }) {
const l = getLang(useParams().language);
const s = getStrings(strings, l);
const css = `.markdown .lang { display: none; } .markdown .lang.${l.toUpperCase()} { display: inherit; }`;
const md = readme;

const [content, setContent] = useState(`${s.loading}`);

useEffect(() => {
document.title = `${brand} Compliance Packages`;
});

useEffect(() => {
fetch(md)
.then((response) => {
Expand All @@ -52,12 +56,11 @@ export default function Markdown({ readme }) {
});

useEffect(() => {
const page = document.getElementsByTagName("body")[0].classList[0];
const branches = document.querySelectorAll(".markdown .contents");

if (branches.length > 0) {
for (const branch of branches) {
Explorer(page, branch, l).then((table) => {
Explorer(brand.toLowerCase(), branch, l).then((table) => {
ReactDOM.createRoot(branch).render(
<ReactMarkdown
children={table}
Expand Down

0 comments on commit 3def771

Please sign in to comment.