メインコンテンツまでスキップ

Metadata

use MejiroEPUB\DocumentInfo;

new DocumentInfo(
title: '目白の旅',
language: 'ja',
author: '目白 太郎',
identifier: 'https://novels.example.com/works/42',
publisher: 'Example Novels',
description: "全126話、完結。\n小さな鳥が、山を越えて海を見に行く話。",
source: 'https://novels.example.com/works/42',
published: new DateTimeImmutable('2024-04-01'),
);
ArgumentWritten asNotes
titledc:titleRequired. Marked as the main title.
languagedc:language, xml:langRequired. A BCP 47 tag: ja, en, en-US.
authordc:creator with the role author
identifierdc:identifierSee below.
publisherdc:publisherFor a web novel, the site.
descriptiondc:descriptionThe synopsis. Line breaks are kept.
sourcedc:sourceWhere the text comes from, such as the work's page.
publisheddc:dateWhen the work was published, written as a day.

The time the file was made is separate: it is modified: on the Document and defaults to now.

Optional values are null when absent. An empty or blank string is an error (ME-VAL-1001) rather than an empty element — pass null.

All of it is cleaned like body text: control characters removed, broken UTF-8 repaired, markup escaped.

The identifier​

Reading systems use the identifier to tell books apart. Give the same book the same identifier every time you generate it, and a reader that already has it can treat the new file as an update rather than a second copy.

Any stable string works. A work's URL is a natural choice; so is urn:uuid:… derived from your own record. If you pass none, a random UUID is generated and an INFO line is logged suggesting you pass one — which means every download looks like a different book.

Shelf titles and file names​

Some reading systems show the file name on their shelf instead of the title in the metadata, even though they read the metadata — Kinokuniya's Kinoppy, for one, shows the author and publisher from the file but lists an imported book as work_42.epub. Nothing inside the EPUB changes that.

So name the downloaded file after the work: 目白の旅.epub, not work_42.epub. Serving downloads shows how to send a Japanese file name safely.