3.14.1 • Published 5 years ago

contentz v3.14.1

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

Contentz

license releases npm version dependencies lerna

Create Content, Get a Highly Optimized Website

  • Use MDX to write articles and pages
  • Support Incremental Build
  • Offline First
  • Use Frontmatter to define metadata for your articles and pages
  • Prefetch every internal link used in your content
  • Get an archive page with linked and prefetched articles
  • Get a homepage with links to social networks
  • Good Looking Responsive Design
  • Automatic Dark Mode (in Safari)
  • Apply CSS in MDX using the css prop and the css template tag
  • Internationalization
  • Generate social images (Open Graph) in a single command
  • Automatically generate table of contents

Install it

Install it using npm or yarn with a simple command

yarn add contentz
# npm install contentz

Use it

After you have installed Contentz you could use it with a simple command.

contentz build

That will read your files and generate your website for you.

Create configuration

Create a configuration file called config.yml

---
title: Sergio Xalambrí
description: Senior Software Engineer and Technical Writer
domain: https://sergiodxa.com
language: en
repository: https://github.com/sergiodxa/personal-site/
email: hello@sergiodxa.com
patreon: sergiodxa
analytics: UA-XXXXXXXXX-2
social:
  twitter: sergiodxa
  github: sergiodxa
  npm: sergiodxa
  linkedin: sergiodxa
  dev: sergiodxa
  meetup: 182915204
navigation:
  - name: About
    path: /about
  - name: Services
    path: /services

Table of options

OptionDescriptionRequired
titleThe title of the website, used in the <title> and in the homepageNo (default: Just another Contentz site)
descriptionThe description of the website, used in the <meta> and in the homepageNo (default: empty description)
domainThe domain you are going to use to host the website, used in the RSS feedYes
languageThe main language of the website, used as fallback for articles and pagesNo (default: en)
repositoryThe GitHub repository hosting the website, used in the footer of articles and pagesNo (default: hide link to edit)
emailYour email address, used on the Email icon in the homepageNo (default: hide icon)
patreonYour Patreon username, used in the homepage and the footerNo (default: hiden patreon message)
analyticsYour Analytics UANo (default: hide analytics)
socialA list of your social networks, used to link them in the homepageNo (default: hide social icons)
navigationA list of pages to link in the headerNo (default: don't add extra links)
swSet it as false if you want to disable SW generationNo (default: true)
incrementalSet it as false if you want to disable incremental buildNo (default: true)
iconSet the path of the favicon of the websiteNo (default: /static/favicon.png)

Possible social networks

For other Social Networks send a PR with a new icon and add a way to format the URL for that icon.

Start Writing

Create a folder /articles and put your .mdx files there, here's an example post.

---
title: My super cool article
description: This is the description of the article
date: 2018-01-01T00:00:00.000Z
published: true
---

This is my content, here I could use markdown or import a component and render it.

Now run contentz and it will create a /public directory with your homepage, archive page and article. You could access your archive at /articles/ and each article as /articles/:article/, in the example you may see it at /articles/my-super-cool-article.

Custom Pages

For custom pages create a /pages folder and put your .mdx files there, here's an example page.

---
title: About me
---

Hi! I'm an example page.

Now run contentz and it will create a /public directory with your homepage and pages. Each page will be put at the base level of public, that mean your /pages/about.mdx could be accessed as /about/ in your browser and not /pages/about.

Link Sharing

In case you want to have a page to share interesting links you could create a link.yml file at the root of your project. Then run contentz and it will automatically generate a /link/ page for you with a list of all your links. Each link should have url, title, comment and date key. Example file:

---
- url: https://sergiodxa.com/
  title: Sergio Xalambrí
  comment: The website of the creator of Contentz
  date: 2019-01-28T19:44:10.945Z
- url: https://sergiodxa.dev/
  title: sergiodxa.dev
  comment: The alias of the website of the creator of Contentz
  date: 2019-01-28T19:44:10.945Z

Error Page

Contentz will automatically generate an error page on /404.html, when deploying you could redirect not found pages to /404.html.

If you deploy to Netlify it will pick up that file automatically.

Service Worker and Offline Mode

Contentz generate a SW automatically for you, this SW will cache every request to your own website (using location.origin). It will not cache request to another domain.

This behavior could be disabled adding sw: false to your config.yml file. Adding this will also delete de sw.js and load-sw.js to avoid cached access to the and create the unload-sw.js file.

RSS Feed

Contentz will generate a valid RSS Atom feed automatically with your list of articles, it will be placed in /atom.xml and a <meta> tag will be automatically added for you in each page to make it discoverable.

Static Files

If you want to link to static files like images, videos, etc. create a /static folder and put all your files there. When running content they will be automatically copied to /public/static

Style in MDX

In case you want to add an HTML tag with custom styles directly in your MDX content you could use the css prop9https://emotion.sh/docs/css-prop) and the css template tag of Emotion.

Example:

<div css={{ color: "red" }}>This is red</div>
<div css={css`color: blue`}>This is blue</div>

Incremental Build

Contentz will detect what files changed and only update the related files. This mean if you add a new link only /link/ will be regenerated, but if you change an article the article pages, the list of articles and the RSS feed will be regenerated.

In the case you update the configuration or you update Contentz version all pages will be regenerated.

If you want to opt-out of this feature set incremental: false in your config.yml. This will automatically invalidate previous caches and always generate all pages.

Social Image

Contentz could also automatically generate social images (aka Open Graph) for you to use in your articles and pages. To use it run the command:

contentz social [path]

Where [path] is the file to use to generate the social image. It could also be more than one file adding an space between them.

contentz social [path1] [path2]

A path could be a path for an article, a post or one of the auto generated pages.

  • home
  • archive/articles
  • links
  • error

If you want to generate them initially run

contentz social home articles links error

After generating the social images you will see a folder /static/_social with your images, pages will be placed in /static/_social/pages and articles in /static/_social/article, special pages will be at the root of _social.

Internationalization

Contentz support i18n out of the box for the fixed texts of the website, text like the Patreon support or edit on GitHub. To change the main language of your website set the key language or the key lang (language is prefered) to the language code.

Supported languages are es for Spanish and en for English (default to English in case of invalid language code).

If your language is not supported add a JSON with the messages and load it in the i18n lib. Then send a PR to add it.

3.14.1

5 years ago

3.14.0

5 years ago

3.13.3

5 years ago

3.13.2

5 years ago

3.13.1

5 years ago

3.13.0

5 years ago

3.12.1

5 years ago

3.12.0

5 years ago

3.11.0

5 years ago

3.10.0

5 years ago

3.9.0

5 years ago

3.8.1

5 years ago

3.8.0

5 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.2

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.8.0

5 years ago

2.7.0

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.10.0

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.0.0

5 years ago