scss support
This commit is contained in:
		@@ -1,5 +1,4 @@
 | 
			
		||||
import { toJsxRuntime } from "hast-util-to-jsx-runtime"
 | 
			
		||||
import { resolveToRoot } from "../../path"
 | 
			
		||||
import { StaticResources } from "../../resources"
 | 
			
		||||
import { EmitCallback, QuartzEmitterPlugin } from "../types"
 | 
			
		||||
import { ProcessedContent } from "../vfile"
 | 
			
		||||
@@ -8,6 +7,10 @@ import { render } from "preact-render-to-string"
 | 
			
		||||
import { ComponentType } from "preact"
 | 
			
		||||
import { HeadProps } from "../../components/Head"
 | 
			
		||||
 | 
			
		||||
import styles from '../../styles/base.scss'
 | 
			
		||||
import { googleFontHref, templateThemeStyles } from "../../theme"
 | 
			
		||||
import { GlobalConfiguration } from "../../cfg"
 | 
			
		||||
 | 
			
		||||
interface Options {
 | 
			
		||||
  Head: ComponentType<HeadProps>
 | 
			
		||||
}
 | 
			
		||||
@@ -21,8 +24,18 @@ export class ContentPage extends QuartzEmitterPlugin {
 | 
			
		||||
    this.opts = opts
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async emit(content: ProcessedContent[], resources: StaticResources, emit: EmitCallback): Promise<string[]> {
 | 
			
		||||
  async emit(cfg: GlobalConfiguration, content: ProcessedContent[], resources: StaticResources, emit: EmitCallback): Promise<string[]> {
 | 
			
		||||
    const fps: string[] = []
 | 
			
		||||
 | 
			
		||||
    // emit styles
 | 
			
		||||
    emit({
 | 
			
		||||
      slug: "index",
 | 
			
		||||
      ext: ".css",
 | 
			
		||||
      content: templateThemeStyles(cfg.theme, styles)
 | 
			
		||||
    })
 | 
			
		||||
    fps.push("index.css")
 | 
			
		||||
    resources.css.push(googleFontHref(cfg.theme))
 | 
			
		||||
 | 
			
		||||
    for (const [tree, file] of content) {
 | 
			
		||||
 | 
			
		||||
      // @ts-ignore (preact makes it angry)
 | 
			
		||||
@@ -36,7 +49,7 @@ export class ContentPage extends QuartzEmitterPlugin {
 | 
			
		||||
          slug={file.data.slug!}
 | 
			
		||||
          externalResources={resources} />
 | 
			
		||||
        <body>
 | 
			
		||||
          <div id="quartz-root">
 | 
			
		||||
          <div id="quartz-root" class="page">
 | 
			
		||||
            <header>
 | 
			
		||||
              <h1>{file.data.frontmatter?.title}</h1>
 | 
			
		||||
            </header>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,3 +3,5 @@ export { GitHubFlavoredMarkdown } from './gfm'
 | 
			
		||||
export { CreatedModifiedDate } from './lastmod'
 | 
			
		||||
export { Katex } from './latex'
 | 
			
		||||
export { Description } from './description'
 | 
			
		||||
export { ResolveLinks } from './links'
 | 
			
		||||
export { ObsidianFlavoredMarkdown } from './ofm'
 | 
			
		||||
 
 | 
			
		||||
@@ -38,17 +38,21 @@ export class ObsidianFlavoredMarkdown extends QuartzTransformerPlugin {
 | 
			
		||||
        const backlinkRegex = new RegExp(/!?\[\[([^\[\]\|\#]+)(#[^\[\]\|\#]+)?(\|[^\[\]\|\#]+)?\]\]/, "g")
 | 
			
		||||
        return (tree: Root, _file) => {
 | 
			
		||||
          findAndReplace(tree, backlinkRegex, (value: string, ...capture: string[]) => {
 | 
			
		||||
            const [path, rawHeader, rawAlias] = capture
 | 
			
		||||
            const header = rawHeader?.slice(1).trim() ?? ""
 | 
			
		||||
            const alias = rawAlias?.slice(1).trim() ?? value 
 | 
			
		||||
            const url = slugify(path.trim() + header)
 | 
			
		||||
            return {
 | 
			
		||||
              type: 'link',
 | 
			
		||||
              url,
 | 
			
		||||
              children: [{
 | 
			
		||||
                type: 'text',
 | 
			
		||||
                value: alias
 | 
			
		||||
              }]
 | 
			
		||||
            if (value.startsWith("!")) {
 | 
			
		||||
 | 
			
		||||
            } else {
 | 
			
		||||
              const [path, rawHeader, rawAlias] = capture
 | 
			
		||||
              const header = rawHeader?.slice(1).trim() ?? ""
 | 
			
		||||
              const alias = rawAlias?.slice(1).trim() ?? path
 | 
			
		||||
              const url = slugify(path.trim() + header)
 | 
			
		||||
              return {
 | 
			
		||||
                type: 'link',
 | 
			
		||||
                url,
 | 
			
		||||
                children: [{
 | 
			
		||||
                  type: 'text',
 | 
			
		||||
                  value: alias
 | 
			
		||||
                }]
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          })
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
import { PluggableList } from "unified"
 | 
			
		||||
import { StaticResources } from "../resources"
 | 
			
		||||
import { ProcessedContent } from "./vfile"
 | 
			
		||||
import { GlobalConfiguration } from "../cfg"
 | 
			
		||||
 | 
			
		||||
export abstract class QuartzTransformerPlugin {
 | 
			
		||||
  abstract name: string
 | 
			
		||||
@@ -23,7 +24,7 @@ export interface EmitOptions {
 | 
			
		||||
export type EmitCallback = (data: EmitOptions) => Promise<string>
 | 
			
		||||
export abstract class QuartzEmitterPlugin {
 | 
			
		||||
  abstract name: string
 | 
			
		||||
  abstract emit(content: ProcessedContent[], resources: StaticResources, emitCallback: EmitCallback): Promise<string[]>
 | 
			
		||||
  abstract emit(cfg: GlobalConfiguration, content: ProcessedContent[], resources: StaticResources, emitCallback: EmitCallback): Promise<string[]>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface PluginTypes {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user