pnpm run format

This commit is contained in:
Miguel Pimentel 2024-06-20 17:46:04 +00:00 committed by GitHub
parent f734a00d85
commit e1f7366ee9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 197 additions and 114 deletions

View File

@ -1,15 +1,10 @@
# 🌱 Forgetful Notes
![code size](https://img.shields.io/github/languages/code-size/semanticdata/forgetful-notes)
![repository size](https://img.shields.io/github/repo-size/semanticdata/forgetful-notes)
![commits](https://img.shields.io/github/commit-activity/t/semanticdata/forgetful-notes)
![last commit](https://img.shields.io/github/last-commit/semanticdata/forgetful-notes)
![is website up?](https://img.shields.io/website/https/forgetfulnotes.com.svg)
![code size](https://img.shields.io/github/languages/code-size/semanticdata/forgetful-notes) ![repository size](https://img.shields.io/github/repo-size/semanticdata/forgetful-notes) ![commits](https://img.shields.io/github/commit-activity/t/semanticdata/forgetful-notes) ![last commit](https://img.shields.io/github/last-commit/semanticdata/forgetful-notes) ![is website up?](https://img.shields.io/website/https/forgetfulnotes.com.svg)
[Forgetful Notes](https://forgetfulnotes.com) is my _digital garden_ of knowledge. It serves as a platform for my learning and creative endeavours. A space for thinking through, building upon, and coming back to.
[![Github Pages](https://img.shields.io/badge/github%20pages-121013?style=for-the-badge&logo=github&logoColor=white)](https://forgetfulnotes.com/)
[![Vercel](https://img.shields.io/badge/vercel-%23000000.svg?style=for-the-badge&logo=vercel&logoColor=white)](https://forgetful-notes.vercel.app/)
[![Github Pages](https://img.shields.io/badge/github%20pages-121013?style=for-the-badge&logo=github&logoColor=white)](https://forgetfulnotes.com/) [![Vercel](https://img.shields.io/badge/vercel-%23000000.svg?style=for-the-badge&logo=vercel&logoColor=white)](https://forgetful-notes.vercel.app/)
## ✨ Features
@ -65,7 +60,7 @@ npx quartz <command> --help
You can add custom CSS code within `/quartz/styles/custom.scss`. You will then need to uncomment line 4 of `/quartz/styles/base.scss` to have it take effect.
| Used in: | Font Family | Previous Font |
| --- | :---: | :---: |
| --- | :-: | :-: |
| Headers | [Bitter](https://fonts.google.com/specimen/Bitter) | [Schibsted Grotesk](https://fonts.google.com/specimen/Schibsted+Grotesk) |
| Body | [Poppins](https://fonts.google.com/specimen/Poppins) | [Source Sans Pro](https://fonts.google.com/specimen/Source+Sans+3) |
| Code | [Fira Mono](https://fonts.google.com/specimen/Fira+Mono) | [IBM Plex Mono](https://fonts.google.com/specimen/IBM+Plex+Mono) |
@ -85,7 +80,6 @@ All content for the site is written in _Markdown_ within [Obsidian](https://obsi
### 🔨 Build only
```yml
steps:
- uses: actions/checkout@v4

View File

@ -48,4 +48,5 @@ toolkit.legacyUserProfileCustomizations.stylesheets
2. Restart Firefox and test it out!
[^1]: In windows, `%appdata%` is equivalent to `C:\Users\{username}\AppData\Roaming`.
[^2]: After Firefox 107, `#sidebar` was deprecated, and `#sidebar-box` was introduced as a replacement.

View File

@ -59,9 +59,9 @@ All _mobile-first-designs_ media queries and 1 _desktop-first-design_ media quer
------------------------------------------------------------------
// USING THE MIXINS
// Example - Writing a custom bootstrap-like container from scratch
------------------------------------------------------------------
---
.container {
--------------------------------------------------------------- .container {
margin: 0 auto;
width: 100%;
@include screen-min(768px) {

View File

@ -15,4 +15,5 @@ Relational data uses a structure and language consistent with first-order predic
The purpose of the relational model is to provide a declarative method for specifying data and queries: users directly state what information the database contains and what information they want from it, and let the database management system software take care of describing data structures for storing the data and retrieval procedures for answering queries.
[^1]: First-order logic—also known as first-order predicate calculus—is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science.
[^2]: In mathematics, a tuple is a finite sequence or ordered list of numbers or, more generally, mathematical objects, which are called the elements of the tuple.

View File

@ -68,7 +68,7 @@ const config: QuartzConfig = {
Plugin.TableOfContents(),
Plugin.CrawlLinks({markdownLinkResolution: "shortest"}),
Plugin.Description(),
Plugin.Latex({ renderEngine: "katex" }),
Plugin.Latex({renderEngine: "katex"}),
],
filters: [Plugin.RemoveDrafts()],
emitters: [

View File

@ -1,5 +1,5 @@
import { PageLayout, SharedLayout } from "./quartz/cfg";
import * as Component from "./quartz/components";
import {PageLayout, SharedLayout} from "./quartz/cfg"
import * as Component from "./quartz/components"
// components shared across all pages
export const sharedPageComponents: SharedLayout = {
@ -14,7 +14,7 @@ export const sharedPageComponents: SharedLayout = {
GitHub: "https://github.com/semanticdata/forgetful-notes/",
},
}),
};
}
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
@ -50,7 +50,7 @@ export const defaultContentPageLayout: PageLayout = {
// Component.DesktopOnly(Component.TableOfContents()),
// Component.Backlinks(),
// ],
};
}
// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
@ -73,4 +73,4 @@ export const defaultListPageLayout: PageLayout = {
// Component.DesktopOnly(Component.Explorer()),
// ],
// right: [],
};
}

View File

@ -183,7 +183,8 @@ export function ExplorerNode({
const isDefaultOpen = opts.folderDefaultState === "open"
// Calculate current folderPath
const folderPath = node.name !== "" ? joinSegments(fullPath ?? "", node.name) : ""
const folderPath =
node.name !== "" ? joinSegments(fullPath ?? "", node.name) : ""
const href = resolveRelative(fileData.slug!, folderPath as SimpleSlug) + "/"
return (

View File

@ -1,7 +1,11 @@
import { i18n } from "../../i18n"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types"
import {i18n} from "../../i18n"
import {
QuartzComponent,
QuartzComponentConstructor,
QuartzComponentProps,
} from "../types"
const NotFound: QuartzComponent = ({ cfg }: QuartzComponentProps) => {
const NotFound: QuartzComponent = ({cfg}: QuartzComponentProps) => {
// If baseUrl contains a pathname after the domain, use this as the home link
const url = new URL(`https://${cfg.baseUrl ?? "example.com"}`)
const baseDir = url.pathname
@ -15,4 +19,4 @@ const NotFound: QuartzComponent = ({ cfg }: QuartzComponentProps) => {
)
}
export default (() => NotFound) satisfies QuartzComponentConstructor
export default (() => NotFound) satisfies QuartzComponentConstructor

View File

@ -1,4 +1,4 @@
import { Translation, CalloutTranslation } from "./locales/definition"
import {Translation, CalloutTranslation} from "./locales/definition"
import en from "./locales/en-US"
import fr from "./locales/fr-FR"
import it from "./locales/it-IT"
@ -61,6 +61,7 @@ export const TRANSLATIONS = {
} as const
export const defaultTranslation = "en-US"
export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation]
export const i18n = (locale: ValidLocale): Translation =>
TRANSLATIONS[locale ?? defaultTranslation]
export type ValidLocale = keyof typeof TRANSLATIONS
export type ValidCallout = keyof CalloutTranslation
export type ValidCallout = keyof CalloutTranslation

View File

@ -1,4 +1,4 @@
import { Translation } from "./definition"
import {Translation} from "./definition"
export default {
propertyDefaults: {
@ -40,10 +40,10 @@ export default {
},
recentNotes: {
title: "Zuletzt bearbeitete Seiten",
seeRemainingMore: ({ remaining }) => `${remaining} weitere ansehen →`,
seeRemainingMore: ({remaining}) => `${remaining} weitere ansehen →`,
},
transcludes: {
transcludeOf: ({ targetSlug }) => `Transklusion von ${targetSlug}`,
transcludeOf: ({targetSlug}) => `Transklusion von ${targetSlug}`,
linkToOriginal: "Link zum Original",
},
search: {
@ -54,31 +54,36 @@ export default {
title: "Inhaltsverzeichnis",
},
contentMeta: {
readingTime: ({ minutes }) => `${minutes} min read`,
readingTime: ({minutes}) => `${minutes} min read`,
},
},
pages: {
rss: {
recentNotes: "Zuletzt bearbeitete Seiten",
lastFewNotes: ({ count }) => `Letzte ${count} Seiten`,
lastFewNotes: ({count}) => `Letzte ${count} Seiten`,
},
error: {
title: "Nicht gefunden",
notFound: "Diese Seite ist entweder nicht öffentlich oder existiert nicht.",
notFound:
"Diese Seite ist entweder nicht öffentlich oder existiert nicht.",
home: "Return to Homepage",
},
folderContent: {
folder: "Ordner",
itemsUnderFolder: ({ count }) =>
count === 1 ? "1 Datei in diesem Ordner." : `${count} Dateien in diesem Ordner.`,
itemsUnderFolder: ({count}) =>
count === 1
? "1 Datei in diesem Ordner."
: `${count} Dateien in diesem Ordner.`,
},
tagContent: {
tag: "Tag",
tagIndex: "Tag-Übersicht",
itemsUnderTag: ({ count }) =>
count === 1 ? "1 Datei mit diesem Tag." : `${count} Dateien mit diesem Tag.`,
showingFirst: ({ count }) => `Die ersten ${count} Tags werden angezeigt.`,
totalTags: ({ count }) => `${count} Tags insgesamt.`,
itemsUnderTag: ({count}) =>
count === 1
? "1 Datei mit diesem Tag."
: `${count} Dateien mit diesem Tag.`,
showingFirst: ({count}) => `Die ersten ${count} Tags werden angezeigt.`,
totalTags: ({count}) => `${count} Tags insgesamt.`,
},
},
} as const satisfies Translation
} as const satisfies Translation

View File

@ -1,4 +1,4 @@
import { Translation } from "./definition"
import {Translation} from "./definition"
export default {
propertyDefaults: {
@ -40,10 +40,10 @@ export default {
},
recentNotes: {
title: "یادداشت‌های اخیر",
seeRemainingMore: ({ remaining }) => `${remaining} یادداشت دیگر →`,
seeRemainingMore: ({remaining}) => `${remaining} یادداشت دیگر →`,
},
transcludes: {
transcludeOf: ({ targetSlug }) => `از ${targetSlug}`,
transcludeOf: ({targetSlug}) => `از ${targetSlug}`,
linkToOriginal: "پیوند به اصلی",
},
search: {
@ -54,13 +54,13 @@ export default {
title: "فهرست",
},
contentMeta: {
readingTime: ({ minutes }) => `زمان تقریبی مطالعه: ${minutes} دقیقه`,
readingTime: ({minutes}) => `زمان تقریبی مطالعه: ${minutes} دقیقه`,
},
},
pages: {
rss: {
recentNotes: "یادداشت‌های اخیر",
lastFewNotes: ({ count }) => `${count} یادداشت اخیر`,
lastFewNotes: ({count}) => `${count} یادداشت اخیر`,
},
error: {
title: "یافت نشد",
@ -69,16 +69,18 @@ export default {
},
folderContent: {
folder: "پوشه",
itemsUnderFolder: ({ count }) =>
count === 1 ? ".یک مطلب در این پوشه است" : `${count} مطلب در این پوشه است.`,
itemsUnderFolder: ({count}) =>
count === 1
? ".یک مطلب در این پوشه است"
: `${count} مطلب در این پوشه است.`,
},
tagContent: {
tag: "برچسب",
tagIndex: "فهرست برچسب‌ها",
itemsUnderTag: ({ count }) =>
itemsUnderTag: ({count}) =>
count === 1 ? "یک مطلب با این برچسب" : `${count} مطلب با این برچسب.`,
showingFirst: ({ count }) => `در حال نمایش ${count} برچسب.`,
totalTags: ({ count }) => `${count} برچسب یافت شد.`,
showingFirst: ({count}) => `در حال نمایش ${count} برچسب.`,
totalTags: ({count}) => `${count} برچسب یافت شد.`,
},
},
} as const satisfies Translation

View File

@ -1,4 +1,4 @@
import { Translation } from "./definition"
import {Translation} from "./definition"
export default {
propertyDefaults: {
@ -40,10 +40,10 @@ export default {
},
recentNotes: {
title: "Najnowsze notatki",
seeRemainingMore: ({ remaining }) => `Zobacz ${remaining} nastepnych →`,
seeRemainingMore: ({remaining}) => `Zobacz ${remaining} nastepnych →`,
},
transcludes: {
transcludeOf: ({ targetSlug }) => `Osadzone ${targetSlug}`,
transcludeOf: ({targetSlug}) => `Osadzone ${targetSlug}`,
linkToOriginal: "Łącze do oryginału",
},
search: {
@ -54,13 +54,13 @@ export default {
title: "Spis treści",
},
contentMeta: {
readingTime: ({ minutes }) => `${minutes} min. czytania `,
readingTime: ({minutes}) => `${minutes} min. czytania `,
},
},
pages: {
rss: {
recentNotes: "Najnowsze notatki",
lastFewNotes: ({ count }) => `Ostatnie ${count} notatek`,
lastFewNotes: ({count}) => `Ostatnie ${count} notatek`,
},
error: {
title: "Nie znaleziono",
@ -69,16 +69,20 @@ export default {
},
folderContent: {
folder: "Folder",
itemsUnderFolder: ({ count }) =>
count === 1 ? "W tym folderze jest 1 element." : `Elementów w folderze: ${count}.`,
itemsUnderFolder: ({count}) =>
count === 1
? "W tym folderze jest 1 element."
: `Elementów w folderze: ${count}.`,
},
tagContent: {
tag: "Znacznik",
tagIndex: "Spis znaczników",
itemsUnderTag: ({ count }) =>
count === 1 ? "Oznaczony 1 element." : `Elementów z tym znacznikiem: ${count}.`,
showingFirst: ({ count }) => `Pokazuje ${count} pierwszych znaczników.`,
totalTags: ({ count }) => `Znalezionych wszystkich znaczników: ${count}.`,
itemsUnderTag: ({count}) =>
count === 1
? "Oznaczony 1 element."
: `Elementów z tym znacznikiem: ${count}.`,
showingFirst: ({count}) => `Pokazuje ${count} pierwszych znaczników.`,
totalTags: ({count}) => `Znalezionych wszystkich znaczników: ${count}.`,
},
},
} as const satisfies Translation

View File

@ -1,23 +1,33 @@
import { QuartzTransformerPlugin } from "../types"
import { Root, Html, BlockContent, DefinitionContent, Paragraph, Code } from "mdast"
import { Element, Literal, Root as HtmlRoot } from "hast"
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
import { slug as slugAnchor } from "github-slugger"
import {QuartzTransformerPlugin} from "../types"
import {
Root,
Html,
BlockContent,
DefinitionContent,
Paragraph,
Code,
} from "mdast"
import {Element, Literal, Root as HtmlRoot} from "hast"
import {
ReplaceFunction,
findAndReplace as mdastFindReplace,
} from "mdast-util-find-and-replace"
import {slug as slugAnchor} from "github-slugger"
import rehypeRaw from "rehype-raw"
import { SKIP, visit } from "unist-util-visit"
import {SKIP, visit} from "unist-util-visit"
import path from "path"
import { splitAnchor } from "../../util/path"
import { JSResource } from "../../util/resources"
import {splitAnchor} from "../../util/path"
import {JSResource} from "../../util/resources"
// @ts-ignore
import calloutScript from "../../components/scripts/callout.inline.ts"
// @ts-ignore
import checkboxScript from "../../components/scripts/checkbox.inline.ts"
import { FilePath, pathToRoot, slugTag, slugifyFilePath } from "../../util/path"
import { toHast } from "mdast-util-to-hast"
import { toHtml } from "hast-util-to-html"
import { PhrasingContent } from "mdast-util-find-and-replace/lib"
import { capitalize } from "../../util/lang"
import { PluggableList } from "unified"
import {FilePath, pathToRoot, slugTag, slugifyFilePath} from "../../util/path"
import {toHast} from "mdast-util-to-hast"
import {toHtml} from "hast-util-to-html"
import {PhrasingContent} from "mdast-util-find-and-replace/lib"
import {capitalize} from "../../util/lang"
import {PluggableList} from "unified"
export interface Options {
comments: boolean
@ -91,7 +101,8 @@ const arrowMapping: Record<string, string> = {
}
function canonicalizeCallout(calloutName: string): keyof typeof calloutMapping {
const normalizedCallout = calloutName.toLowerCase() as keyof typeof calloutMapping
const normalizedCallout =
calloutName.toLowerCase() as keyof typeof calloutMapping
// if callout is not recognized, make it a custom one
return calloutMapping[normalizedCallout] ?? calloutName
}
@ -135,21 +146,24 @@ const tagRegex = new RegExp(
"gu",
)
const blockReferenceRegex = new RegExp(/\^([-_A-Za-z0-9]+)$/, "g")
const ytLinkRegex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
const ytLinkRegex =
/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
const ytPlaylistLinkRegex = /[?&]list=([^#?&]*)/
const videoExtensionRegex = new RegExp(/\.(mp4|webm|ogg|avi|mov|flv|wmv|mkv|mpg|mpeg|3gp|m4v)$/)
const videoExtensionRegex = new RegExp(
/\.(mp4|webm|ogg|avi|mov|flv|wmv|mkv|mpg|mpeg|3gp|m4v)$/,
)
const wikilinkImageEmbedRegex = new RegExp(
/^(?<alt>(?!^\d*x?\d*$).*?)?(\|?\s*?(?<width>\d+)(x(?<height>\d+))?)?$/,
)
export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options> | undefined> = (
userOpts,
) => {
const opts = { ...defaultOptions, ...userOpts }
export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<
Partial<Options> | undefined
> = (userOpts) => {
const opts = {...defaultOptions, ...userOpts}
const mdastToHtml = (ast: PhrasingContent | Paragraph) => {
const hast = toHast(ast, { allowDangerousHtml: true })!
return toHtml(hast, { allowDangerousHtml: true })
const hast = toHast(ast, {allowDangerousHtml: true})!
return toHtml(hast, {allowDangerousHtml: true})
}
return {
@ -202,7 +216,9 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
const [fp, anchor] = splitAnchor(`${rawFp ?? ""}${rawHeader ?? ""}`)
const blockRef = Boolean(anchor?.startsWith("^")) ? "^" : ""
const displayAnchor = anchor ? `#${blockRef}${anchor.trim().replace(/^#+/, "")}` : ""
const displayAnchor = anchor
? `#${blockRef}${anchor.trim().replace(/^#+/, "")}`
: ""
const displayAlias = rawAlias ?? rawHeader?.replace("#", "|") ?? ""
const embedDisplay = value.startsWith("!") ? "!" : ""
@ -238,7 +254,17 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
if (value.startsWith("!")) {
const ext: string = path.extname(fp).toLowerCase()
const url = slugifyFilePath(fp as FilePath)
if ([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".svg", ".webp"].includes(ext)) {
if (
[
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".svg",
".webp",
].includes(ext)
) {
const match = wikilinkImageEmbedRegex.exec(alias ?? "")
const alt = match?.groups?.alt ?? ""
const width = match?.groups?.width ?? "auto"
@ -254,13 +280,23 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
},
},
}
} else if ([".mp4", ".webm", ".ogv", ".mov", ".mkv"].includes(ext)) {
} else if (
[".mp4", ".webm", ".ogv", ".mov", ".mkv"].includes(ext)
) {
return {
type: "html",
value: `<video src="${url}" controls></video>`,
}
} else if (
[".mp3", ".webm", ".wav", ".m4a", ".ogg", ".3gp", ".flac"].includes(ext)
[
".mp3",
".webm",
".wav",
".m4a",
".ogg",
".3gp",
".flac",
].includes(ext)
) {
return {
type: "html",
@ -275,7 +311,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
const block = anchor
return {
type: "html",
data: { hProperties: { transclude: true } },
data: {hProperties: {transclude: true}},
value: `<blockquote class="transclude" data-url="${url}" data-block="${block}"><a href="${
url + anchor
}" class="transclude-inner">Transclude of ${url}${block}</a></blockquote>`,
@ -368,18 +404,24 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
if (typeof replace === "string") {
node.value = node.value.replace(regex, replace)
} else {
node.value = node.value.replace(regex, (substring: string, ...args) => {
const replaceValue = replace(substring, ...args)
if (typeof replaceValue === "string") {
return replaceValue
} else if (Array.isArray(replaceValue)) {
return replaceValue.map(mdastToHtml).join("")
} else if (typeof replaceValue === "object" && replaceValue !== null) {
return mdastToHtml(replaceValue)
} else {
return substring
}
})
node.value = node.value.replace(
regex,
(substring: string, ...args) => {
const replaceValue = replace(substring, ...args)
if (typeof replaceValue === "string") {
return replaceValue
} else if (Array.isArray(replaceValue)) {
return replaceValue.map(mdastToHtml).join("")
} else if (
typeof replaceValue === "object" &&
replaceValue !== null
) {
return mdastToHtml(replaceValue)
} else {
return substring
}
},
)
}
}
})
@ -392,7 +434,11 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
plugins.push(() => {
return (tree: Root, _file) => {
visit(tree, "image", (node, index, parent) => {
if (parent && index != undefined && videoExtensionRegex.test(node.url)) {
if (
parent &&
index != undefined &&
videoExtensionRegex.test(node.url)
) {
const newNode: Html = {
type: "html",
value: `<video controls src="${node.url}"></video>`,
@ -416,7 +462,10 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
// find first line and callout content
const [firstChild, ...calloutContent] = node.children
if (firstChild.type !== "paragraph" || firstChild.children[0]?.type !== "text") {
if (
firstChild.type !== "paragraph" ||
firstChild.children[0]?.type !== "text"
) {
return
}
@ -427,18 +476,31 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
const match = firstLine.match(calloutRegex)
if (match && match.input) {
const [calloutDirective, typeString, calloutMetaData, collapseChar] = match
const calloutType = canonicalizeCallout(typeString.toLowerCase())
const [
calloutDirective,
typeString,
calloutMetaData,
collapseChar,
] = match
const calloutType = canonicalizeCallout(
typeString.toLowerCase(),
)
const collapse = collapseChar === "+" || collapseChar === "-"
const defaultState = collapseChar === "-" ? "collapsed" : "expanded"
const titleContent = match.input.slice(calloutDirective.length).trim()
const useDefaultTitle = titleContent === "" && restOfTitle.length === 0
const defaultState =
collapseChar === "-" ? "collapsed" : "expanded"
const titleContent = match.input
.slice(calloutDirective.length)
.trim()
const useDefaultTitle =
titleContent === "" && restOfTitle.length === 0
const titleNode: Paragraph = {
type: "paragraph",
children: [
{
type: "text",
value: useDefaultTitle ? capitalize(typeString) : titleContent + " ",
value: useDefaultTitle
? capitalize(typeString)
: titleContent + " ",
},
...restOfTitle,
],
@ -458,7 +520,8 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
</div>`,
}
const blockquoteContent: (BlockContent | DefinitionContent)[] = [titleHtml]
const blockquoteContent: (BlockContent | DefinitionContent)[] =
[titleHtml]
if (remainingText.length > 0) {
blockquoteContent.push({
type: "paragraph",
@ -486,7 +549,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
node.data = {
hProperties: {
...(node.data?.hProperties ?? {}),
className: classNames.join(" "),
"className": classNames.join(" "),
"data-callout": calloutType,
"data-callout-fold": collapse,
"data-callout-metadata": calloutMetaData,
@ -614,10 +677,14 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
plugins.push(() => {
return (tree: HtmlRoot) => {
visit(tree, "element", (node) => {
if (node.tagName === "img" && typeof node.properties.src === "string") {
if (
node.tagName === "img" &&
typeof node.properties.src === "string"
) {
const match = node.properties.src.match(ytLinkRegex)
const videoId = match && match[2].length == 11 ? match[2] : null
const playlistId = node.properties.src.match(ytPlaylistLinkRegex)?.[1]
const playlistId =
node.properties.src.match(ytPlaylistLinkRegex)?.[1]
if (videoId) {
// YouTube video (with optional playlist)
node.tagName = "iframe"
@ -653,7 +720,10 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
plugins.push(() => {
return (tree: HtmlRoot, _file) => {
visit(tree, "element", (node) => {
if (node.tagName === "input" && node.properties.type === "checkbox") {
if (
node.tagName === "input" &&
node.properties.type === "checkbox"
) {
const isChecked = node.properties?.checked ?? false
node.properties = {
type: "checkbox",
@ -715,7 +785,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
})
}
return { js }
return {js}
},
}
}
@ -725,4 +795,4 @@ declare module "vfile" {
blocks: Record<string, Element>
htmlAst: HtmlRoot
}
}
}