Closed ProductiveCoding closed 5 months ago
Ah, I see. How married are you to scene_alias
? I think something like the widely-used title
property might make more sense.
This could probably be done with a compile step, no?
I don't know how toget the same result with a compile step
Il Gio 25 Gen 2024, 16:54 B. Camphart @.***> ha scritto:
This could probably be done with a compile step, no?
— Reply to this email directly, view it on GitHub https://github.com/kevboh/longform/issues/237#issuecomment-1910489724, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACC2WZCMHP56JBZEHUW2OKDYQJ53XAVCNFSM6AAAAABCJOD3HSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJQGQ4DSNZSGQ . You are receiving this because you authored the thread.Message ID: @.***>
A custom step, yes. Here's one, tested locally:
module.exports = {
description: {
name: "Rename scenes to aliases",
description: "Retitles scenes to their scene_alias property, if present",
availableKinds: ["Scene"],
options: [],
},
compile(scenes) {
return scenes.map((scene) => {
const fm = scene.metadata.frontmatter;
if (!fm) {
return scene;
}
return {
...scene,
name: fm["scene_alias"] || scene.name,
};
});
},
};
See the docs on how to use it. You'll need to add this script as a .js
file in your vault, then set the containing folder in Longform settings. After that the step will be available in the add compile step modal.
Remember to use this step before stripping frontmatter (although it may still work, I just didn't go back and verify).
Closing, please lmk if you need more help using this feature.
Describe the solution you'd like Add a "scene_alias" field to the the front-matter of the note so that longform uses it instead of the scene title, when valorized. This allows the user to have a scene titled "chapter 1" but the scene-alias value in the compiled manuscript.md (i.e. "My first chapter") and even id for pandoc cross-references (i.e. "My first chapter {#sec:my_first_chapter}"). I implemented my solution adding the following piece of code after line 21306 if (sceneInput.metadata.frontmatter.scene_alias != null) { title = title.replace("$1", sceneInput.metadata.frontmatter.scene_alias); } else { title = title.replace("$1", sceneInput.name); }