Page
Last modified by Manuel Leduc on 2025/07/11 14:44
Users
Explanations
Attachments are stored in hidden directories with the same name as the page without its extension. For instance for page space/mypage, the mardown is stored in space/mypage.md, and an attachment named image.png in space/.mypage/attachments/image.png.
This format is used for the File System, Nextcloud and GitHub backends.
Developers
Reference
Page reader
/**
* Provide the operations to read a page content.
* @since 0.20
*/
interface PageReader {
/**
* Parse the provided page content, and returns a json object containing the actual page content plus the
* available metadata. The metadata are expected to be provided as a yaml object wrapped between two lines
* containing exactly '---'
* @param pageContent - the provided page content
*/
readPage(pageContent: string): { [key: string]: unknown };
}Page writer
/**
* @since 0.20
*/
interface PageWriter {
writePage(pageContent: { [key: string]: unknown }): string;
}How To
Read a page
import { DefaultPageReader } from "@xwiki/cristal-page-default";
const defaultPageReader = new DefaultPageReader();
const pageContent = `---
title: Page title
---
Some page content`;
const metadata = defaultPageReader.readPage(pageContent);Write a page
import { DefaultPageWriter } from "@xwiki/cristal-page-default";
const defaultPageWriter = new DefaultPageWriter();
const page = defaultPageWriter.writePage({ content: "Some page content", title: "Page title" });
/*
---
title: Page title
---
Some page content
*/

This project is being financed by the French State as part of the France 2030 program
Ce projet est financé par l’État Français dans le cadre de France 2030