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

custom elements as pages (aka one off page templates) #170

Closed
1 of 5 tasks
thescientist13 opened this issue Aug 17, 2019 · 4 comments
Closed
1 of 5 tasks

custom elements as pages (aka one off page templates) #170

thescientist13 opened this issue Aug 17, 2019 · 4 comments
Assignees
Labels
enhancement Improve something existing (e.g. no docs, new APIs, etc) question Further information is requested v0.10.0
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Aug 17, 2019

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Currently to generate a page, Greenwood goes through the pages directory and builds out a route for every .md file.

src/
  pages/
    about.md
    index.md

However, if you predominantly want to write a page in just JavaScript to generate HTML content dynamically you would have to do something like this in a page template instead:

const postsData = [/* some array of  "post" objects */];
const postsList = postsData.map(item => {
  return html`<li>${item.title}</li>`;
})

...

render() {
   return html`
     <ul>
        ${ postsList }
     </ul>
   `
}

Basically every page needs a markdown file and a template. This is great for many to one (many pages, one template) but if your page is better authored as JavaScript, you still need to create two files.

Details

So it would be great to see if maybe doing something like this would essentially treat about.js as a Template by default?

src/
  pages/
    about.js
    index.md

This way, if you have one off or JavaScript heavy pages, you only have to make one file for it.

Additionally, it would make sense that the templates folder would essentially just be a collection of layouts, which is most useful when stamping out many pages of the same structure (like a blog post)

@thescientist13 thescientist13 added the question Further information is requested label Aug 17, 2019
@thescientist13 thescientist13 changed the title custom elements as (one off) pages (one off page templates) custom elements as pages (aka one off page templates) Aug 17, 2019
@thescientist13
Copy link
Member Author

This may end up falling under / becoming its own RFC.

@thescientist13 thescientist13 added the enhancement Improve something existing (e.g. no docs, new APIs, etc) label Nov 10, 2019
@thescientist13
Copy link
Member Author

Another great use case would be for projectevergreen.github.io. For more "webapp" like projects, being able to use JS to author a page would be really nice. This would allow the project to extract out all the home page content into a custom element instead of stuffing the page-template full of code just to serialize some JS.

@thescientist13 thescientist13 added this to the MVP milestone Nov 26, 2019
@thescientist13
Copy link
Member Author

I think this might be invalid now that all users can build up their pages anyway they want now?

@thescientist13 thescientist13 self-assigned this Dec 31, 2020
@thescientist13
Copy link
Member Author

not needed, templates / pages are HTML first now in v0.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve something existing (e.g. no docs, new APIs, etc) question Further information is requested v0.10.0
Projects
None yet
Development

No branches or pull requests

1 participant