AO3 Loader #
A small Astro site that turns a folder of fanfiction files into pages you can read on your website. The works can come from an author's AO3 profile, from EPUBs and PDFs you downloaded from AO3, or from Markdown files you wrote yourself.
It's an example of an Astro content loader. Yours to copy and play around with!
Getting started #
You'll need Node.js 22.12 or newer. Install the dependencies, then start the site:
npm install
npm run dev
| Command | Action |
|---|---|
npm install |
Installs dependencies |
npm run dev |
Starts the local dev server at localhost:4321 |
npm run typecheck |
Checks TypeScript and Astro files |
npm run build |
Builds your production site to ./dist/ |
npm run preview |
Previews your build locally, before deploying |
What the site looks like #
Works list page #
See: ao3-loader/src/pages/index.astro

Work page #
See: ao3-loader/src/pages/works/[workId]/chapters/[chapterNumber].astro
With placeholder content since we can't get chapters from AO3 right now 🥲

Adding works #
Put them in the One Folder™: src/content/fanfics/. They can go inside
subfolders too, so organize them however you like. The loader can tell what
each file is from its name, and skips loading any file that isn't named like these:
| A file named like this... | ...is read as |
|---|---|
Wishing Well.epub, Wishing Well.pdf |
A work you downloaded from AO3 |
Danger High Voltage.work.md |
A one-shot you wrote in Markdown |
A folder with a _work.yaml and .chapter.md files |
A multichapter work you wrote in Markdown |
Wishing Well.ao3.yaml |
A work the loader saved from AO3 for you (how) |
Every time you run npm run dev or npm run build, the loader reads every
work it finds in the folder and hands them to Astro, which checks that each one
is actually shaped like the fanfics it expects. If a file has
a mistake, the build stops, and the error should tell you the problem and what file to fix.
The terminal shows every work that was loaded, so you can check that yours made it in.
Note
If the same work is in the folder more than once, like an EPUB and a PDF of the same fic, the loader keeps only one copy, picking the first it finds in this order: a Markdown work you wrote, a work the loader saved, an EPUB, then a PDF. The terminal names each file that was left out, and the file that was kept instead.
Downloading from an AO3 profile #
The loader doesn't just show what's already in its folder. It can also fill the folder
for you, by downloading an author's works from AO3 and saving them in
src/content/fanfics/.
Setting up the manifest #
To set up the loader to download from AO3, you list the author in a file called manifest.yaml:
- Copy
src/content/fanfics/manifest.example.yamlto a new file namedmanifest.yaml, in the same folder - Replace
astolatafterauthor:with the author's AO3 username, and changefolder_nameto where you want their works saved. Remove the settings you don't need - Run
npm run dev
From then on, every run downloads the author's works before loading the
folder. Each work is saved as a .ao3.yaml file, in a folder named after the
author (or the folder_name you pick), and is loaded like any other file in
there.
Manifest options #
The manifest only decides what gets downloaded. The Astro site still shows everything in the folder, whether the manifest mentions it or not:
download: false=> stops asking AO3 for this author's works, and keeps showing the ones already savedchapters: true=> also downloads the text of every chapter, which makes each run slowerexclude=> skips works in the fandoms you list, or posted under the pseuds you list
Every option is explained in manifest.example.yaml.
Important
While download is on, every run saves the author's works again, and
replaces each saved file with what AO3 sends:
- An edit you made to a saved file is lost, and a saved file you deleted comes back
- Chapters saved by an earlier run are lost if
chaptersisfalse, or if AO3 doesn't send a work's chapters this time
Note
The loader never deletes a saved file. If you change folder_name,
organize_by, or name_by, or the author renames a work on AO3, the old
file stays where it was, and the site can show either copy. Delete
the old files yourself.
EPUBs and PDFs from AO3 #
Drop the EPUBs and PDFs you downloaded from AO3 anywhere in
src/content/fanfics/. They show up on the site like any other work.
Writing your own works #
You can also write works yourself, in Markdown.
One-shots #
A one-shot is a single file whose name ends in .work.md. The work's details
go at the top, between the --- lines, and the text goes below them:
---
# Titles with ": " in them need quotes
title: "Danger: High Voltage"
author: boba-tan
fandoms: [Binary Calls]
tags:
characters: [NAND Cypher, Reader]
relationships: [NAND Cypher/Reader]
additional: [Mutual Pining]
# Use | for a multiline summary (with markdown support). Always indent by the
# same amount of blank spaces
summary: |
Reader finds out resistance _is_, after all, futile.
Written for the ["Ohm Sweet Ohm" challenge](https://fujocoded.com).
---
A triangular outline loomed through the frosted pane, slender
cables crackling in the electric night.
The doorbell rang. The lights flickered.
_Reader's heart followed suit._
Only title and author are needed. For more than one author, write
authors: [boba-tan, CSS] instead. A work with no author stops the build.
Everything else is optional:
- The tag types are yours to name, so you're not stuck with AO3's
- Most fields an AO3 work has (
rating,language,adult,complete, and so on) can go here too. The full list isotherWorkSchema, insrc/content/fanfics/_config/your-works.ts url,shortUrl,host, andstatscan't, since your work isn't on AO3. Writing one stops the build- The loader counts your chapters for you. Write
chaptersyourself to change it, likechapters: { published: 3, total: 5 } - The loader doesn't count words. To show a word count, write it yourself,
like
words: 1234
Lists can also be written one item per line, which is easier to read when they get long:
fandoms:
- Binary Calls
tags:
characters:
- NAND Cypher
- Reader
relationships:
- NAND Cypher/Reader
additional:
- Enemies to lovers
- Only One Server Rack
- NAND Cypher Is Bad at Feelings
Multichapter works #
A multichapter work is a folder. The work's details go in a file named
_work.yaml, and each chapter is its own file, with a name that ends in
.chapter.md:
Binary Calls/Opposites Conduct/_work.yaml
Binary Calls/Opposites Conduct/01-clinging-with-static.chapter.md
Binary Calls/Opposites Conduct/02-spark-then-surge.chapter.md
_work.yaml holds the same details as the top of a one-shot, without the
--- lines. The underscore means "this file is about the folder it's in, it's
not a chapter". It also keeps the file at the top of the folder.
title: Opposites Conduct
author: boba-tan
fandoms: [Binary Calls]
A folder with a _work.yaml and no .chapter.md file stops the build, with a
message that names the folder.
A chapter file can have its own title, summary, and notes at the top, or
nothing at all:
---
title: Clinging with Static
summary: When voltage runs high, NAND Cypher is suddenly jealous.
notes:
start: Don't like, don't read
end: |
Thanks to my beta!
Next chapter on Friday.
---
"You sound like a power freak." The words are out of my mouth
before I can stop them. "I think we could use a breaker."
Chapter order #
Every .chapter.md file in the folder is loaded, in alphabetical order.
Starting each name with a number (01-, 02-) is the easy way to get the order
you want. 2 comes before 10, so you don't have to write 02...we just like
keeping our file prefixes the same length.
To number the chapters yourself without relying on order, give each one an
index. It always wins over the name of the file:
---
index: 2
title: Spark, Then Surge
---
Important
You can skip numbers (1, 2, 5). Two things stop the build, with a message that names the files to fix:
- An
indexon some chapters of a work but not on others. It's every chapter or none - The same
indexon two chapters of a work
Things to know #
- The summary and notes are Markdown too, like the text
- The
idcan be left out. The loader makes one from the first author's username and the title (boba-tan-danger-high-voltageabove). If two of your works end up with the sameid, only one is kept, and the terminal says which - To replace a work the loader saved, or an EPUB or PDF, with your own
version, give your Markdown work the same
id: the number in the work's AO3 link - Other
.mdfiles, like a README or your notes, are left alone
Changing the loader #
The loader's code is in src/content/fanfics/_config/. Start with
index.ts: it reads top to bottom, from what a work looks like to how Astro
gets them.
The _config README says what's in
each file, and where to make the most common changes.