Citation processing
<skill name="grill-me" location="[REDACTED_LOCAL_PATH]">
References are relative to [REDACTED_LOCAL_PATH]
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
Ask the questions one at a time.
If a question can be answered by exploring the codebase, explore the codebase instead.
</skill>
I would like you to build some simple citation tools for me. I am going to collect references in a BibTeX file (src/data/references.bib) and I would like to be able to use MDX tags like <Cite ref="berton-2023"/> and <Citep ref="kaercher-corcos-2025"/>. The citations should be processed using BibTeX and whatever LaTeX to Markdown translator you like (pandoc is installed) and should then be included as sidenotes in the page where they appear. There is no need for a central references page.
I inspected the codebase first. Relevant facts:
- Astro + MDX site.
- Global MDX components are injected in
astro.config.mjs. - Existing
Sidenote.astroalready gives numbered margin/sidenote behavior. src/data/references.bibalready exists with keys likeberton-2023andkaercher-corcos-2025.- No citation pipeline exists yet.
First decision:
Show remaining 24 lines
What should <Cite> and <Citep> render in the main prose?
Options:
- LaTeX-like author/year
<Cite ref="berton-2023" />→Berton (2023)plus sidenote<Citep ref="berton-2023" />→(Berton, 2023)plus sidenote
- Numbered-marker only
<Cite ref="berton-2023" />→ just a sidenote marker- sidenote contains full citation
- Full inline citation
<Cite ref="berton-2023" />→Berton, Roland P. H. “Two-Dimensional…” …- probably too noisy for prose
My recommended answer: option 1.
Use:
<Cite>for narrative citations:Berton (2023)<Citep>for parenthetical citations:(Berton, 2023)- both attach a numbered sidenote containing the full formatted reference.
Do you agree with this author-year behavior?
Yes.
Next question:
Should repeated citations to the same reference on the same page create repeated sidenotes, or should only the first citation create the full sidenote?
Options:
- Every citation gets its own sidenote
- Simple and local.
- If the same article is cited three times, the full reference appears three times in the margin.
Show remaining 29 lines
- Only first citation gets full sidenote; later citations are inline only
- Cleaner margins.
- But implementation needs per-page citation state.
- Every citation gets a sidenote, but repeated ones use a short form
- First: full reference.
- Later:
Berton, “Two-Dimensional Dynamics…”. - More scholarly, but more complexity.
My recommended answer: option 2 for v1.
First use of a reference on a page:
<Cite ref="berton-2023" />
renders:
Berton (2023)[sidenote marker]
with the full citation in the sidenote.
Later use on the same page renders only:
Berton (2023)
This keeps pages readable and avoids repeated full citations.
Do you agree?
Yes.
Next question:
Should citation components support multiple references in one tag?
Example:
<Citep ref="berton-2023; kaercher-corcos-2025" />
or:
Show remaining 31 lines
<Citep refs={["berton-2023", "kaercher-corcos-2025"]} />
Options:
- Single reference only in v1
- Simpler API and implementation.
- Multiple citations require writing two tags.
- Support multiple references via a semicolon-separated
refstring
- Natural for Markdown-ish authoring:
``mdx
<Citep ref="berton-2023; kaercher-corcos-2025" />
``
- Renders something like
(Berton, 2023; Kärcher and Corcos, 2025). - First unseen reference(s) each get sidenotes.
- Support both
refandrefs
- Flexible, but more API surface than probably needed.
My recommended answer: option 2.
Use semicolon-separated ref values for multiple parenthetical citations. Keep the component API lightweight:
<Cite ref="berton-2023" />
<Citep ref="berton-2023; kaercher-corcos-2025" />
Do you agree?
Yes.
Next question:
What citation style should the BibTeX → Markdown/full-reference formatter use?
Options:
- Chicago author-date
- Good for scholarly prose.
- Full sidenote:
Berton, Roland P. H. 2023. “Two-Dimensional Dynamics of Ice Crystal Parcels in a Cirrus Uncinus.” Tellus B: Chemical and Physical Meteorology. https://doi.org/...
Show remaining 18 lines
- APA-ish
- Common, compact.
- Full sidenote:
Berton, R. P. H. (2023). Two-Dimensional dynamics... Tellus B...
- CSL-configurable
- Use Pandoc with a CSL file and allow future swapping.
- More flexible, but one more file/config convention.
My recommended answer: option 3, with Chicago author-date as the default CSL style.
Implementation direction:
- Use Pandoc’s citation processor against
src/data/references.bib. - Add a project-local CSL file/config only if needed; otherwise use Pandoc’s built-in/default behavior or a bundled style.
- Generate both:
- short author-year labels for inline text
- full bibliography entries for sidenotes
Do you agree with Chicago author-date as the default style, implemented in a way that can be swapped later?
Yes, that sounds good.
Next question:
Where should citation processing happen: during Astro build via a generated data file, or inside each citation component at render time?
Options:
- Prebuild/generate citation data
- Script reads
src/data/references.bib. - Calls Pandoc once.
- Writes something like
src/data/auto/citations.json.
Show remaining 35 lines
- Components import that JSON.
- Fast, deterministic components; easier tests.
- Component render-time processing
<Cite>component directly invokes parsing/Pandoc during Astro render.- Fewer generated files, but slower and messier.
- Harder to maintain per-page citation state.
- Remark plugin transforms MDX citations before Astro
- Elegant long-term.
- But more complex because your desired syntax is MDX components, not markdown cite syntax.
My recommended answer: option 1.
Add a script, probably:
npm run citations
and make build run it first:
"build": "npm run citations && astro check && astro build"
Generated data:
src/data/auto/citations.json
Source of truth remains:
src/data/references.bib
Do you agree with a prebuild generated citation data file?
Option 1 is right.
Next question:
Should missing/invalid citation keys fail the build, or render a visible placeholder?
Example:
<Cite ref="missing-key" />
Options:
Show remaining 21 lines
- Fail the build
- Best for publication correctness.
- A typo in a citation key is caught immediately.
- Slightly stricter while drafting.
- Render visible placeholder
- Example:
[missing citation: missing-key] - Easier during rough drafting.
- But broken citations can accidentally ship.
- Different behavior by environment
- Dev: render placeholder.
- Build: fail.
- More nuanced, slightly more implementation.
My recommended answer: option 1 for this site.
Because this is static publishing and citations are scholarly metadata, citation mistakes should be build errors. Drafts can still be rough, but if the page is part of the site build, bad refs should stop it.
Do you agree that missing citation keys should fail npm run build?
Fail the build.
Next question:
Should citation sidenotes be open/visible by default on narrow/mobile screens?
Existing Sidenote.astro collapses sidenotes behind a clickable marker below the desktop breakpoint unless open={true} is passed.
Options:
- Closed by default on mobile
- Matches existing
Sidenotebehavior.
Show remaining 15 lines
- Keeps mobile prose compact.
- Open by default on mobile
- Readers see references without tapping.
- Can clutter pages with citations.
- Configurable prop
- e.g.
<Citep ref="..." open /> - But default still needs choosing.
My recommended answer: option 1, closed by default.
Use the existing Sidenote default behavior. Citation markers already indicate extra information, and full references are secondary while reading.
Do you agree?
Yes, option 1.
Next question:
How much override/customization should <Cite> and <Citep> support in v1?
Possible props:
<Cite ref="berton-2023" />
<Cite ref="berton-2023" page="14" />
<Cite ref="berton-2023" prefix="see" />
<Citep ref="berton-2023" suffix="chapter 2" />Show remaining 35 lines
<Citep ref="berton-2023" suppressAuthor />
Options:
1. **Minimal v1: only `ref`**
- Simple.
- Covers your examples.
- Add locators/pages later.
2. **Add page/locator support now**
- Useful for books/chapters:
```mdx
<Citep ref="smith-2020" page="42" />
```
→ `(Smith, 2020, 42)`
- Sidenote can include full reference plus page.
3. **Full pandoc-like citation modifiers**
- Prefix, suffix, suppress author, locator labels.
- Too much for v1.
**My recommended answer:** option 2.
Support:
<Cite ref="berton-2023" />
<Citep ref="berton-2023" />
<Citep ref="berton-2023" page="42" />
<Citep ref="berton-2023" locator="pp. 42–43" />
But skip prefix/suffix/suppress-author for now.
Do you agree with adding simple page/locator support in v1?Yes.
Next question:
How should locators work for multiple references?
Example:
<Citep ref="berton-2023; kaercher-corcos-2025" page="42" />
That is ambiguous: does page 42 apply to both references, only the first, or is it invalid?
Show remaining 22 lines
Options:
- Allow
page/locatoronly with a single reference
- Clear and simple.
- Multiple references with pages require separate tags:
``mdx
<Citep ref="berton-2023" page="42" />; <Citep ref="kaercher-corcos-2025" page="7" />
``
- Apply the same locator to all references
- Rarely what you want.
- Support structured locator syntax
- e.g.
refs={[{ ref: "a", page: "42" }, { ref: "b", page: "7" }]} - More complexity than v1 deserves.
My recommended answer: option 1.
If ref contains multiple keys, page or locator should be rejected with a build error. That keeps the API honest.
Do you agree?
Yes, 1.
Next question:
Should the generated full sidenote citation include DOI/URL links when available?
Options:
- Yes, link DOI/URL
- Full sidenote includes a clickable DOI or URL.
- Useful for readers.
- Slightly more visual clutter.
Show remaining 19 lines
- No, text-only citation
- Cleaner.
- Less useful.
- Only DOI, not URL
- Avoids long publisher URLs when DOI exists.
- Best balance.
My recommended answer: option 3.
If a DOI exists, render a DOI link:
<a href="https://doi.org/10....">doi:10....</a>
If no DOI exists but URL exists, render the URL link.
Do you agree?
Yes.
Next question:
Should the sidenote citation preserve abstracts/keywords/notes from BibTeX, or only render bibliographic fields?
Your current references.bib entries include large abstract, keyword(s), eprint, and note fields.
Options:
- Bibliographic fields only
- Author, year, title, journal/publisher, volume/issue/pages, DOI/URL.
Show remaining 14 lines
- Ignore abstract, keywords, eprint, note unless citation style includes them.
- Include abstract in sidenote
- Richer, but sidenotes become enormous and distract from prose.
- Configurable per citation
- e.g.
<Citep ref="..." abstract /> - Too much for v1.
My recommended answer: option 1.
Citation sidenotes should be compact references, not mini literature-review cards. Ignore abstracts/keywords/notes unless Pandoc/CSL naturally includes some note field.
Do you agree?
Bibliographic fields only. The BibTeX file will contain all sorts of things, because the entries are pasted direct from the journal websites, but the sidenotes should just be short bibliographic entries. There will almost always be a DOI link there anyway.
Important codebase/pandoc finding: with the current references.bib, Pandoc already produces sensible Chicago-author-date output, but the second entry has:
doi = {https://doi.org/10.1029/2025JD044488}
Pandoc renders that as:
https://doi.org/https://doi.org/10.1029/2025JD044488Show remaining 28 lines
because BibTeX DOI fields are expected to contain the DOI value, not the full URL.
Next question:
**Should the citation generator normalize messy DOI fields from pasted journal BibTeX?**
Options:
1. **Yes, normalize DOI fields**
- If DOI is `https://doi.org/10.xxxx`, store/render it as `10.xxxx`.
- If DOI is `doi:10.xxxx`, store/render it as `10.xxxx`.
- Output link becomes `https://doi.org/10.xxxx`.
- More robust for pasted publisher entries.
2. **No, require clean BibTeX**
- Simpler.
- But pasted journal BibTeX will often be messy.
3. **Warn but don’t normalize**
- Helps notice problems, but still makes output ugly unless manually fixed.
**My recommended answer:** option 1.
The generator should sanitize DOI fields before calling Pandoc or before writing generated citation data, so pasted publisher BibTeX works without manual cleanup.
Do you agree?Yes.
Next question:
Should citation inline text follow Pandoc’s exact Chicago output, including “Berton 2023” without a comma, or should <Citep> use the more common prose form with a comma: (Berton, 2023)?
Pandoc Chicago author-date currently outputs:
(Berton 2023; Kärcher and Corcos 2025)
Your original example expectation sounded more like:
Show remaining 23 lines
(Berton, 2023)
Options:
- Use Pandoc/Chicago exactly
<Citep ref="berton-2023" />→(Berton 2023)- Most style-consistent with the full bibliography.
- Use comma form
<Citep ref="berton-2023" />→(Berton, 2023)- More visually familiar to many readers.
- Slight divergence from strict Chicago author-date.
- Make it style-configurable
- Too much for v1.
My recommended answer: option 1.
Since we’re choosing Chicago author-date, let Pandoc/CSL define the exact punctuation. That avoids inventing a partial citation formatter ourselves.
Do you agree that parenthetical citations should render as (Author Year), not (Author, Year)?
Yes, option 1.
Next question:
Should the citation sidenote attach to every unseen reference in a multi-citation, or should one sidenote contain all newly cited references?
Example first citation:
<Citep ref="berton-2023; kaercher-corcos-2025" />
Options:
Show remaining 24 lines
- One combined sidenote
- Inline:
(Berton 2023; Kärcher and Corcos 2025)[1] - Sidenote contains both full references, likely as a short list.
- Cleanest for multi-citations.
- Separate sidenote markers for each reference
- Inline:
(Berton 2023[1]; Kärcher and Corcos 2025[2]) - More precise, but ugly.
- Only first unseen reference gets sidenote
- Bad; hides references.
My recommended answer: option 1.
A multi-citation should produce one combined sidenote containing all references in that tag that have not already appeared on the page.
If one ref has already appeared and one is new:
<Citep ref="berton-2023; kaercher-corcos-2025" />
then the sidenote contains only kaercher-corcos-2025, while the inline citation still shows both.
Do you agree?
Yes.
Next question:
How should “already cited on this page” state be tracked/reset?
The existing Sidenote.astro uses a globalThis counter keyed by Astro.url.pathname. Citation components could do the same.
Options:
- Use
globalThis, keyed by page pathname
- Matches current sidenote implementation.
Show remaining 20 lines
- Simple inside Astro components.
- Fine for static build.
- Require each page/layout to wrap content in a
CitationContextcomponent
- More explicit.
- More boilerplate and not natural in Astro-only components.
- Remark plugin prepass per MDX file
- Robust but bigger architecture.
My recommended answer: option 1 for v1.
Use a global set keyed by:
__aiResearchCitations:${Astro.url.pathname}
That means first citation per static route gets sidenote; repeated ones don’t.
Do you agree?
Yes.
Next question:
Should generated full citation entries be stored as Markdown strings or HTML strings?
Options:
- Markdown strings
- Example generated data:
```json
{
Show remaining 28 lines
"berton-2023": {
"fullMarkdown": "Berton, Roland P. H. 2023. ..."
}
}
```
- But Astro components would then need to render Markdown inside a component slot, which is awkward without adding another renderer.
- HTML strings
- Example:
``json
{
"berton-2023": {
"fullHtml": "Berton, Roland P. H. 2023. “... ” <em>Tellus B</em>. <a href=\"...\">...</a>."
}
}
``
- Easy for
Cite/Citepto inject inside<Sidenote set:html={...}>. - Need generator to sanitize/trust Pandoc output.
- Structured citation objects
- Store author/title/year/journal/doi fields and format ourselves.
- More control, but then we are not really using Pandoc/CSL for formatting.
My recommended answer: option 2.
Use Pandoc to produce sanitized HTML snippets for full references. Since the input is your own BibTeX file and build-time generated, this is acceptable and makes the Astro components simple.
Do you agree that generated citation entries should store full citation HTML?
Yes.
Next question:
Should src/data/auto/citations.json be committed to git, or treated as generated/untracked build output?
Options:
- Commit it
- Site can build without rerunning citation generation in some contexts.
- Diff shows citation output changes when
references.bibchanges. - But generated files add noise.
Show remaining 17 lines
- Do not commit it
- Cleaner source tree.
- Build always regenerates it.
- But imports from
src/data/auto/citations.jsonrequire the file to exist beforeastro check, so local/editor workflows may break unless generation is always run first.
- Commit a generated file but make regeneration automatic
- Source of truth is still
references.bib. npm run citationsupdatescitations.json.npm run buildregenerates before checking/building.- Best balance for static sites.
My recommended answer: option 3.
Commit src/data/auto/citations.json, but treat it as generated. That keeps Astro/TypeScript imports stable while preserving references.bib as the real source.
Do you agree?
I'm wondering about building the site in CI. If we commit that JSON file, would I be right in thinking that we would not need to run BibTeX and Pandoc in CI, since the JSON already has the HTML renders for the required citations?
Yes, mostly right.
If src/data/auto/citations.json is committed and the components only import that JSON, then CI does not need BibTeX/Pandoc to render the site. Astro can build from the already-generated citation HTML.
But there’s a tradeoff:
- If CI does not run the citation generator, it cannot detect that
references.bibandcitations.jsonare out of sync. - You could accidentally update
references.bib, forget to regeneratecitations.json, and CI would still pass while the site uses stale citation output.
So the next decision is:
Show remaining 38 lines
Should CI require Pandoc in order to verify citation data freshness, or should citation regeneration be a local/manual responsibility?
Options:
- CI does not run Pandoc
- Commit
citations.json. - Build works without Pandoc.
- Fast and portable.
- Risk: stale generated citation data.
- CI runs citation generation and fails if
citations.jsonchanges
- Requires Pandoc in CI.
- Guarantees generated citation data is fresh.
- More robust scholarly publishing workflow.
- Two-tier workflow
- Normal CI build uses committed
citations.jsonand does not require Pandoc. - Optional/manual/periodic check runs Pandoc freshness verification.
- Balanced, but slightly more workflow complexity.
My recommended answer: option 1 for now, with a separate local command like:
npm run citations
and maybe later add:
npm run citations:check
if stale data becomes a problem.
For your site, avoiding a CI Pandoc dependency is probably worth it.
Do you agree that CI should be able to build without Pandoc, using committed generated citation JSON?
Yes, let's do option 1.
Next question:
Given CI should build without Pandoc, should npm run build regenerate citations automatically, or should citation generation be a separate manual command?
Options:
npm run builddoes not run citation generation
- Build only uses committed
src/data/auto/citations.json. - CI does not need Pandoc.
- You manually run
npm run citationsafter editingreferences.bib.
Show remaining 31 lines
npm run buildruns citation generation
- Safer locally.
- But CI needs Pandoc unless you add environment conditionals.
npm run buildoptionally skips generation in CI
- More magic:
``sh
if [ "$CI" != "true" ]; then npm run citations; fi
``
- Can surprise you because local and CI builds differ.
My recommended answer: option 1.
Keep:
"build": "astro check && astro build"
Add:
"citations": "node scripts/generate-citations.ts"
Workflow:
npm run citations
npm run build
Do you agree that citation generation should be manual/separate, not part of npm run build?
Yes, 1.
Next question:
What should happen when src/data/auto/citations.json is missing?
This matters because if the generated file is committed, normal checkouts are fine — but first implementation and accidental deletion need handling.
Options:
- Build fails with a clear error
- Components import JSON.
Show remaining 18 lines
- If missing, Astro/TypeScript fails.
- Add README/docs saying run
npm run citations.
- Fallback to an empty citation map
- Build proceeds until a citation is used, then fails.
- Harder to reason about.
- Auto-generate only if Pandoc exists
- Reintroduces build-time Pandoc complexity.
My recommended answer: option 1.
Keep failure simple and clear:
citations.jsonis a committed generated artifact.- If missing, run
npm run citations. - CI should never miss it unless someone deletes it.
Do you agree?
Yes.
Next question:
Should Cite and Citep be added to the global MDX components registry?
Currently astro.config.mjs injects global imports for:
FigureMarginNoteMediaGridSidenoteWikipedia
Show remaining 20 lines
Options:
- Yes, global
- You can write
<Cite ref="..." />anywhere in MDX without imports. - Matches your desired ergonomics.
- No, explicit imports
- More obvious dependencies per page.
- Annoying for citations.
My recommended answer: option 1.
Add:
CiteCitep
to globalMdxComponents in astro.config.mjs.
Do you agree?
Yes.
Next question:
Should we create one component with a mode prop internally, or two separate public component files?
Options:
- Two public components, shared internal helper
src/components/Cite.astrosrc/components/Citep.astro- both use shared logic from
src/lib/citations.ts
Show remaining 23 lines
- Clean MDX API.
- One component only
<Citation ref="..." mode="narrative" />- Less aligned with your desired
<Cite>/<Citep>syntax.
- One implementation component plus tiny wrappers
Citation.astrodoes rendering.Cite.astroandCitep.astrowrap it.- Good if Astro supports passing props cleanly enough, but may be unnecessary.
My recommended answer: option 1.
Two public .astro components plus a TypeScript helper module:
src/components/Cite.astro
src/components/Citep.astro
src/lib/citations.ts
scripts/generate-citations.ts
src/data/auto/citations.json
Do you agree?
Yes.
Next question:
How should we handle possessive or grammatical variants of narrative citations?
Example prose:
<Cite ref="berton-2023" /> model predicts...
renders:
Show remaining 30 lines
Berton (2023) model predicts...
But sometimes you want:
Berton’s (2023) model predicts...
Options:
1. **Ignore in v1**
- Author can write around it:
```mdx
The model in <Cite ref="berton-2023" /> predicts...
```
2. **Add `possessive` prop**
- `<Cite ref="berton-2023" possessive />`
- → `Berton’s (2023)`
- More polish, but slightly expands API.
3. **Add arbitrary `text` override**
- `<Cite ref="berton-2023" text="Berton’s (2023)" />`
- Too much; risks mismatches.
**My recommended answer:** option 1.
Keep v1 simple and add grammar variants only when actual writing needs them.
Do you agree?Yes.
Next question:
Should Cite be allowed to contain multiple refs, or should multiple refs only be allowed in Citep?
Example:
<Cite ref="berton-2023; kaercher-corcos-2025" />
Possible narrative rendering:
Show remaining 23 lines
Berton (2023); Kärcher and Corcos (2025)
Options:
- Allow multiple refs in both
CiteandCitep
- Symmetric API.
- Pandoc can render narrative multi-citations.
- Allow multiple refs only in
Citep
- More natural: parenthetical grouped citations are common.
- Narrative multi-citations can get grammatically awkward.
- If needed, write two narrative citations manually:
``mdx
<Cite ref="berton-2023" /> and <Cite ref="kaercher-corcos-2025" />
``
My recommended answer: option 2.
Citep should support semicolon-separated multiple refs. Cite should accept exactly one ref in v1. This avoids awkward narrative grammar and keeps locators simpler.
Do you agree?
Yes.
Next question:
What exact inline rendering should page/locator produce?
Given Chicago/Pandoc style, examples:
For parenthetical:
<Citep ref="smith-2020" page="42" />Show remaining 29 lines
Options:
(Smith 2020, 42)(Smith 2020, p. 42)(Smith 2020: 42)
For narrative:
<Cite ref="smith-2020" page="42" />
Options:
Smith (2020, 42)Smith (2020, p. 42)Smith (2020), 42
My recommended answer: use Pandoc/CSL locator behavior, which for Chicago author-date is typically:
(Smith 2020, 42)
Smith (2020, 42)
So:
page="42"passes locator42.locator="chap. 2"passes exact locator-ish suffix if we can support it cleanly.- Output follows Pandoc.
Do you agree with Pandoc/CSL locator punctuation?
Yes.
Next question:
Should locator be free text, or should we only support page?
Pandoc can handle simple locators cleanly:
<Citep ref="berton-2023" page="42" />
→ (Berton 2023, 42)
Show remaining 30 lines
But arbitrary locator text is less predictable:
<Citep ref="berton-2023" locator="chap. 2" />
Options:
- Support only
pagein v1
- Simple and predictable.
- Most common need.
- Avoids weird citation text.
- Support both
pageandlocator
- More flexible.
- Need rules: cannot pass both; locator is inserted after year using Pandoc syntax.
- Support
locatoronly
- General, but less self-documenting.
My recommended answer: option 1.
Use:
<Citep ref="berton-2023" page="42" />
<Cite ref="berton-2023" page="42" />
Skip generic locator until you actually need chapters/sections.
Do you agree?
Yes.
Next question:
Should a page citation count as the same already-cited reference for sidenote suppression?
Example:
<Cite ref="berton-2023" />
...
<Citep ref="berton-2023" page="42" />Show remaining 17 lines
Options:
- Same reference key suppresses sidenote regardless of page
- First citation gets full reference sidenote.
- Later page-specific citation is inline only:
(Berton 2023, 42). - Simple and avoids repeated full bibliography entries.
- Different page locator creates a new sidenote
- Could mention page-specific context.
- But your sidenote is just bibliographic, not quote annotation, so repetition is unnecessary.
My recommended answer: option 1.
Track cited-ness by BibTeX key only, not page.
Do you agree?
Yes.
Next question:
Should we support citation children/content, or should citations be self-closing only?
Examples:
<Cite ref="berton-2023" />
vs.
Show remaining 24 lines
<Cite ref="berton-2023">Berton’s model</Cite>
which might render:
Berton’s model [sidenote marker]
Options:
- Self-closing only
- Clear semantics.
<Cite>controls citation text.
- Allow children as override text
- More flexible.
- But makes author-year behavior less consistent.
My recommended answer: option 1.
For v1, citation components should be self-closing and produce their own inline text from BibTeX/Pandoc.
Do you agree?
Yes.
Next question:
Should the generated citation data include all BibTeX entries, or only entries actually cited in current MDX content?
Options:
- All BibTeX entries
- Simple generator.
- Any valid key in
references.bibis available. citations.jsonmay include unused references, but likely small.
Show remaining 11 lines
- Only cited entries
- Smaller generated file.
- But generator must scan MDX for
<Cite>/<Citep>usage. - Adding a citation requires regeneration after content edit, not just BibTeX edit.
My recommended answer: option 1.
Generate citation data for every BibTeX key in src/data/references.bib. The file can grow, but citation libraries are usually manageable, and this avoids MDX scanning complexity.
Do you agree?
Yes.
Next question:
Should the generator depend on a JavaScript BibTeX parser, or should it use Pandoc itself to discover/render entries?
Options:
- Use Pandoc as the only citation processor
- Generator shells out to Pandoc.
- Avoids adding a BibTeX parser dependency.
- But extracting keys and short labels may need a small BibTeX key regex.
Show remaining 19 lines
- Add a JS BibTeX parser
- Easier to inspect entries, normalize DOI fields, extract keys/authors/years.
- Then still use Pandoc for formatted output.
- More dependency surface.
- Fully custom JS formatting
- Avoids Pandoc at generation time.
- But contradicts the “use BibTeX/Pandoc/CSL” goal.
My recommended answer: option 1.
Use Pandoc for formatting and a small conservative parser/regex only to:
- find entry keys like
@article{berton-2023, ...} - normalize obvious bad DOI forms before passing a temporary BibTeX file to Pandoc
No extra dependency unless this proves brittle.
Do you agree?
Yes.
Next question:
Should generated citation data include precomputed inline strings for both narrative and parenthetical citations, or should components assemble inline text from structured fields?
Options:
- Precompute inline strings with Pandoc
- Generator asks Pandoc for:
- narrative: @berton-2023 → Berton (2023)
- parenthetical: [@berton-2023] → (Berton 2023)
Show remaining 28 lines
- page variants generated at component time? Harder, because page values are dynamic props.
- Most style-faithful, but less flexible for arbitrary
page.
- Store enough structured data for components to assemble inline text
- Store something like:
``json
{
"authorLabel": "[REDACTED_ENV:authorLabel]",
"year": "2023",
"fullHtml": "..."
}
``
- Components render:
- Cite: authorLabel (year)
- Citep: (authorLabel year)
- with page: (authorLabel year, page)
- Slightly less pure Pandoc, but matches Chicago author-date enough for v1 and handles
pageeasily.
- Hybrid
- Store Pandoc-rendered inline strings for no-page citations.
- Store structured
authorLabel/yearfor page variants. - More data, more complexity.
My recommended answer: option 2.
Use Pandoc for full reference HTML, but use a small structured inline formatter for author-year strings. Reason: page is a runtime prop in MDX, so precomputing every locator is impossible. For Chicago author-date, Author (Year) and (Author Year, page) are straightforward.
Do you agree?
Yes.
Next question:
How should authorLabel be generated for inline citations?
Examples:
- one author:
Berton - two authors:
Kärcher and Corcos - three authors: maybe
Smith, Jones, and LeeorSmith et al.
Options:
Show remaining 30 lines
- Use Pandoc-rendered inline citations to derive labels
- Generator asks Pandoc for
@keyand[@key]. - Extracts/stores the no-page rendered strings or parses out author/year.
- Most style-faithful, but string extraction is a little fiddly.
- Parse BibTeX
authorfield manually
- One author → last name.
- Two authors →
A and B. - Three or more →
A et al. - Simple enough for v1, but may mishandle institutions, editors, suffixes, particles, nonstandard names.
- Store Pandoc-rendered no-page strings and structured fallback
narrativeText:Kärcher and Corcos (2025)parentheticalText:(Kärcher and Corcos 2025)- plus
authorLabelandyearfor page variants. - More robust, slightly more complex.
My recommended answer: option 2 for v1, with conservative behavior:
- split BibTeX authors on
and - use the surname part for each author
- 1 author:
Surname - 2 authors:
Surname and Surname - 3+ authors:
Surname et al. - use
year - fail generation if an entry lacks usable
authororyear
This is good enough for article citations and keeps runtime simple.
Do you agree?
Yes.
Next question:
How should entries without an author field be handled?
Some BibTeX entries may eventually be reports, standards, software, websites, or institutional publications with fields like:
organization = {World Meteorological Organization}
or:
Show remaining 29 lines
editor = {Smith, Jane}
instead of `author`.
Options:
1. **Require `author` and `year` for v1**
- Generator fails if a cited/generated entry lacks them.
- Simple and strict.
- Fine if your references are mostly journal articles.
2. **Fallback to `editor`, then `organization`, then `title`**
- More robust for reports/web resources.
- More parsing rules.
3. **Generate full sidenote for all entries, but only allow inline `<Cite>`/`<Citep>` for author-year-compatible entries**
- Complicated distinction.
**My recommended answer:** option 2.
For inline label:
1. `author` if present
2. else `editor` if present, with maybe `ed.` ignored in inline v1
3. else `organization` / `institution` / `publisher`
4. else fail with a clear generator error
Still require `year` for v1.
Do you agree with those fallbacks?Yes.
Next question:
Should date be accepted as a fallback to year?
Some BibTeX/web entries may have:
date = {2025-10-01}
instead of:
Show remaining 24 lines
year = {2025}
Options:
1. **Require `year` only**
- Simple.
- Many BibTeX entries have `year`.
2. **Fallback from `date` to first 4-digit year**
- More robust for CSL-ish entries.
- Easy enough.
3. **Allow `month` + `year`, but not `date`**
- Less useful.
**My recommended answer:** option 2.
For inline citation year:
- use `year` if present
- else parse first four-digit year from `date`
- else fail generation
Do you agree?Yes.
Next question:
Should the generator fail on every BibTeX entry that lacks author/year, or only on entries that are actually cited?
Earlier we chose generating data for all BibTeX entries. That implies strict validation on all entries unless we decide otherwise.
Options:
- Fail on all invalid entries
- Keeps
references.bibclean.
Show remaining 15 lines
- But pasted/staged entries you are not using yet can break generation.
- Generate full entries for all possible entries, but mark incomplete ones unusable
- Components fail only if you cite an incomplete entry.
- More tolerant.
- But since generator does not scan MDX, it won’t know cited vs unused.
- Require valid author/year-ish metadata for all entries included in
references.bib
- Same as option 1, but framed as a convention.
My recommended answer: option 1/3 for now.
If references.bib is the site bibliography, entries should be citation-ready. Since you’re pasting journal BibTeX, most will have author/year. If later you want a messy “reference inbox,” we can add src/data/reference-inbox.bib or skip invalid entries.
Do you agree that npm run citations should fail if any BibTeX entry cannot produce an author/year label?
Yes.
Next question:
Should the generator write TypeScript instead of JSON to improve type safety?
Options:
- JSON
src/data/auto/citations.json- Simple, matches our earlier discussion.
- Importable in Astro/TS with existing config likely.
Show remaining 12 lines
- TypeScript
src/data/auto/citations.ts- Can export
as const. - Easier type inference.
- But generated code is a little less neutral.
My recommended answer: option 1.
Use JSON and define TypeScript types in src/lib/citations.ts.
Do you agree?
Generate TypeScript. I think we should make that a general policy. Like for the biographical data, which is also TypeScript.
Good correction. That changes the generated artifact shape.
Next question:
What should the generated TypeScript module export?
Options:
- Single default/const citation map
```ts
Show remaining 39 lines
export const citations = {
"berton-2023": {
authorLabel: "[REDACTED_ENV:authorLabel]",
year: "2023",
fullHtml: "..."
}
} as const;
```
- Citation map plus exported key type
``ts
export const citations = { ... } as const;
export type CitationKey = keyof typeof citations;
``
- Citation map, key type, and source metadata
```ts
export const citationSource = {
bibliography: "src/data/references.bib",
generatedAt: "..."
} as const;
export const citations = { ... } as const;
export type CitationKey = keyof typeof citations;
```
My recommended answer: option 2.
Avoid generatedAt because it creates noisy diffs every time generation runs. Keep the generated module stable:
// Generated by scripts/generate-citations.ts from src/data/references.bib.
// Do not edit directly.
export const citations = { ... } as const;
export type CitationKey = keyof typeof citations;
Do you agree?
Yes.
Next question:
Should citation component props type ref as CitationKey, or keep it as string?
In .astro components, props can be typed, but MDX string literals may or may not give useful compile-time checking depending on Astro/MDX behavior.
Options:
- Type as
stringand validate at runtime/build render
- Reliable clear build errors.
Show remaining 20 lines
- Handles semicolon-separated refs naturally.
- Type as
CitationKeywhere possible
- Better editor/TS checks for
<Cite ref="..." />maybe. - Awkward for multi-ref
Citep, becauserefcan be"a; b".
- Use
string, exportCitationKeyfor helper code only
- Good balance.
My recommended answer: option 3.
Props:
ref: string;
page?: string | number;
Helper functions validate keys against generated citations.
Do you agree?
Yes.
Next question:
Should page numbers accept numbers as well as strings?
Examples:
<Citep ref="smith-2020" page="42" />
<Citep ref="smith-2020" page={42} />
<Citep ref="smith-2020" page="42–43" />Show remaining 19 lines
Options:
- Accept string only
- Simpler type.
- Ranges work naturally.
- Accept string or number
- More ergonomic in MDX.
- Convert to string internally.
My recommended answer: option 2.
Use:
page?: string | number;
Do you agree?
Yes.
Next question:
Should citation components expose id or open props for the underlying Sidenote?
Existing Sidenote supports:
id?: string;
label?: string;
open?: boolean;Show remaining 18 lines
Options:
- No passthrough props
- Keep citations simple.
- Use default sidenote behavior.
- Expose
openonly
- Allows a citation sidenote to be expanded by default if needed.
- Expose
id,label, andopen
- Full control, but more API.
My recommended answer: option 1.
Citation sidenotes are not hand-authored annotations; they should behave consistently. If future needs arise, we can add open.
Do you agree?
Yes.
Next question:
Should full citation HTML in sidenotes be wrapped as a list when multiple new refs appear?
Example:
<Citep ref="berton-2023; kaercher-corcos-2025" />
Options:
Show remaining 23 lines
- Single ref: bare paragraph; multiple refs: ordered/unordered list
- Single note stays compact.
- Multi-note is readable:
``html
<ol>
<li>...</li>
<li>...</li>
</ol>
``
- Always list
- Consistent, but single citation has unnecessary list styling.
- Join with line breaks
- Compact but less semantic.
My recommended answer: option 1.
Single unseen ref: sidenote body contains its full HTML directly.
Multiple unseen refs: wrap each citation in an ordered list.
Do you agree?
Yes, although the list needs to be styled so that there are no extraneous bullets or other decorations, just some space between the citations.
Next question:
Should multi-citation sidenote lists be semantic lists with CSS removing markers, or plain block wrappers?
Options:
- Semantic list, visually unmarked
```html
<ol class="citation-list">
<li>...</li>
Show remaining 26 lines
<li>...</li>
</ol>
``
CSS:
`css
.citation-list {
list-style: none;
padding-left: 0;
}
``
Screen readers still understand it as a list.
- Plain wrappers
``html
<div class="citation-list">
<div>...</div>
<div>...</div>
</div>
``
No list semantics, simpler visual behavior.
My recommended answer: option 1.
Use semantic <ol> but style away numbering/bullets and add spacing between entries.
Do you agree?
Yes.
Next question:
Should we keep the prop name ref, even though ref can be a special/reserved-ish JSX concept in some frameworks?
Your desired syntax is:
<Cite ref="berton-2023" />
<Citep ref="kaercher-corcos-2025" />Show remaining 26 lines
Options:
- Keep
ref
- Matches your requested API.
- Short and natural for BibTeX references.
- Astro components should receive it as a normal prop in this context.
- Use
key
- Bad idea because
keyis also special in JSX-like systems.
- Use
citeorcitation
- Avoids any
refambiguity:
``mdx
<Cite cite="berton-2023" />
``
- But less natural than your requested syntax.
- Support both
refandcite
- Flexible but unnecessary API clutter.
My recommended answer: option 1.
Keep ref. It is exactly the authoring syntax you want, and if Astro/MDX treats it normally for .astro components, it keeps the API clean.
Do you agree?
I don't actually care what it's called. I actually think the ideal syntax might be <Cite>berton-2023</Cite> and <Citep>berton-2023; kaercher-corcos-2025</Citep> rather than putting the key in a prop.
That is probably better authoring syntax.
Next question:
Should citation keys be passed as component children instead of a prop?
Proposed API:
<Cite>berton-2023</Cite>
<Citep>berton-2023; kaercher-corcos-2025</Citep>Show remaining 36 lines
<Citep page="42">berton-2023</Citep>
Options:
1. **Children-only**
- Cleanest MDX prose syntax.
- Citation key visually reads like content.
- But component must parse slot text and reject non-plain children.
2. **Prop-only**
- Easier implementation:
```mdx
<Cite ref="berton-2023" />
```
- Slightly uglier.
3. **Support both children and prop**
- Flexible, but creates two conventions.
- Need precedence/error rules.
**My recommended answer:** option 1.
Use children-only in v1:
<Cite>berton-2023</Cite>
<Citep>berton-2023; kaercher-corcos-2025</Citep>
Rules:
- slot content must be plain text after trimming
- semicolon-separated keys allowed only in `Citep`
- no nested markup/expressions inside citation components
- `page` remains a prop because it is metadata, not the citation key
Do you agree with children-only citation keys?Yes. That looks better.
Next question:
How strict should the child content parser be?
Because Astro slots render as HTML, these:
<Cite>berton-2023</Cite>Show remaining 41 lines
and maybe line-wrapped:
<Citep>
berton-2023; kaercher-corcos-2025
</Citep>
will need to be reduced to plain text.
Options:
- Allow whitespace/newlines only around plain text keys
- Trim outer whitespace.
- Collapse internal whitespace around semicolons.
- Reject rendered HTML tags.
- Good examples:
``mdx
<Cite>berton-2023</Cite>
<Citep>
berton-2023; kaercher-corcos-2025
</Citep>
``
- Bad:
``mdx
<Cite><em>berton-2023</em></Cite>
``
- Allow arbitrary rendered text by stripping HTML tags
- More forgiving.
- But accidental markup could silently become a citation key.
- Single-line only
- Simplest.
- Annoying for multi-citations.
My recommended answer: option 1.
Allow plain text with harmless whitespace/newlines, but fail the build if the slot contains markup or anything that does not parse cleanly as citation keys.
Do you agree?
Yes, option 1.
Next question:
Should <Cite> allow a page prop with child-key syntax?
Example:
<Cite page="42">berton-2023</Cite>
renders:
Show remaining 25 lines
Berton (2023, 42)
Options:
- Yes, both
CiteandCitepsupportpage
- Symmetric.
- Useful for narrative citations.
- Only
Citepsupportspage
- Slightly simpler.
- But unnecessarily restrictive.
My recommended answer: option 1.
Support:
<Cite page="42">berton-2023</Cite>
<Citep page="42">berton-2023</Citep>
Still reject page when Citep contains multiple refs.
Do you agree?
Yes.
Next question:
Should we still support the original prop syntax as a compatibility alias?
Examples:
<Cite ref="berton-2023" />
<Cite>berton-2023</Cite>Show remaining 20 lines
Options:
- No, children-only
- One canonical syntax.
- Avoids ambiguity.
- Matches the revised preferred API.
- Yes, support both
- Easier if you later forget the syntax.
- But two conventions.
My recommended answer: option 1.
Use children-only:
<Cite>berton-2023</Cite>
<Citep>berton-2023; kaercher-corcos-2025</Citep>
Do you agree to drop ref entirely?
Yes. Children only.
Next question:
How should the component extract child citation keys in Astro?
Astro slots are rendered asynchronously via Astro.slots.render('default'), which returns an HTML string. For plain text children, that should be easy to trim.
Options:
- Parse rendered slot HTML as plain text only
- Render slot to string.
Show remaining 30 lines
- Reject if it contains
</>tags after trimming. - Decode basic HTML entities if needed.
- Parse semicolon-separated keys.
- Simple and sufficient.
- Use a remark/MDX transform instead
- More structurally correct.
- But much larger implementation.
- Avoid children syntax because slot parsing is awkward
- We already decided children syntax is nicer.
My recommended answer: option 1.
Implement a helper like:
parseCitationSlot(await Astro.slots.render('default'))
It should accept:
berton-2023
and reject:
<em>berton-2023</em>
Do you agree?
Yes.
Next question:
Should HTML entity decoding be supported for citation keys?
Probably not needed for BibTeX keys like:
berton-2023
kaercher-corcos-2025Show remaining 16 lines
Options:
- No entity decoding
- Citation keys should be ASCII-ish.
- Simpler.
- If rendered slot contains
&, it will fail validation.
- Decode basic entities
- More robust for weird keys.
- But encourages complicated keys.
My recommended answer: option 1.
Require simple BibTeX keys that do not need HTML entity decoding. Your existing keys fit this.
Do you agree?
Yes.
Next question:
What characters should citation keys allow?
Existing keys:
berton-2023
kaercher-corcos-2025Show remaining 26 lines
Options:
- Conservative
``regex
/^[A-Za-z0-9:_-]+$/
``
Allows common BibTeX keys.
Rejects spaces, slashes, periods.
- BibTeX-ish broader
Allow most non-whitespace/non-semicolon characters.
More flexible, but less clean.
- No regex, just lookup in generated citation map
Missing lookup catches invalid keys.
But error messages less precise for malformed multi-ref strings.
My recommended answer: option 1.
Use simple citation keys:
letters, numbers, colon, underscore, hyphen
Do you agree?
Yes.
Next question:
Should the generator also enforce the same key regex for BibTeX entry keys?
Options:
- Yes
- Prevents generating keys that components cannot cite.
- Clear convention for this site.
Show remaining 14 lines
- No
- Let BibTeX contain broader keys, but components may not handle them.
- Inconsistent.
My recommended answer: option 1.
If a BibTeX key does not match:
/^[A-Za-z0-9:_-]+$/
npm run citations should fail with a clear error.
Do you agree?
Yes.
Next question:
Should we create a Backlog task now before implementation?
Project instructions say if we proceed to implementation, use Backlog CLI:
- create task
- set In Progress
- assign to self
- add implementation plan
- share plan and wait for approval before coding
Show remaining 20 lines
Options:
- Yes, create one task for citation tooling
- Title:
Add BibTeX-backed MDX citation sidenotes - ACs reflect our decisions.
- Then I add implementation plan and pause for your approval.
- Split into several tasks
- generator, components, styling, docs/tests
- More traceable, but probably overkill for this feature.
- Skip Backlog
- Faster, but conflicts with project instructions.
My recommended answer: option 1.
One task is enough for this coherent feature.
Do you want me to create the Backlog task and implementation plan now?
Yes, go ahead. One task is enough.
Created and started Backlog task:
TASK-13— Add BibTeX-backed MDX citation sidenotes
Implementation plan:
- Inspect current MDX/global-component and sidenote patterns.
- Add
scripts/generate-citations.tsto readsrc/data/references.bib, validate keys/metadata, normalize DOI URL forms, call Pandoc, and writesrc/data/auto/citations.ts. - Add
src/lib/citations.tsfor parsing, validation, inline formatting, per-page cited state, and errors. - Add
src/components/Cite.astroandsrc/components/Citep.astro.
Show remaining 7 lines
- Register
Cite/Citepglobally inastro.config.mjs. - Add CSS for unmarked spaced multi-citation sidenote lists.
- Add
npm run citations; leavenpm run buildunchanged. - Add/adjust tests and run
npm test,npm run citations,npm run build. - Complete Backlog ACs and final summary after verification.
Please confirm if you want me to proceed with implementation.
Please go ahead.
Implemented TASK-13.
Added:
scripts/generate-citations.tssrc/data/auto/citations.tssrc/lib/citations.tssrc/components/Cite.astrosrc/components/Citep.astrotest/citations.test.ts
Show remaining 20 lines
Updated:
astro.config.mjs— global MDXCite/Citeppackage.json—npm run citationssrc/styles/global.css— unmarked citation sidenote list styling
Usage:
<Cite>berton-2023</Cite>
<Citep>berton-2023; kaercher-corcos-2025</Citep>
<Citep page="42">berton-2023</Citep>
Validation:
npm run citationspassesnpm run buildpasses- Citation tests pass
- Full
npm teststill has one unrelated existing failure expectingdist/sessions/001-first-session/index.html
Backlog task TASK-13 is marked Done.
That works pretty well, but when the dev server rerenders a page containing a citation, the citation sidenote disappears.
Fixed.
Root cause: citation “already seen” state was stored on globalThis keyed by pathname. In the dev server, rerendering the same page reused that state, so citations were treated as repeats and their sidenotes disappeared.
Change:
- Moved citation seen-state to per-render
Astro.locals. - Repeated citations still suppress duplicate sidenotes within one render.
- A fresh dev-server rerender gets fresh citation state.
Updated:
Show remaining 10 lines
src/lib/citations.tssrc/components/Cite.astrosrc/components/Citep.astrotest/citations.test.ts
Validation:
node --test test/citations.test.tspassesnpm run buildpasses
Backlog TASK-14 marked Done.
Please commit the relevant changes. I have been editing some content pages by hand in the meantime: don't commit those.
Committed relevant citation changes only.
Commit:
1c78049 Add BibTeX citation sidenotes
Left uncommitted:
public/figures/placeholder.svgsrc/components/BaseHead.astrosrc/components/Header.astrosrc/content/project/overview.mdx
Show remaining 3 lines
src/pages/index.mdxsrc/pages/project/index.astrosrc/data/auto/references.el