From 529ee37892e9e1bac623545a90243e393b713cc0 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 16 Apr 2024 09:10:44 -0700 Subject: [PATCH] 1.6.0 (#1244) * fix #1237; null head, header, footer * 1.6.0 --- docs/config.md | 2 +- docs/getting-started.md | 2 +- docs/imports.md | 2 +- docs/lib/csv.md | 2 +- package.json | 2 +- src/config.ts | 16 ++++++++++------ src/frontMatter.ts | 6 +----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/config.md b/docs/config.md index a543cf175..fbb0a9a5e 100644 --- a/docs/config.md +++ b/docs/config.md @@ -116,7 +116,7 @@ An array containing pages and sections. If not specified, it defaults to all Mar Both pages and sections have a **name**, which typically corresponds to the page’s title. The name gets displayed in the sidebar. Clicking on a page navigates to the corresponding **path**, which should start with a leading slash and be relative to the root; the path can also be specified as a full URL to navigate to an external site. Each section must specify an array of **pages**. -Sections may be **collapsible**. If the **open** option is set, the **collapsible** option defaults to true; otherwise it defaults to false. If the section is not collapsible, the **open** option is ignored and the section is always open; otherwise, the **open** option defaults to true. When a section is collapsible, clicking on a section header opens or closes that section. A section will always be open if the current page belongs to that section. +Sections may be **collapsible**. If the **open** option is set, the **collapsible** option defaults to true; otherwise it defaults to false. If the section is not collapsible, the **open** option is ignored and the section is always open; otherwise, the **open** option defaults to true. When a section is collapsible, clicking on a section header opens or closes that section. A section will always be open if the current page belongs to that section. For example, here **pages** specifies two sections and a total of four pages: diff --git a/docs/getting-started.md b/docs/getting-started.md index 335f6c1c3..1e22ab43d 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -152,7 +152,7 @@ Or with Yarn: You should see something like this: -
Observable Framework v1.5.1
+
Observable Framework v1.6.0
 ↳ http://127.0.0.1:3000/
diff --git a/docs/imports.md b/docs/imports.md index 01dc03f21..ec5a7d00e 100644 --- a/docs/imports.md +++ b/docs/imports.md @@ -71,7 +71,7 @@ Downloads from npm are cached in `.observablehq/cache/_npm` within your [source Self-hosting of `npm:` imports applies to transitive static and [dynamic imports](#dynamic-imports). In addition to downloading modules, Framework downloads supporting files as needed for [recommended libraries](#implicit-imports) and [`import.meta.resolve`](#import-resolutions). For example, [DuckDB](./lib/duckdb) needs WebAssembly modules, and [KaTeX](./lib/tex) needs a stylesheet and fonts. For dynamic imports and `import.meta.resolve`, Framework is only able to self-host import specifiers that are static string literals. -## Node imports +## Node imports You can import from `node_modules`. This is useful for managing dependencies with a package manager such as npm or Yarn, for importing private packages from the npm registry, or for importing from a different package registry such as GitHub. diff --git a/docs/lib/csv.md b/docs/lib/csv.md index 849aff575..aa9d5e526 100644 --- a/docs/lib/csv.md +++ b/docs/lib/csv.md @@ -28,7 +28,7 @@ const capitals = FileAttachment("us-state-capitals.tsv").tsv({typed: true}); Inputs.table(capitals) ``` -For a different delimiter, use `FileAttachment.dsv`. For example, for semicolon separated values: +For a different delimiter, use `FileAttachment.dsv`. For example, for semicolon separated values: ```js run=false const capitals = FileAttachment("us-state-capitals.csv").dsv({delimiter: ";", typed: true}); diff --git a/package.json b/package.json index 91fe23a00..7df187ee5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@observablehq/framework", "license": "ISC", - "version": "1.5.1", + "version": "1.6.0", "type": "module", "publishConfig": { "access": "public" diff --git a/src/config.ts b/src/config.ts index 04e076a0f..42b605375 100644 --- a/src/config.ts +++ b/src/config.ts @@ -49,9 +49,9 @@ export interface Config { pages: (Page | Section)[]; pager: boolean; // defaults to true scripts: Script[]; // defaults to empty array - head: string; // defaults to empty string - header: string; // defaults to empty string - footer: string; // defaults to “Built with Observable on [date].” + head: string | null; // defaults to null + header: string | null; // defaults to null + footer: string | null; // defaults to “Built with Observable on [date].” toc: TableOfContents; style: null | Style; // defaults to {theme: ["light", "dark"]} deploy: null | {workspace: string; project: string}; @@ -161,9 +161,9 @@ export function normalizeConfig(spec: any = {}, defaultRoot = "docs", watchPath? if (sidebar !== undefined) sidebar = Boolean(sidebar); pager = Boolean(pager); scripts = Array.from(scripts, normalizeScript); - head = String(head); - header = String(header); - footer = String(footer); + head = stringOrNull(head); + header = stringOrNull(header); + footer = stringOrNull(footer); toc = normalizeToc(toc); deploy = deploy ? {workspace: String(deploy.workspace).replace(/^@+/, ""), project: String(deploy.project)} : null; search = Boolean(search); @@ -280,3 +280,7 @@ export function mergeStyle( ? defaultStyle : {theme}; } + +export function stringOrNull(spec: unknown): string | null { + return spec == null || spec === false ? null : String(spec); +} diff --git a/src/frontMatter.ts b/src/frontMatter.ts index fc91fbece..cf73db78f 100644 --- a/src/frontMatter.ts +++ b/src/frontMatter.ts @@ -1,5 +1,5 @@ import matter from "gray-matter"; -import {normalizeTheme} from "./config.js"; +import {normalizeTheme, stringOrNull} from "./config.js"; import {yellow} from "./tty.js"; export interface FrontMatter { @@ -49,10 +49,6 @@ export function normalizeFrontMatter(spec: any = {}): FrontMatter { return frontMatter; } -function stringOrNull(spec: unknown): string | null { - return spec == null || spec === false ? null : String(spec); -} - function normalizeToc(spec: unknown): {show?: boolean; label?: string} { if (spec == null) return {show: false}; if (typeof spec !== "object") return {show: Boolean(spec)};