Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

General notes for collection of materials #281

Open
mahish opened this issue Nov 8, 2016 · 2 comments
Open

General notes for collection of materials #281

mahish opened this issue Nov 8, 2016 · 2 comments
Milestone

Comments

@mahish
Copy link

mahish commented Nov 8, 2016

Hey,
first let me thank you for this amazing framework. I do rly enjoy it:)

I would love to have possibility to show general notes for whole group of materials, e.g. notes for lists:

└── materials
    └── components
        └── lists
            ├── ordered.html
            └── unordered.html

Taken the logic behind the notes system (notes in front matter or in .md files with the same name), I would expect it should work something like this:

└── materials
    └── components
        └── lists
            ├── ordered.html
            └── unordered.html
        └── lists.md

But actually I would like more this one:

└── materials
    └── components
        └── lists
            ├── lists.md (or notes.md)
            ├── ordered.html
            └── unordered.html

Anyway, I didn't find a way to do it by myself. Any hint?

@GuerillaRadio
Copy link

I agree this is much needed. Has anyone figured out a way to add notes to groups of materials (i.e. a materials folder)?

@mahish
Copy link
Author

mahish commented Feb 24, 2017

I ended up with a workaround. Basically I duplicated & modifed notes functionality in fabricator-assembler/index.js which you can find in node_modules. Then used it once in the first material item within the group/collection in the same way as you would use notes. You just need to prepare your include templates.

// get material front-matter, omit `notes`
var localData = _.omit(fileMatter.data, ['notes', 'collectionNotes']);

// trim whitespace from material content
var content = fileMatter.content.replace(/^(\s*(\r?\n|\r))+|(\s*(\r?\n|\r))+$/g, '');


// capture meta data for the material
if (!isSubCollection) {
  assembly.materials[collection].items[key] = {
    filename: id,
    name: toTitleCase(id),
    notes: (fileMatter.data.notes) ? md.render(fileMatter.data.notes) : '',
    data: localData
  };
} else {
  assembly.materials[parent].items[collection].items[key] = {
    filename: id,
    name: toTitleCase(id.split('.')[1]),
    notes: (fileMatter.data.notes) ? md.render(fileMatter.data.notes) : '',
    collectionNotes: (fileMatter.data.collectionNotes) ? md.render(fileMatter.data.collectionNotes) : '',
    data: localData
  };
}

Check the index.js, lines 325-345 in fabricator-assembler repo.

Hope it helps.

@mahish mahish changed the title General notes for grouped materials General notes for collection of materials Feb 24, 2017
@LukeAskew LukeAskew added this to the 2.0.0 milestone Apr 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants