How to use the nextein/posts.inCategory function in nextein

To help you get started, we’ve selected a few nextein examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elmasse / nextein-example / pages / stories.js View on Github external
render() {
    const { posts, selected } = this.props
    
    const stories = posts.filter(inCategory(selected))
    return (
      <main>
        <h1>{selected.replace(`${category}/`, ``)}</h1>
        <section>
          {
            stories.map((story, idx) =&gt; (
              <article>
                <h2><a>{story.data.title}</a></h2>
                <content>
              </content></article>
            ))
          }
        </section>
      </main>
    )
  }
github elmasse / nextein-example / pages / index.js View on Github external
const Index = ({ posts }) =&gt; {
  
  const inPosts = posts.filter(inCategory('post')).sort(sortByDate)
  const inHome = posts.filter(inCategory('home'))

  return (
    <main style="{styles.main}">
      
      
      <section style="{styles.section}">
        <h1>/post</h1>
        <p>{inPosts.length} entries found.</p>    
        {
          inPosts
          .map((post, idx) =&gt; )
        }
      </section>
      <section style="{styles.section}">  
        <h1>/home</h1>
        <p>{inHome.length} entries found.</p>    </section></main>
github elmasse / nextein-example / pages / index.js View on Github external
const Index = ({ posts }) =&gt; {
  
  const inPosts = posts.filter(inCategory('post')).sort(sortByDate)
  const inHome = posts.filter(inCategory('home'))

  return (
    <main style="{styles.main}">
      
      
      <section style="{styles.section}">
        <h1>/post</h1>
        <p>{inPosts.length} entries found.</p>    
        {
          inPosts
          .map((post, idx) =&gt; )
        }
      </section>
      <section style="{styles.section}">  
        <h1>/home</h1></section></main>
github elmasse / nextein-example / next.config.js View on Github external
const getStories = async () =>  {
  const category = 'stories'
  const all = await entries()
  return all
    .filter(inCategory(category, {includeSubCategories: true}))
    .map(post => post.data.category)
    .filter((category, idx, arr) => arr.indexOf(category) === idx )
    .reduce((prev, entry) => ({
      ...prev,
      [`/${entry.replace(`${category}/`, '')}`]: { page: '/stories', query: { category: `${entry}` } }
    }), {})
}

nextein

A static site and blog generator based on Next.js

ISC
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis