Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Aug 10, 2024
1 parent cdd833d commit 6f94471
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 26 deletions.
7 changes: 5 additions & 2 deletions plugin-css-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as acornWalk from "acorn-walk";
import * as acorn from "acorn";
import { hashString } from "@greenwood/cli/src/lib/hashing-utils.js";
import { importAttributes } from "acorn-import-attributes"; // comes from Greenwood
import { resolveForRelativeUrl } from '@greenwood/cli/src/lib/resource-utils.js';
import { resolveForRelativeUrl } from "@greenwood/cli/src/lib/resource-utils.js";

function getCssModulesMap(compilation) {
const locationUrl = new URL("./__css-modules-map.json", compilation.context.scratchDir);
Expand Down Expand Up @@ -135,7 +135,10 @@ class CssModulesResource extends ResourceInterface {
const { pathname, searchParams } = url;
const params =
url.searchParams.size > 0 ? `${searchParams.toString()}&type=css-module` : "type=css-module";
const workspaceUrl = await resolveForRelativeUrl(new URL(`.${pathname}`, userWorkspace), userWorkspace);
const workspaceUrl = await resolveForRelativeUrl(
new URL(`.${pathname}`, userWorkspace),
userWorkspace,
);
const root =
url.protocol === "file:"
? new URL(`file://${pathname}`).href
Expand Down
4 changes: 2 additions & 2 deletions src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default class Header extends HTMLElement {
const nav = JSON.parse(this.getAttribute("nav") || "[]").sort((a, b) =>
a.data.order > b.data.order ? 1 : -1,
);
console.log('HEADER NAV', { nav });
const template = document.createElement('template');
console.log("HEADER NAV", { nav });
const template = document.createElement("template");

template.innerHTML = `
<header>
Expand Down
2 changes: 1 addition & 1 deletion src/components/side-nav/side-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class SideNav extends HTMLElement {
}
});
});
console.log('SIDE NAV', { content, sections });
console.log("SIDE NAV", { content, sections });

this.innerHTML = `
<h2>${heading}</h2>
Expand Down
20 changes: 10 additions & 10 deletions src/components/table-of-contents/table-of-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ import { getContent } from "@greenwood/cli/src/data/queries.js";

export default class TableOfContents extends HTMLElement {
async connectedCallback() {
const title = this.getAttribute('title') ?? '';
const page = (await getContent()).find((page) => page.title === title);
const title = this.getAttribute("title") ?? "";
const page = (await getContent()).find((page) => page.title === title);
// maybe call the frontmatter toc as well?
const { tableOfContents = [] } = page?.data ?? {};
console.log({ title, page, tableOfContents });

if (tableOfContents.length === 0) {
return
return;
}

this.innerHTML = `
<h2>On This Page (${title})</h2>
<ol>
${
tableOfContents.map((item) => {
${tableOfContents
.map((item) => {
const { content, slug } = item;
return `
<li><a href="#${slug}">${content}</a></li>
`
}).join('')
}
`;
})
.join("")}
</ol>
`
`;
}
}

customElements.define('app-toc', TableOfContents);
customElements.define("app-toc", TableOfContents);
6 changes: 5 additions & 1 deletion src/pages/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<html>
<head>
<title>Greenwood - ${globalThis.page.title}</title>
<script type="module" src="../../components/blog-posts-list/blog-posts-list.js" data-gwd-opt="static"></script>
<script
type="module"
src="../../components/blog-posts-list/blog-posts-list.js"
data-gwd-opt="static"
></script>
<style>
.content {
margin: 0 auto;
Expand Down
8 changes: 4 additions & 4 deletions src/pages/docs/basics/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Change the port
```js
export default {
devServer: {
port: 4001
}
}
```
port: 4001,
},
};
```
2 changes: 1 addition & 1 deletion src/pages/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ order: 1
template: docs
---

# Welcome to our Documentation
# Welcome to our Documentation
2 changes: 1 addition & 1 deletion src/pages/docs/rendering/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ src/
pages/
index.html
products.js
```
```
2 changes: 1 addition & 1 deletion src/pages/playlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<body>
<h1>Welcome to the Player!</h1>
<app-player name="${globalThis.page.name}" playlist='${globalThis.page.songs}'></app-player>
<app-player name="${globalThis.page.name}" playlist="${globalThis.page.songs}"></app-player>
<p style="text-align: center">
(^^^ Custom Element being passed custom HTML (active) frontmatter)
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</head>

<body>
<app-header nav='${globalThis.collection.nav}'></app-header>
<app-header nav="${globalThis.collection.nav}"></app-header>

<main>
<page-outlet></page-outlet>
Expand Down
8 changes: 6 additions & 2 deletions src/templates/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<head>
<title>Greenwood - ${globalThis.page.title}</title>
<script type="module" src="../components/side-nav/side-nav.js" data-gwd-opt="static"></script>
<script type="module" src="../components/table-of-contents/table-of-contents.js" data-gwd-opt="static"></script>
<script
type="module"
src="../components/table-of-contents/table-of-contents.js"
data-gwd-opt="static"
></script>
<style>
.sidebar,
.content,
Expand All @@ -24,7 +28,7 @@
}

.toc {
width: 20%
width: 20%;
}

app-toc {
Expand Down

0 comments on commit 6f94471

Please sign in to comment.