Skip to content

Commit

Permalink
sidebar nav for bylaws
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Feb 1, 2024
1 parent 79ac464 commit 691b8d5
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 16 deletions.
32 changes: 32 additions & 0 deletions _config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import resolveUrls from "lume/plugins/resolve_urls.ts";
import sass from "lume/plugins/sass.ts";
import sitemap from "lume/plugins/sitemap.ts";
import slugify_urls from "lume/plugins/slugify_urls.ts";
import toc from "https://deno.land/x/lume_markdown_plugins@v0.7.0/toc.ts";

import anchor from "npm:markdown-it-anchor";
import footnote from "npm:markdown-it-footnote";
Expand Down Expand Up @@ -45,6 +46,7 @@ site
.use(date())
.use(metas())
.use(resolveUrls())
.use(toc())
.use(slugify_urls({
replace: {
"&": "and",
Expand Down Expand Up @@ -127,6 +129,30 @@ site.data("url", (page: Page) => {
// deno-lint-ignore no-explicit-any
const FOUNDATION_DATA: Record<string, any> = safeLoad(Deno.readTextFileSync("./site/_includes/foundation.yml"));

// Ignore pages based on the foundation.yml file
site.addEventListener("beforeBuild", () => {
// deno-lint-ignore no-explicit-any
const structure: Record<string, any> | undefined = FOUNDATION_DATA;
if (structure) {
ignorePages(structure, "foundation/");
}
});

function ignorePages(structure: Record<string, unknown>, path: string) {
Object.entries(structure).forEach(([key, value]) => {
const obj = value as Record<string, unknown>;
if (obj != null) {
if (obj["ignore"]) {
console.log(`Ignoring ${path}${key}.md`);
site.ignore(`${path}${key}.md`);
} else if (!obj["layout"]) {
// this is not a page, it is a nested type
ignorePages(value as Record<string, unknown>, `${path}${key}/`);
}
}
});
}

site.preprocess([".html"], (pages) => {
for (const page of pages) {
// For foundation pages:
Expand Down Expand Up @@ -164,6 +190,12 @@ site.preprocess([".html"], (pages) => {
page.data.title = page.data.basename;
}
}

const entry = page.data.bylaws.nav.find((x: { href: string }) => x.href === page.data.url);
if (entry) {
page.data.ord = entry.ord;
}

page.data.github = page.src.entry?.path.replace("/foundation/", "https://github.com/commonhaus/foundation-draft/blob/main/");
}

Expand Down
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"assemble": "deno run --allow-read=. --allow-write=. ./.github/discussions.ts",
"discuss": "deno task query && deno task assemble",
"lastmod": "deno run --allow-run=\"git\" --allow-read=. --allow-write=. ./.github/lastmod.ts",
"checklinks": "deno run --allow-read --allow-net https://deno.land/x/link_checker/crawl.ts https://www.commonhaus.org"
"checklinks": "deno run --allow-read --allow-net https://deno.land/x/link_checker/crawl.ts https://www.commonhaus.org",
"checklocal": "deno run --allow-read --allow-net https://deno.land/x/link_checker/crawl.ts http://localhost:3000/"
},
"compilerOptions": {
"types": [
Expand Down
4 changes: 4 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions site/_data/bylaws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
nav:
- title: Preface
href: /bylaws/preface.html
ord: 1
- title: Purpose
href: /bylaws/purpose.html
ord: 2
- title: CF Membership
href: /bylaws/cf-membership.html
ord: 3
- title: CF Council
href: /bylaws/cf-council.html
ord: 4
- title: CF Advisory Board
href: /bylaws/cf-advisory-board.html
ord: 5
- title: Decision Making
href: /bylaws/decision-making.html
ord: 6
- title: Notice and Records
href: /bylaws/notice-records.html
ord: 7
- title: Liability and Indemnification
href: /bylaws/liability-indemnification.html
ord: 8
- title: Ammendments
href: /bylaws/amendments.html
ord: 9
- title: Bootstrapping
href: /bylaws/bootstrapping.html
ord: A
32 changes: 20 additions & 12 deletions site/_includes/foundation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ BOOTSTRAPPING:
bootstrapping.
date: 2024-01-23T19:48:42.000Z
layout: layouts/bylaws.vto
CONTRIBUTING:
ignore: true
date: 2024-01-15T22:39:01.000Z
layout: layouts/bylaws.vto
CODE_OF_CONDUCT:
url: /about/code_of_conduct.html
description: >
Expand Down Expand Up @@ -52,18 +56,6 @@ README:
to get involved.
date: 2024-01-26T22:07:28.000Z
layout: layouts/bylaws.vto
SECURITY:
url: /about/security.html
description: >
Guidance on securely reporting vulnerabilities in Commonhaus Foundation
projects. This resource outlines responsible disclosure protocols,
emphasizing direct communication with project maintainers and
confidentiality. It provides step-by-step instructions on appropriately
reporting security issues to ensure they are addressed effectively and
safely, safeguarding the integrity of the projects and the broader
community.
date: 2023-09-26T05:01:43.000Z
layout: layouts/bylaws.vto
TRADEMARKS:
url: /about/trademarks.html
description: >
Expand All @@ -77,6 +69,11 @@ TRADEMARKS:
date: 2023-11-08T18:27:19.000Z
layout: layouts/bylaws.vto
bylaws:
0-preface:
description: |
Overview of terms and concepts in the Commonhaus Foundation bylaws
layout: layouts/bylaws.vto
date: 2024-01-23T19:42:25.000Z
1-purpose:
description: >
Discover the foundational purpose and non-profit status of the Commonhaus
Expand Down Expand Up @@ -238,6 +235,17 @@ policies:
shape the foundation's activities and decisions.
date: 2023-12-15T14:15:46.000Z
layout: layouts/bylaws.vto
security-policy:
description: >
Guidance on securely reporting vulnerabilities in Commonhaus Foundation
projects. This resource outlines responsible disclosure protocols,
emphasizing direct communication with project maintainers and
confidentiality. It provides step-by-step instructions on appropriately
reporting security issues to ensure they are addressed effectively and
safely, safeguarding the integrity of the projects and the broader
community.
date: 2024-01-23T19:42:25.000Z
layout: layouts/bylaws.vto
succession-plan:
description: >
Understand the Commonhaus Foundation's approach to maintaining project
Expand Down
36 changes: 35 additions & 1 deletion site/_includes/layouts/bylaws.vto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Default page title
language: en
layout: layouts/base.vto
---
<article>
<article {{ if page.data.ord }}class="bylaws" style='--ord: "{{ page.data.ord }}";'{{ /if }}>
<header class="byline">
<a aria-label="Edit source on GitHub" href="{{ github }}" class="github">{{ page.data.svg.github }}</a>
</header>
Expand All @@ -13,3 +13,37 @@ layout: layouts/base.vto
<span class="posted">Last updated <time datetime="{{ page.data.date |> date('DATE') }}">{{ page.data.date |> date('d MMMM yyyy') }}</time></span>
</footer>
</article>
<aside class="bylaw-contents">
<nav aria-label="Bylaw Navigation" class="index">
<ul class="top-level">
{{- for x of page.data.bylaws.nav }}
<li data-ord="{{ x.ord }}">
<a href="{{ x.href }}" aria-label="{{ x.title }}" aria-haspopup="true">
<span aria-hidden="true" class="h-site-icon">{{ page.data.svg[x.icon] }}</span>
<span aria-hidden="true" class="h-site-text">{{ x.title }}</span>
</a>
{{- if page.data.url == x.href && toc.length }}
<div class="pagenav">
<ol>
{{- for item of toc }}
<li data-ord="{{ x.ord }}">
<a href="#{{ item.slug }}">{{ item.text }}</a>
{{- if item.children.length }}
<ol>
{{- for child of item.children }}
<li data-ord="{{ x.ord }}">
<a href="#{{ child.slug }}">{{ child.text }}</a>
</li>
{{- /for }}
</ol>
{{- /if }}
</li>
{{- /for }}
</ol>
</div>
{{- /if }}
</li>
{{- /for }}
</ul>
</nav>
</aside>
46 changes: 46 additions & 0 deletions site/_includes/scss/bylaws.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
article.bylaws {
h1 {counter-reset: h2}
h2 {counter-reset: h3}
h1:before {
content: var(--ord) ". "
}
h2:before {
counter-increment: h2;
content: var(--ord) "." counter(h2) ". "
}
h3:before {
counter-increment: h3;
content: var(--ord) "." counter(h2) "." counter(h3) ". "
}
}
aside.bylaw-contents {
background-color: var(--bg-secondary);
border-left: 1px dotted var(--bg-shadow);

ul.top-level {
> li:before {
content: attr(data-ord);
}
}
div.pagenav {
border-top: 1px dotted var(--bg-shadow);
background-color: var(--bg-primary);
border-bottom: 1px dotted var(--bg-shadow);
padding: .5em;
ol {
counter-reset: item;
padding: 0; // Removes the default padding

&:first-of-type {
padding-top: .5em;
}
}
li {
display: block;
}
li:before {
content: attr(data-ord) "." counters(item, ".") " ";
counter-increment: item
}
}
}
4 changes: 4 additions & 0 deletions site/_includes/scss/text.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a.header-anchor {
color: var(--text-normal);
text-decoration: none;
}
2 changes: 2 additions & 0 deletions site/assets/site.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@use 'colors';
@use 'layout';
@use 'navigation';
@use 'bylaws';
@use 'text';
@use 'fun';

// Screen reader only
Expand Down
4 changes: 2 additions & 2 deletions site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Checkout:

- [Announcements and notices](./activity/index.md#announcements-and-notices)
- [Reviews and Calls for input](./activity/index.md#reviews-and-calls-for-input)
- [Draft Bylaws](../foundation/bylaws/README.md)
- [Draft Policies](../foundation/policies/README.md)
- [Draft Bylaws](/bylaws/)
- [Draft Policies](/policies/)

0 comments on commit 691b8d5

Please sign in to comment.