You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB
JavaScript

"use strict";
const React = require("react");
const classnames = require("classnames");
const renderingContext = require("../rendering-context");
let currentURLContext = React.createContext();
function ExternalLinkIcon() {
return <img class="externalLink" src="/assets/external-link-icon.svg" alt="External link" />;
}
function MenuItem({ url, children }) {
let currentURL = React.useContext(currentURLContext);
let isCurrentPage = (url === currentURL);
return (
<a href={url} className={classnames("item", { active: isCurrentPage })}>
{children}
</a>
);
}
module.exports = function DefaultLayout({ mdxContent, meta, pageContext }) {
console.log({ mdxContent, meta, pageContext });
return (
<renderingContext.Provider value={{ mdxContent, meta, pageContext }}>
<currentURLContext.Provider value={meta.url}>
<html lang="en">
<head>
<meta charSet="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>{meta.title} - Nix Manual</title>
<link rel="stylesheet" href="/assets/bundle.css"/>
</head>
<body>
<div className="header">
<div className="inner">
<img className="logo" src="/assets/nix-logo.svg" alt="Nix logo"/>
{/* <div className="menu">
<MenuItem url="/">Home</MenuItem>
<MenuItem url="/getting-started">Getting started</MenuItem>
<MenuItem url="/modules">Validator index</MenuItem>
<MenuItem url="https://git.cryto.net/validatem">
Source code
<ExternalLinkIcon />
</MenuItem>
</div> */}
</div>
</div>
<div className="content">
<div className="inner">
{ mdxContent }
</div>
</div>
<div className="footer">
<div className="inner">
This is a proof-of-concept for the NixOS documentation, using <a href="https://mdxjs.com/">MDX</a> and <a href="https://shayu.it/">Shayu</a>.
</div>
</div>
</body>
</html>
</currentURLContext.Provider>
</renderingContext.Provider>
);
};