Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from async-go/jason-githubactions
Browse files Browse the repository at this point in the history
Make things more configurable
  • Loading branch information
jyavorska authored Nov 19, 2021
2 parents 6a34b09 + 1868505 commit 43cc457
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
25 changes: 22 additions & 3 deletions components/Header.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import { React } from "react";
import getConfig from "next/config";

export default function Header() {
function trimUrl(url) {
// Utility function to remove (index).md from page URLs
url = url.replace(/\/index\.md$/, "");
url = url.replace(/\.md$/, "");
return url;
}

function MakeLinks() {
const { publicRuntimeConfig } = getConfig();
const handbookName = publicRuntimeConfig.handbookName || "";
const headerLinks = publicRuntimeConfig.headerLinks;
return (
<>
{Object.keys(headerLinks).map((link) => (
<a key={link} href={trimUrl(headerLinks[link])}>
{link}
</a>
))}
</>
);
}

export default function Header() {
return (
<>
<header>
<nav>
<a href="/">{handbookName + " Home"}</a>
<MakeLinks />
</nav>
</header>
</>
Expand Down
21 changes: 13 additions & 8 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import rehypeHeadings from "rehype-autolink-headings";
import rehypeUrl from "rehype-url-inspector";
import url from "url";

function trimUrl(url) {
// Utility function to remove (index).md from page URLs
url = url.replace(/\/index\.md$/, "");
url = url.replace(/\.md$/, "");
return url;
}

const mdx = withMDX({
extension: /\.(md)$/,
options: {
Expand Down Expand Up @@ -43,11 +50,7 @@ const mdx = withMDX({
}
if (parsedUrl.pathname) {
// Trim (index).md extension from links
parsedUrl.pathname = parsedUrl.pathname.replace(
/\/index\.md$/,
""
);
parsedUrl.pathname = parsedUrl.pathname.replace(/\.md$/, "");
parsedUrl.pathname = trimUrl(parsedUrl.pathname);
match.node.properties[match.propertyName] =
url.format(parsedUrl);
}
Expand All @@ -65,9 +68,11 @@ export default mdx({
publicRuntimeConfig: {
// Be sure to customize these values for your site. Changing these values
// requires restarting the dev server.
handbookName:
// The name of the handbook as shown in the header
"Handbook Demo",
headerLinks: {
// A list of links for the header of every page, relative to root.
"Handbook Home": "/",
Team: "/company/team/index.md",
},
editRepositoryBase:
// This is the base path for the "edit this page" link. The relative path
// of the current page from the root is added. No trailing slash. If unset,
Expand Down
10 changes: 7 additions & 3 deletions pages/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Handbook home

This is what your future company handbook would look like if you use this template; this is the starting point, and you can easily customize from here. If you'd like to read more about how it works, check out the [README](https://github.com/async-go/company-handbook-template/blob/main/README.md) in our [GitLab project](https://github.com/async-go/company-handbook-template). The handbook is designed to be simple to use, and changes integrate into whatever version control you're already using, giving you a nice discussion flow before merging.
This is starting point of what your future company handbook would look like if you use this template. If you'd like to read more about how it works, check out the [README](https://github.com/async-go/company-handbook-template/blob/main/README.md) in our [GitHub project](https://github.com/async-go/company-handbook-template). The handbook is designed to be simple to use, and changes integrate into whatever version control you're already using, giving you a nice discussion flow before merging.

We have a lot of ideas on how to improve this handbook template to make it easier to get started. You can check out our public [issues tracker](https://github.com/async-go/company-handbook-template/issues) and see what we have planned or submit your own ideas.

## Company

- [Strategy](./strategy/index.md)
- [Team members](./company/team.md)

## Departments

Each of our departments has their own sub-section of the handbook.
Expand All @@ -13,7 +18,6 @@ Each of our departments has their own sub-section of the handbook.
- [Marketing](./marketing/index.md)
- [Sales](./sales/index.md)

## Quick links
## Other links

- [Editing this handbook](./editing/index.md)
- [Team members](./company/team.md)
3 changes: 3 additions & 0 deletions pages/strategy/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Strategy

Here is where you can document your company strategy.
4 changes: 2 additions & 2 deletions styles/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
.anchor-link {
padding-left: 1rem;
font-size: 1rem;
color: var(--text-light);
color: var(--border);
}

.anchor-link:hover {
padding-left: 1rem;
font-size: 1rem;
color: var(--accent);
color: var(--text-light);
}

header {
Expand Down

1 comment on commit 43cc457

@vercel
Copy link

@vercel vercel bot commented on 43cc457 Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.