diff --git a/astro.config.mjs b/astro.config.mjs index 6047152..90d54a1 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,37 +1,25 @@ import { defineConfig } from 'astro/config'; import tailwind from '@astrojs/tailwind'; import mdx from '@astrojs/mdx'; -import AutoImport from 'astro-auto-import'; - -const defaultLayoutPlugin = () => (tree, file) => { - const path = file.history.at(-1).split('/').at(-1); - file.data.astro.frontmatter.layout = ( - path.startsWith('index.') - ? '../layouts/Cover.astro' - : '../layouts/Default.astro' - ); -}; +import autoImport from 'astro-auto-import'; +import react from '@astrojs/react'; +// https://astro.build/config export default defineConfig({ trailingSlash: 'never', output: 'static', build: { - format: 'file', + format: 'file' }, compressHTML: false, - markdown: { - remarkPlugins: [defaultLayoutPlugin], - extendDefaultPlugins: true, - }, integrations: [ tailwind({ - applyBaseStyles: false, + applyBaseStyles: false }), - AutoImport({ - imports: [ - './src/components/Score.astro', - ], + autoImport({ + imports: ['./src/components/Score.astro'] }), - mdx() + mdx(), + react() ], }); diff --git a/package.json b/package.json index d4e9299..f33245c 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,12 @@ "@astrojs/react": "^3.3.1", "@astrojs/tailwind": "^5.1.0", "@theoryofnekomata/react-musical-keyboard": "1.0.13", - "@types/react": "^18.3.0", + "@types/react": "^18.3.1", "@types/react-dom": "^18.3.0", "astro": "^4.5.16", "jsdom": "^24.0.0", - "react": "^18.3.0", - "react-dom": "^18.3.0", + "react": "^18.3.1", + "react-dom": "^18.3.1", "tailwindcss": "^3.4.3", "typescript": "^5.4.4", "verovio": "^4.1.0" @@ -33,7 +33,7 @@ "@types/verovio": "^3.13.4", "archiver": "^7.0.1", "astro-auto-import": "^0.4.2", - "tsx": "^4.7.2", - "prop-types": "^15.8.1" + "prop-types": "^15.8.1", + "tsx": "^4.7.2" } } diff --git a/patchouli.book.json b/patchouli.book.json new file mode 100644 index 0000000..c5fc5d5 --- /dev/null +++ b/patchouli.book.json @@ -0,0 +1,3 @@ +{ + "title": "Book Name" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e50265..d6ffe14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,7 @@ dependencies: specifier: 1.0.13 version: 1.0.13(mem@6.1.1)(react@18.3.1) '@types/react': - specifier: ^18.3.0 + specifier: ^18.3.1 version: 18.3.1 '@types/react-dom': specifier: ^18.3.0 @@ -33,10 +33,10 @@ dependencies: specifier: ^24.0.0 version: 24.0.0 react: - specifier: ^18.3.0 + specifier: ^18.3.1 version: 18.3.1 react-dom: - specifier: ^18.3.0 + specifier: ^18.3.1 version: 18.3.1(react@18.3.1) tailwindcss: specifier: ^3.4.3 diff --git a/src/components/FrequenciesForm/index.tsx b/src/components/FrequenciesForm/index.tsx index d5646ea..e2e72c3 100644 --- a/src/components/FrequenciesForm/index.tsx +++ b/src/components/FrequenciesForm/index.tsx @@ -163,7 +163,7 @@ export const FrequenciesForm = () => { return (
{showForm && ( - <> +
{ />
+ {/* @ts-ignore */} { />
- +
)} @@ -279,7 +283,7 @@ export const FrequenciesForm = () => {
MIDI note frequencies and their stretched counterparts - (base frequency={baseFrequency} Hz for key #{baseKey}, factor={(stretchFactorNumerator/equalDivisionOfTheOctave).toFixed(3)}) + (base frequency={baseFrequency} Hz for key #{baseKey}, stretch factor={(stretchFactorNumerator/equalDivisionOfTheOctave).toFixed(3)}). + First figures indicate non-stretched frequencies, second figures indicate stretched frequencies. Parenthesized figures represent difference + between the frequencies.
diff --git a/src/components/Score.astro b/src/components/Score.astro index b8db55b..5170257 100644 --- a/src/components/Score.astro +++ b/src/components/Score.astro @@ -7,7 +7,7 @@ const scoreXml = await loadScore(id); ---
- +
@@ -16,7 +16,7 @@ const scoreXml = await loadScore(id);
diff --git a/src/content/appendices/01-piano-key-frequencies.mdx b/src/content/appendices/01-piano-key-frequencies.mdx new file mode 100644 index 0000000..46eb68f --- /dev/null +++ b/src/content/appendices/01-piano-key-frequencies.mdx @@ -0,0 +1,7 @@ +--- +title: Piano Key Frequencies +--- + +import { FrequenciesForm } from '../../components/FrequenciesForm'; + + diff --git a/src/pages/ch01-introduction.mdx b/src/content/chapters/01-introduction.mdx similarity index 100% rename from src/pages/ch01-introduction.mdx rename to src/content/chapters/01-introduction.mdx diff --git a/src/pages/ch02-speed.mdx b/src/content/chapters/02-speed.mdx similarity index 100% rename from src/pages/ch02-speed.mdx rename to src/content/chapters/02-speed.mdx diff --git a/src/pages/ch03-analysis.mdx b/src/content/chapters/03-analysis.mdx similarity index 100% rename from src/pages/ch03-analysis.mdx rename to src/content/chapters/03-analysis.mdx diff --git a/src/pages/ch04-sound-projection.mdx b/src/content/chapters/04-sound-projection.mdx similarity index 100% rename from src/pages/ch04-sound-projection.mdx rename to src/content/chapters/04-sound-projection.mdx diff --git a/src/content/chapters/05-limits.mdx b/src/content/chapters/05-limits.mdx new file mode 100644 index 0000000..9da1242 --- /dev/null +++ b/src/content/chapters/05-limits.mdx @@ -0,0 +1,3 @@ +--- +title: Limits +--- diff --git a/src/content/chapters/06-overcoming-doubts.mdx b/src/content/chapters/06-overcoming-doubts.mdx new file mode 100644 index 0000000..6fbbc01 --- /dev/null +++ b/src/content/chapters/06-overcoming-doubts.mdx @@ -0,0 +1,3 @@ +--- +title: Overcoming Doubts +--- diff --git a/src/content/chapters/07-fingering.mdx b/src/content/chapters/07-fingering.mdx new file mode 100644 index 0000000..8d023a2 --- /dev/null +++ b/src/content/chapters/07-fingering.mdx @@ -0,0 +1,3 @@ +--- +title: Fingering +--- diff --git a/src/content/chapters/08-pulse.mdx b/src/content/chapters/08-pulse.mdx new file mode 100644 index 0000000..576d1ef --- /dev/null +++ b/src/content/chapters/08-pulse.mdx @@ -0,0 +1,3 @@ +--- +title: Pulse +--- diff --git a/src/content/chapters/09-sensation.mdx b/src/content/chapters/09-sensation.mdx new file mode 100644 index 0000000..edfab22 --- /dev/null +++ b/src/content/chapters/09-sensation.mdx @@ -0,0 +1,3 @@ +--- +title: Sensation +--- diff --git a/src/content/chapters/10-autopilot.mdx b/src/content/chapters/10-autopilot.mdx new file mode 100644 index 0000000..c4d9e11 --- /dev/null +++ b/src/content/chapters/10-autopilot.mdx @@ -0,0 +1,3 @@ +--- +title: Autopilot +--- diff --git a/src/pages/ch11-musicality.mdx b/src/content/chapters/11-musicality.mdx similarity index 100% rename from src/pages/ch11-musicality.mdx rename to src/content/chapters/11-musicality.mdx diff --git a/src/content/chapters/12-the-musician.mdx b/src/content/chapters/12-the-musician.mdx new file mode 100644 index 0000000..53fd26b --- /dev/null +++ b/src/content/chapters/12-the-musician.mdx @@ -0,0 +1,3 @@ +--- +title: The Musician +--- diff --git a/src/content/chapters/13-ornaments.mdx b/src/content/chapters/13-ornaments.mdx new file mode 100644 index 0000000..fa67953 --- /dev/null +++ b/src/content/chapters/13-ornaments.mdx @@ -0,0 +1,3 @@ +--- +title: Ornaments +--- diff --git a/src/content/chapters/14-rests.mdx b/src/content/chapters/14-rests.mdx new file mode 100644 index 0000000..c2345ce --- /dev/null +++ b/src/content/chapters/14-rests.mdx @@ -0,0 +1,3 @@ +--- +title: Rests +--- diff --git a/src/content/chapters/15-gestures.mdx b/src/content/chapters/15-gestures.mdx new file mode 100644 index 0000000..6b613f5 --- /dev/null +++ b/src/content/chapters/15-gestures.mdx @@ -0,0 +1,3 @@ +--- +title: Gestures +--- diff --git a/src/content/chapters/16-articulation.mdx b/src/content/chapters/16-articulation.mdx new file mode 100644 index 0000000..408c81e --- /dev/null +++ b/src/content/chapters/16-articulation.mdx @@ -0,0 +1,3 @@ +--- +title: Articulation +--- diff --git a/src/content/chapters/17-expression.mdx b/src/content/chapters/17-expression.mdx new file mode 100644 index 0000000..ddff86c --- /dev/null +++ b/src/content/chapters/17-expression.mdx @@ -0,0 +1,3 @@ +--- +title: Expression +--- diff --git a/src/content/chapters/18-mistakes.mdx b/src/content/chapters/18-mistakes.mdx new file mode 100644 index 0000000..4cc2005 --- /dev/null +++ b/src/content/chapters/18-mistakes.mdx @@ -0,0 +1,3 @@ +--- +title: Mistakes +--- diff --git a/src/content/chapters/19-performance.mdx b/src/content/chapters/19-performance.mdx new file mode 100644 index 0000000..609b952 --- /dev/null +++ b/src/content/chapters/19-performance.mdx @@ -0,0 +1,3 @@ +--- +title: Performance +--- diff --git a/src/pages/ch20-trills.mdx b/src/content/chapters/20-trills.mdx similarity index 100% rename from src/pages/ch20-trills.mdx rename to src/content/chapters/20-trills.mdx diff --git a/src/pages/ch21-speed-and-anticipation.mdx b/src/content/chapters/21-speed-and-anticipation.mdx similarity index 100% rename from src/pages/ch21-speed-and-anticipation.mdx rename to src/content/chapters/21-speed-and-anticipation.mdx diff --git a/src/content/chapters/22-thirds.mdx b/src/content/chapters/22-thirds.mdx new file mode 100644 index 0000000..43f7bea --- /dev/null +++ b/src/content/chapters/22-thirds.mdx @@ -0,0 +1,3 @@ +--- +title: Thirds +--- diff --git a/src/content/config.ts b/src/content/config.ts new file mode 100644 index 0000000..c58d39e --- /dev/null +++ b/src/content/config.ts @@ -0,0 +1,28 @@ +import { z, defineCollection } from 'astro:content'; + +const specialCollection = defineCollection({ + type: 'content', + schema: z.object({ + title: z.string(), + }), +}); + +const chaptersCollection = defineCollection({ + type: 'content', + schema: z.object({ + title: z.string(), + }), +}); + +const appendicesCollection = defineCollection({ + type: 'content', + schema: z.object({ + title: z.string(), + }), +}); + +export const collections = { + 'special': specialCollection, + 'chapters': chaptersCollection, + 'appendices': appendicesCollection, +}; diff --git a/src/content/layouts/Appendix.astro b/src/content/layouts/Appendix.astro new file mode 100644 index 0000000..d3676af --- /dev/null +++ b/src/content/layouts/Appendix.astro @@ -0,0 +1,186 @@ +--- +const { title, titlePrefix } = Astro.props.frontmatter || Astro.props; +--- + + + + + + + + {title} + + + + + + diff --git a/src/layouts/Cover.astro b/src/content/layouts/Cover.astro similarity index 100% rename from src/layouts/Cover.astro rename to src/content/layouts/Cover.astro diff --git a/src/layouts/Default.astro b/src/content/layouts/Default.astro similarity index 96% rename from src/layouts/Default.astro rename to src/content/layouts/Default.astro index 8abe3b0..8f5aeb7 100644 --- a/src/layouts/Default.astro +++ b/src/content/layouts/Default.astro @@ -54,6 +54,10 @@ const { title } = Astro.props.frontmatter || Astro.props; @apply mb-16; } + table { + caption-side: bottom; + } + @media only screen { html { @apply text-gray-800; @@ -108,6 +112,10 @@ const { title } = Astro.props.frontmatter || Astro.props; figcaption { @apply text-sm; } + + .print-hidden { + display: none; + } } @media only screen and (prefers-color-scheme: dark) { diff --git a/src/pages/foreword.mdx b/src/content/special/foreword.mdx similarity index 100% rename from src/pages/foreword.mdx rename to src/content/special/foreword.mdx diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro new file mode 100644 index 0000000..247e140 --- /dev/null +++ b/src/pages/[...slug].astro @@ -0,0 +1,18 @@ +--- +import { getCollection } from 'astro:content'; +import Default from '../content/layouts/Default.astro'; + +export const getStaticPaths = async () => { + const entries = await getCollection('special'); + return entries.map(entry => ({ + params: { slug: entry.slug }, props: { entry }, + })); +} + +const { entry } = Astro.props; +const { Content } = await entry.render(); +--- + + + + diff --git a/src/pages/appendices/[...slug].astro b/src/pages/appendices/[...slug].astro new file mode 100644 index 0000000..dadfa43 --- /dev/null +++ b/src/pages/appendices/[...slug].astro @@ -0,0 +1,19 @@ +--- +import { getCollection } from 'astro:content'; +import Layout from '../../content/layouts/Appendix.astro'; + +export const getStaticPaths = async () => { + const entries = await getCollection('appendices'); + return entries.map(entry => ({ + params: { slug: entry.slug }, props: { entry }, + })); +} + +const { entry } = Astro.props; +const { Content } = await entry.render(); +const titlePrefix = String.fromCharCode(parseInt(entry.slug) - 1 + 65); +--- + + + + diff --git a/src/pages/appendix01-piano-key-frequencies.mdx b/src/pages/appendix01-piano-key-frequencies.mdx deleted file mode 100644 index 441b484..0000000 --- a/src/pages/appendix01-piano-key-frequencies.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Piano Key Frequencies -layout: ../layouts/Default.astro ---- - -import { FrequenciesForm } from '../components/FrequenciesForm'; - - diff --git a/src/pages/ch05-limits.mdx b/src/pages/ch05-limits.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch06-overcoming-doubts.mdx b/src/pages/ch06-overcoming-doubts.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch07-fingering.mdx b/src/pages/ch07-fingering.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch08-pulse.mdx b/src/pages/ch08-pulse.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch09-sensation.mdx b/src/pages/ch09-sensation.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch10-autopilot.mdx b/src/pages/ch10-autopilot.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch12-the-musician.mdx b/src/pages/ch12-the-musician.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch13-ornaments.mdx b/src/pages/ch13-ornaments.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch14-rests.mdx b/src/pages/ch14-rests.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch15-gestures.mdx b/src/pages/ch15-gestures.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch16-articulation.mdx b/src/pages/ch16-articulation.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch17-expression.mdx b/src/pages/ch17-expression.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch18-mistakes.mdx b/src/pages/ch18-mistakes.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch19-performance.mdx b/src/pages/ch19-performance.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/ch22-thirds.mdx b/src/pages/ch22-thirds.mdx deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/chapters/[...slug].astro b/src/pages/chapters/[...slug].astro new file mode 100644 index 0000000..9ffc71f --- /dev/null +++ b/src/pages/chapters/[...slug].astro @@ -0,0 +1,18 @@ +--- +import { getCollection } from 'astro:content'; +import Default from '../../content/layouts/Default.astro'; + +export const getStaticPaths = async () => { + const entries = await getCollection('chapters'); + return entries.map(entry => ({ + params: { slug: entry.slug }, props: { entry }, + })); +} + +const { entry } = Astro.props; +const { Content } = await entry.render(); +--- + + + + diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..3a8092d --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,10 @@ +--- +import Default from '../content/layouts/Cover.astro'; +import { title } from '../../patchouli.book.json'; +--- + + + + {title} + + diff --git a/src/pages/index.mdx b/src/pages/index.mdx deleted file mode 100644 index e2f1a68..0000000 --- a/src/pages/index.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Book Name ---- - - - {frontmatter.title} - diff --git a/src/pages/toc.astro b/src/pages/toc.astro index 9e59ec1..e551494 100644 --- a/src/pages/toc.astro +++ b/src/pages/toc.astro @@ -1,6 +1,6 @@ --- import { readdir, readFile } from 'node:fs/promises'; -const { default: Default } = await import('../layouts/Default.astro'); +import Default from '../content/layouts/Default.astro'; type Frontmatter = Record; @@ -9,7 +9,7 @@ interface PageProps { } const title = 'Table of Contents' -const allPages = await readdir('src/pages'); +const allPages = await readdir('src/content/chapters'); const pages = allPages.filter((p) => ( !p.startsWith('index.') && !p.endsWith('.astro') @@ -18,7 +18,7 @@ const pages = allPages.filter((p) => ( const pagesContentImported = await Promise.all( pages.map(async (p) => { - const fileBuffer = await readFile(`src/pages/${p}`); + const fileBuffer = await readFile(`src/content/chapters/${p}`); const file = fileBuffer.toString('utf-8'); const [, frontmatterRaw] = file.split('---'); @@ -39,7 +39,7 @@ const pagesContentImported = await Promise.all(
    {pagesContentImported.map(([p, f]) => (
  1. - + {f.frontmatter.title}
MIDI note frequencies and their stretched counterparts - (base frequency={baseFrequency} Hz for key #{baseKey}, factor={(stretchFactorNumerator/equalDivisionOfTheOctave).toFixed(3)}) + (base frequency={baseFrequency} Hz for key #{baseKey}, stretch factor={(stretchFactorNumerator/equalDivisionOfTheOctave).toFixed(3)})