Giter Club home page Giter Club logo

deno_blog's Introduction

Blog

Minimal boilerplate blogging. All you need is one boilerplate JavaScript file that has 2 lines of code:

import blog from "https://deno.land/x/blog/blog.tsx";

blog();

Getting started

To initialize your own blog you can run following script:

$ deno run -r --allow-read --allow-write https://deno.land/x/blog/init.ts ./directory/for/blog/

This command will setup a blog with a "Hello world" post so you can start writing right away.

Start local server with live reload:

$ deno task dev

To ensure the best development experience, make sure to follow Set up your environment from the Deno Manual.

Configuration

You can customize your blog as follows:

import blog, { ga, redirects } from "https://deno.land/x/blog/blog.tsx";
import { unocss_opts } from "./unocss.ts";

blog({
  author: "Dino",
  title: "My Blog",
  description: "The blog description.",
  avatar: "avatar.png",
  avatarClass: "rounded-full",
  links: [
    { title: "Email", url: "mailto:[email protected]" },
    { title: "GitHub", url: "https://github.com/denobot" },
    { title: "Twitter", url: "https://twitter.com/denobot" },
  ],
  lang: "en",
  // localised format based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
  dateFormat: (date) =>
    new Intl.DateTimeFormat("en-GB", { dateStyle: "long" }).format(date),
  middlewares: [
    ga("UA-XXXXXXXX-X"),
    redirects({
      "/foo": "/my_post",
      // you can skip leading slashes too
      "bar": "my_post2",
    }),
  ],
  unocss: unocss_opts, // check https://github.com/unocss/unocss
  favicon: "favicon.ico",
});

Preview

Customize the header and footer

By default, we render the header and footer with builtin template using the blog settings. You can customize them as follows:

/** @jsx h */

import blog, { h } from "https://deno.land/x/blog/blog.tsx";

blog({
  title: "My Blog",
  header: <header>Your custom header</header>,
  showHeaderOnPostPage: true, // by default, the header will only show on home, set showHeaderOnPostPage to true to make it show on each post page
  section: (post) => (
    <section>Your custom section with access to Post props.</section>
  ),
  footer: <footer>Your custom footer</footer>,
});

Beware to use .tsx extension to this extent.

Hosting with Deno Deploy

To deploy the project to the live internet, you can use Deno Deploy:

  1. Push your project to GitHub.
  2. Create a Deno Deploy project.
  3. Link the Deno Deploy project to the main.tsx file in the root of the created repository.
  4. The project will be deployed to a public $project.deno.dev subdomain.

Self hosting

You can also self-host the blog, in such case run:

$ deno task serve

deno_blog's People

Contributors

ije avatar j-tag avatar roj1512 avatar bartlomieju avatar ry avatar yidingww avatar lidessen avatar kt3k avatar geoffreypetri avatar windchime-yk avatar lino-levan avatar jlcarveth avatar gofenix avatar beyazit avatar abschill avatar rottenpen avatar wangbinyq avatar s-uei avatar prettykool avatar omar2205 avatar mmyoji avatar linbingquan avatar everettjf avatar willpuckett avatar kyeotic avatar psimk avatar musab avatar levex avatar crowlkats avatar korigamik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.