Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "groupings" #15

Open
thiagodemellobueno opened this issue Feb 2, 2018 · 3 comments
Open

Implement "groupings" #15

thiagodemellobueno opened this issue Feb 2, 2018 · 3 comments

Comments

@thiagodemellobueno
Copy link
Contributor

thiagodemellobueno commented Feb 2, 2018

Just as with "mappings" we currently implement .... we could use grouping strings to group multiple fields into keys, this maybe just a modified 'mapping' functionality.

eg.

groupings: [
  content: 'Content_',
  our_promise: 'Promise_'
  meta: 'Metadata_',
]

should we use "starts with" (hithercontent groups tabs in a given template under Tab-Name_, this could help us deal with some complex structures.

alternately, we can also use:

groupings: [
  name: [
    'first_name',
    'last_name'
  ]
  image: [
    '*results-img__alt',
    '*results-img__image',
    '*results-img__caption'
  ]
]

might have to switch from simple indexing to minimatch for pattern matching... coming towards either a naming convention, or some flag mechanism to indicate when / which objects to apply these groupings to is part of design i have not yet considered.

groupings: {
  image: {
    pattern: [
      'portfolio/**'
    ],
    fields: [
      '*-Image__alt',
      '*-Image__image',
      '*-Image__caption/
    ]
}

overall it would be cool if we could create these conveniences and make the parsing of data into something of a 'middleware' so we could hook up to different content stores, and just write mini plugins for each one (reducing the cost / technical debt for swtiching to different content apis (gather content, contentful, eventually a sweet drupal experience outputting a restful api?)

@RobLoach thoughts?

@thiagodemellobueno
Copy link
Contributor Author

thiagodemellobueno commented Feb 5, 2018

mappings: {
    global: { // applies to all variables in the loop
        title: 'Content_Title', // Map single value
        name: ['Content_First-Name', 'Content_Last-Name'] // Concat values (join with space?)
    },
    article: { // Applies to content with the `article` template
        hero: { // Map nested
            image: [
                { alt: 'Hero-Image__alt' },
                { src: 'Hero__Image' },
                { caption: 'Hero__Image_Caption' },
                { attribution: 'Hero__Image_Attribution' }
            ]
            title: 'Content_Page_Title'
        ]
    }

}

@RobLoach
Copy link
Contributor

RobLoach commented Feb 8, 2018

Hmmmm, it could, but unsure we'd need it. Is mappings front-matter from a file? Or from Gather Content?

Perhaps this is just an extra function that's called from the plugin? Collections would've do it right?

@RobLoach
Copy link
Contributor

RobLoach commented May 18, 2018

https://www.npmjs.com/package/json-mapping
https://www.npmjs.com/package/node-json-transform

  1. Add json-mapping to project
  2. Introduce a gathercontent-mapping.metadata or something???
  3. Have gather content addon read the mappings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants