How to use the frontity.connect function in frontity

To help you get started, weโ€™ve selected a few frontity 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 frontity / frontity / packages / twenty-twenty-theme / src / components / mobile / menu-modal.js View on Github external
@media (min-width: 700px) {
    font-size: 2.4rem;
    padding: 2.5rem 0;
  }

  &:hover,
  &:focus {
    text-decoration: underline;
  }
  /* styles for active link */
  &[aria-current="page"] {
    text-decoration: underline;
  }
`;

export default connect(MobileMenuModal);
github frontity / frontity / packages / twenty-twenty-theme / src / components / page-meta-title.js View on Github external
const cleanTitle = postTitle.replace(/<\/?[^>]+(>|$)/g, "");
    // 3. Render the proper title.
    title = `${cleanTitle} - ${state.frontity.title}`;
  } else if (data.is404) {
    // Add titles to 404's.
    title = `404 Not Found - ${state.frontity.title}`;
  }

  return (
    
      <title>{title}</title>
    
  );
};

export default connect(Title);
github frontity / frontity / packages / extension-example-1 / src / index.tsx View on Github external
beforeCSR: ({ state }) =&gt; {
        console.log("beforeCSR");
      },
      afterCSR: ({ state }) =&gt; {
        console.log("afterCSR");
      },
      action1: ({ state }) =&gt; {
        state.extension1.prop1 = 2;
      },
      action2: ({ state }) =&gt; num =&gt; {
        state.extension1.prop1 = num;
      }
    }
  },
  roots: {
    extension1: connect(Extension1)
  },
  fills: {
    extension1: () =&gt; <div>I am a fill of extension example 1</div>
  },
  libraries: {
    comments: {
      Comment: () =&gt; <div>I am a comment from extension example 1!</div>
    }
  }
};

export default ExtensionExample1;
github frontity / frontity / packages / twentytwenty-theme / src / components / archive / archive-pagination.js View on Github external
{isTherePreviousPage &amp;&amp; (
          
            
          
        )}
      
      
    
  );
};

/**
 * Connect Pagination to global context to give it access to
 * `state`, `actions`, `libraries` via props
 */
export default connect(Pagination);

const Text = styled.em`
  display: inline-block;
  margin-top: 16px;
`;

const Container = styled.div`
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
  width: calc(100% - 8rem);
  margin-left: auto;
  margin-right: auto;
`;
github frontity / frontity / packages / twenty-twenty-theme / src / components / search-modal.js View on Github external
name="search"
            /&gt;
            Search
          

          
            Close search
            
          
        
      
    
  );
};

export default connect(SearchModal);

const ModalOverlay = styled.div`
  background: rgba(0, 0, 0, 0.2);
  display: none;
  opacity: 0;
  position: fixed;
  bottom: 0;
  left: -9999rem;
  top: 0;
  transition: opacity 0.2s linear, left 0s 0.2s linear;
  width: 100%;
  z-index: 999;

  &amp;[data-open="true"] {
    display: block;
    opacity: 1;
github frontity / frontity / packages / twentytwenty-theme / src / components / post / post-categories.js View on Github external
return (
    
      Categories

      
        {postCategories.map(category =&gt; (
          
            {category.name}
          
        ))}
      
    
  );
};

export default connect(PostCategories);

const EntryCategories = styled.div`
  line-height: 1.25;
  margin-bottom: 2rem;

  @media (min-width: 700px) {
    margin-bottom: 3rem;
  }
`;

const EntryCategoriesInner = styled.div`
  justify-content: center;
  display: flex;
  flex-wrap: wrap;
  margin: -0.5rem 0 0 -1rem;
github frontity / frontity / packages / mars-theme / src / components / theme.js View on Github external
return (
    &lt;&gt;
      
        <title>{state.frontity.title}</title>
        
      
      
      
        <header>
      
      {Content}
    
  );
};

export default connect(Theme);

const HeadContainer = styled.div`
  display: flex;
  align-items: center;
  flex-direction: column;
  background-color: #1f38c5;
`;

const Body = styled.div`
  display: flex;
  justify-content: center;
  background-image: linear-gradient(
    180deg,
    rgba(66, 174, 228, 0.1),
    rgba(66, 174, 228, 0)
  );</header>
github frontity / frontity / packages / twenty-twenty-theme / src / components / search / search-results.js View on Github external
)}
        
      

      {isEmpty ? (
        
          
        
      ) : (
        
      )}
    
  );
};

export default connect(SearchResults);

const IntroText = styled(SectionContainer)`
  width: 100%;
  margin-top: 2rem;
  font-weight: initial;

  @media (min-width: 700px) {
    font-size: 2rem;
    margin-top: 2.5rem;
  }
`;

const Text = styled.p`
  margin: 0 0 1em 0;
  &amp;:last-child {
    margin-bottom: 0;
github goiblas / personal-blog / packages / mars-theme / src / components / timeago.js View on Github external
const { lang } = state.frontity.lang;
    const articleDate = new Date(date);

    const rtf = new Intl.RelativeTimeFormat( lang, { style: 'short' })
    const diff = diffFromNow(date)
    const timeago = diff &gt; -24
      ? rtf.format(diff, 'hours')
      : rtf.format(Math.floor(diff / 24), 'days')

    return (
        <time datetime="{" pubdate="true">{timeago}</time>
    )
}

export default connect(Timeago);
github frontity / frontity / packages / yoast / src / components / facebook.tsx View on Github external
{data.isPost &amp;&amp; (
        
          
          {(state.yoast.facebook.image || state.yoast.image) &amp;&amp; (
            
          )}
        
      )}
    
  );
};

export default connect(Facebook);