Skip to content

Commit

Permalink
chore:prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitgentleman committed Mar 23, 2024
1 parent 7c3e78e commit 0a18e60
Show file tree
Hide file tree
Showing 19 changed files with 1,061 additions and 1,059 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Deploy Quartz site to GitHub Pages

on:
push:
branches:
- matt

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-22.04
Expand All @@ -32,7 +32,7 @@ jobs:
uses: actions/upload-pages-artifact@v2
with:
path: public

deploy:
needs: build
environment:
Expand All @@ -42,4 +42,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v2
14 changes: 7 additions & 7 deletions quartz.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const config: QuartzConfig = {
},
colors: {
lightMode: {
light: "#FFFCF0",//background
light: "#FFFCF0", //background
lightgray: "#E6E4D9", //borders
gray: "#B7B5AC", // graph links, heavier borders, accents metadata & DONE text
darkgray: "#4e4e4e",//body text and icons
darkgray: "#4e4e4e", //body text and icons
dark: "#2b2b2b", //page title, header text and icons
secondary: "#D14D41",//link colour, current [[graph view|graph]] node
tertiary: "#4385BE",//hover states and visited [[graph view|graph]] nodes
highlight: "#E6E4D950" //internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
secondary: "#D14D41", //link colour, current [[graph view|graph]] node
tertiary: "#4385BE", //hover states and visited [[graph view|graph]] nodes
highlight: "#E6E4D950", //internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
},
darkMode: {
light: "#100F0F",
Expand All @@ -48,7 +48,7 @@ const config: QuartzConfig = {
dark: "#CECDC3",
secondary: "#D14D41",
tertiary: "#4385BE",
highlight: "#403E3C15"
highlight: "#403E3C15",
},
},
},
Expand All @@ -58,7 +58,7 @@ const config: QuartzConfig = {
Plugin.FrontMatter(),
Plugin.TableOfContents(),
Plugin.CreatedModifiedDate({
priority: ["git","frontmatter", "filesystem"], // you can add 'git' here for last modified from Git but this makes the build slower
priority: ["git", "frontmatter", "filesystem"], // you can add 'git' here for last modified from Git but this makes the build slower
}),
Plugin.Latex({ renderEngine: "katex" }),
Plugin.SyntaxHighlighting({
Expand Down
46 changes: 21 additions & 25 deletions quartz.layout.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import { PageLayout, SharedLayout } from "./quartz/cfg"
import * as Component from "./quartz/components"
import { SimpleSlug } from "./quartz/util/path";
import { SimpleSlug } from "./quartz/util/path"

// Define the filter function
function filterPages(note:any) {
function filterPages(note: any) {
// Define a list of titles to skip
const titlesToSkip = [
'test',
'about these notes',
'uses',
];
const hasStatus = note.frontmatter && 'status' in note.frontmatter;
const titlesToSkip = ["test", "about these notes", "uses"]
const hasStatus = note.frontmatter && "status" in note.frontmatter
// Convert the title to lowercase for case-insensitive comparison
const titleLower = note.frontmatter?.title.toLowerCase();
const titleLower = note.frontmatter?.title.toLowerCase()
// Check if the title is not in the list of titles to skip
const titleNotInSkipList = !titlesToSkip.includes(titleLower);
const titleNotInSkipList = !titlesToSkip.includes(titleLower)

// Return true if both conditions are met
return hasStatus && titleNotInSkipList;

// return !titlesToSkip.includes(titleLower);
return note.frontmatter && 'status' in note.frontmatter;
return hasStatus && titleNotInSkipList

// return !titlesToSkip.includes(titleLower);
return note.frontmatter && "status" in note.frontmatter
}
// components shared across all pages
export const sharedPageComponents: SharedLayout = {
Expand All @@ -40,7 +35,7 @@ export const defaultContentPageLayout: PageLayout = {
beforeBody: [
// Component.Breadcrumbs(),
Component.ArticleTitle(),
Component.ContentMeta({showComma:false}),
Component.ContentMeta({ showComma: false }),
Component.TagList(),
],
left: [
Expand Down Expand Up @@ -76,24 +71,25 @@ export const defaultContentPageLayout: PageLayout = {
fontSize: 0.4,
opacityScale: 0.8,
},
})),
}),
),
Component.DesktopOnly(
Component.RecentNotes({
linkToMore: "tags/writing" as SimpleSlug,
Component.RecentNotes({
linkToMore: "tags/writing" as SimpleSlug,
title: "Recent Writing",
filter: filterPages,
// limit: 5
})
// limit: 5
}),
),
Component.DesktopOnly(Component.Backlinks()),
Component.MobileOnly(Component.Backlinks()),
Component.MobileOnly(
Component.RecentNotes({
linkToMore: "tags/writing" as SimpleSlug,
Component.RecentNotes({
linkToMore: "tags/writing" as SimpleSlug,
title: "Recent Writing",
filter: filterPages,
// limit: 5
})
// limit: 5
}),
),
],
}
Expand Down
11 changes: 6 additions & 5 deletions quartz/components/ContentMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) {
const text = fileData.text
const status = fileData.frontmatter?.status

if (text) {
const segments: (string | JSX.Element)[] = []

Expand All @@ -43,16 +43,17 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
segments.push(displayedTime)
}
if (status) {
const linkDest = `../tags/${status}`;
const linkDest = `../tags/${status}`
const statusElement = (
<span className="essay-status">
<strong key="statusLabel">Status:</strong>
<a key="statusLink" href={linkDest} className="internal essay-status" data-tag={status}>
<span className="hash">#</span>{status}
<span className="hash">#</span>
{status}
</a>
</span>
);
segments.push(statusElement);
)
segments.push(statusElement)
}
const segmentsElements = segments.map((segment) => <span>{segment}</span>)

Expand Down
2 changes: 1 addition & 1 deletion quartz/components/RecentNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default ((userOpts?: Partial<Options>) => {
<li class="recent-li">
<div class="section">
<div class="desc">
<h4 data-status={status}>
<h4 data-status={status}>
<a href={resolveRelative(fileData.slug!, page.slug!)} class="internal">
{title}
</a>
Expand Down
2 changes: 1 addition & 1 deletion quartz/plugins/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export { SyntaxHighlighting } from "./syntax"
export { TableOfContents } from "./toc"
export { HardLineBreaks } from "./linebreaks"
export { TufteComponents } from "./tufte"
export { togglableTables } from "./toggleDiv"
export { togglableTables } from "./toggleDiv"
84 changes: 43 additions & 41 deletions quartz/plugins/transformers/toggleDiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,60 @@ import { Root } from "mdast"
import { visit } from "unist-util-visit"

export const togglableTables: QuartzTransformerPlugin<undefined> = () => {
return {
return {
name: "togglableTables",
markdownPlugins() {
const plugins: PluggableList = []
const plugins: PluggableList = []

plugins.push(() => {
return (tree: Root, _file) => {

visit(tree, 'paragraph', (node, index, parent) => {
if (parent && typeof index === 'number') {
const firstChild = node.children[0];
if (firstChild && firstChild.type === 'text' && firstChild.value.startsWith('???')) {
// Remove '???' and '!!!' from the first child's value.
const content = firstChild.value.slice(3, -3).trim();
plugins.push(() => {
return (tree: Root, _file) => {
visit(tree, "paragraph", (node, index, parent) => {
if (parent && typeof index === "number") {
const firstChild = node.children[0]
if (firstChild && firstChild.type === "text" && firstChild.value.startsWith("???")) {
// Remove '???' and '!!!' from the first child's value.
const content = firstChild.value.slice(3, -3).trim()

// Split the content into visible and hidden based on the '<<<'.
const splitIndex = content.indexOf('<<<');
const visibleContent = content.slice(0, splitIndex !== -1 ? splitIndex : content.length).trim();
const hiddenContent = splitIndex !== -1 ? content.slice(splitIndex + 3).trim() : '';
// Split the content into visible and hidden based on the '<<<'.
const splitIndex = content.indexOf("<<<")
const visibleContent = content
.slice(0, splitIndex !== -1 ? splitIndex : content.length)
.trim()
const hiddenContent = splitIndex !== -1 ? content.slice(splitIndex + 3).trim() : ""

// Split the visible content into lines and wrap each line in a span.
const visibleLines = visibleContent.split('\n').map(line => `<span>${line.trim()}</span>`).join('');
// Split the visible content into lines and wrap each line in a span.
const visibleLines = visibleContent
.split("\n")
.map((line) => `<span>${line.trim()}</span>`)
.join("")

// Transform the node into the appropriate HTML.
// This is a simplified example and may not cover all cases.
const html = `
// Transform the node into the appropriate HTML.
// This is a simplified example and may not cover all cases.
const html = `
<div class="parent-div">
<input type="checkbox" id="toggle${index}" class="toggle-checkbox">
<label for="toggle${index}" class="visible-div relative-container">
${visibleLines}
${hiddenContent ? `<span class="carrot-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="5.5,23.5 18.5,12 5.5,0.5" id="Outline_Icons"></polyline><rect fill="none" width="24" height="24" id="Frames-24px"></rect></svg></span>` : ''}
${hiddenContent ? `<span class="carrot-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><polyline fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="5.5,23.5 18.5,12 5.5,0.5" id="Outline_Icons"></polyline><rect fill="none" width="24" height="24" id="Frames-24px"></rect></svg></span>` : ""}
</label>
${hiddenContent ? `<div class="hidden-div">${hiddenContent}</div>` : ''}
${hiddenContent ? `<div class="hidden-div">${hiddenContent}</div>` : ""}
</div>
`;
parent.children[index] = {
type: 'html',
value: html,
};
// console.log("");

// console.log("~~",visibleContent)
// console.log("~~",content)

}
}
});
`
parent.children[index] = {
type: "html",
value: html,
}
// console.log("");

// console.log("~~",visibleContent)
// console.log("~~",content)
}
}
})

return plugins
}
}
})
}
})

return plugins
},
}
}

54 changes: 26 additions & 28 deletions quartz/plugins/transformers/tufte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { QuartzTransformerPlugin } from "../types"
export interface Options {
/** Replace {{ or:ONE|TWO|THREE }} with html select */
sidenoteComponent: boolean

}

const defaultOptions: Options = {
sidenoteComponent: true,
}

const sidenoterRegex = new RegExp(/\[\^(\d+)\](?!:)(.*?)/, "g");
const sidenoterRegex = new RegExp(/\[\^(\d+)\](?!:)(.*?)/, "g")

export const TufteComponents: QuartzTransformerPlugin<Partial<Options> | undefined> = (
userOpts,
Expand All @@ -20,40 +19,39 @@ export const TufteComponents: QuartzTransformerPlugin<Partial<Options> | undefin
name: "TufteComponents",
textTransform(_ctx, src: string | Buffer) {
if (opts.sidenoteComponent) {
let newSRC: string;
let newSRC: string
if (Buffer.isBuffer(src)) {
newSRC = src.toString();
} else{
newSRC = src;
newSRC = src.toString()
} else {
newSRC = src
}


src = newSRC.replaceAll(sidenoterRegex, (value: string, ...capture: string[]) => {
const [match, text] = capture;
const sidenoterContentRegex = new RegExp(`\\[\\^${match}\\]:\\s*(.*)`);
const sidenoteContentMatch = newSRC.match(sidenoterContentRegex);
if (!sidenoteContentMatch) {
console.error(`Sidenote content not found for reference [^${match}]`);
return value; // Return the original markdown if the sidenote content is not found
}

const sidenote = `<label for="sn-${match}" class="margin-toggle sidenote-number"><sup>${match}</sup></label>
const [match, text] = capture
const sidenoterContentRegex = new RegExp(`\\[\\^${match}\\]:\\s*(.*)`)
const sidenoteContentMatch = newSRC.match(sidenoterContentRegex)
if (!sidenoteContentMatch) {
console.error(`Sidenote content not found for reference [^${match}]`)
return value // Return the original markdown if the sidenote content is not found
}

const sidenote = `<label for="sn-${match}" class="margin-toggle sidenote-number"><sup>${match}</sup></label>
<input type="checkbox" id="sn-${match}" class="margin-toggle"/>
<span class="sidenote">${sidenoteContentMatch[1]}</span>`;
return sidenote;
});
<span class="sidenote">${sidenoteContentMatch[1]}</span>`
return sidenote
})
}

// src = src.toString()
// const matches = [...src.matchAll(sidenoterContentRegex)];

// for (const match of matches) {
// const foundMatch = match[0]; // The whole match
// const capturedText = match[1]; // The captured text inside the brackets
// src = src.toString()
// const matches = [...src.matchAll(sidenoterContentRegex)];

// console.log(`Found match: ${foundMatch}`);
// console.log(`Captured text: ${capturedText}`);
// }
// for (const match of matches) {
// const foundMatch = match[0]; // The whole match
// const capturedText = match[1]; // The captured text inside the brackets

// console.log(`Found match: ${foundMatch}`);
// console.log(`Captured text: ${capturedText}`);
// }
return src
},
}
Expand Down
Loading

0 comments on commit 0a18e60

Please sign in to comment.