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

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deno_blog's Issues

Type error occurred when preset was specified for unocss

presetUno() will result in a type error, but it does not appear from the README that any options are required.
Am I using it wrong?

❯ deno check main.tsx
Check file://path/to/project/main.tsx
error: TS2322 [ERROR]: Type 'Preset<Theme>' is not assignable to type 'Preset<{}> | Preset<{}>[]'.
  Type 'Preset<Theme>' is not assignable to type 'Preset<{}>'.
    Types of property 'rules' are incompatible.
      Type 'Rule<Theme>[] | undefined' is not assignable to type 'Rule<{}>[] | undefined'.
        Type 'Rule<Theme>[]' is not assignable to type 'Rule<{}>[]'.
          Type 'Rule<Theme>' is not assignable to type 'Rule<{}>'.
            Type '[RegExp, DynamicMatcher<Theme>]' is not assignable to type 'Rule<{}>'.
              Type '[RegExp, DynamicMatcher<Theme>]' is not assignable to type '[string, CSSObject | CSSEntries]'.
                Type at position 0 in source is not compatible with type at position 0 in target.
                  Type 'RegExp' is not assignable to type 'string'.
      presetUno(),

My main.tsx is like this.

/** @jsx h */

import blog from "https://deno.land/x/[email protected]/blog.tsx";
import presetUno from 'https://esm.sh/@unocss/[email protected]'

blog({
  ...,
  unocss: {
    presets: [
      presetUno(),
    ],
  },
});

RSS feed is missing post content

I noticed that the generated RSS feed doesn't include the post content, but the library that's being used to generate it supports content.

Was this an intentional decision? Would you be open to either adding the content by default, or through a setting? I can create a PR if you're ok with either.

Test passes locally but fails on CI

The main reason is pathname conflict in these two file:

  • testdata/posts/fifth.md
  • testdata/posts/fifth-uses-pathname.md

in fifth-uses-pathname.md, there is pathname: "/fifth" setting, so both file uses http://localhost:8000/fifth.

This is probably because the order in which files are stored differs depending on the execution environment when walking files under the posts directory.

So this assertion fails only in CI:

https://github.com/denoland/deno_blog/blob/main/blog_test.ts#L167

Renaming fifth.md solves it. However, it should display an error.

What's the license of this project?

Thanks for the awesome project!

I really want to use, but it seems there are no license specified.
Is this project intentionally unlicensed? Or, just forget to put it?

HMR not working

Request /hmr.js, return "Internal server error"
Function fromFileUrl throwed error: Uncaught TypeError: Must be a file URL

"NotFound: No such file or directory" on Deno Deploy

Hi, I've tried to deploy the minimal blog example to Deno Deploy, but encountered this issue:

Screenshot 2023-01-09 at 23 10 34

I'm pretty new to Deno ecosystem and I'm not sure how I can debug it, especially if I cannot reproduce it on my machine. Locally (deno task dev) works just fine - no issues.

Enabling language configuration used in the site

First of all, congratulations on this project! I really enjoy it.

I'd like to discuss an issue that I'd very much like to work on. But I thought I'd get everyone's opinion on it before forking.

Today, the blog pretty much only supports English as the language used on the page besides the content provided on the posts.

Things like: Read More (on the PostCard component), Home (on the PostPage component), etc.

I see that there is already a slot in the components for using a different language. For instance, in the PostCard component:

image

There is the lang parameter that is ultimately taken from the blog config options. Today, it is unused, but it would be ideal for this feature. I think it was left there for this purpose exactly.

So, what is missing here is a mapping between languages ISO codes and the text used in the components.

One way of accomplishing this is as follows:

So in each component we needed this feature we would have a mapping of ISO language codes and the corresponding text in each language. For example, in the PostCard component:

image

And then use it as follows:

image

So what do you guys think?

External Redirects

main.tsx:

[...snip...]
redirects({
  "/github": "https://github.com/levex"
}),
[...snip...]

When navigating to the Deno Deployed blog: https://lev.deno.dev/github the redirect is treated as internal and it 302s me to https://lev.deno.dev/https://github.com/levex

There should be an option to mark a redirect as external, or at least a heuristic.

Adding more syntax highlighting

It seems that gfm has turned on syntax highlighting for JavaScript, Markdown, and HTML by default. And I saw that syntax highlighting for C is also supported by this repo.

import "https://esm.sh/[email protected]/components/prism-c?no-check";

Is there a preferred way to support other languages?

Adding ability to set custom directory for blog

It would be great to have a way to set a custom directory for blog content so we can compile blog in one machine and use the compiled output file on another machine to host the blog.

This way for example we can set the custom path like this:

blog({
    customDirectory: "/home/myuser/blog/"
});

I'd like to send a PR for this feature.

Add support for html and body attributes

Hi,

I don't know where the repo of nanossr is.

Would be nice to include the new attributes props of <Helmet />.

Example:

const App = () => {
  return (
    <div>
      <Helmet>
        <html lang="en" amp />

        <body class="root" />
        <body class="main" id="id" />

        <title>Nano JSX Helmet SSR</title>
        <meta name="description" content="Nano-JSX application" />
      </Helmet>

      <Helmet footer>
        <script src="/this/belongs/to/the/footer.js"></script>
      </Helmet>

      <h1>Hello nano!</h1>
    </div>
  )
}

const app = Nano.renderSSR(<App />)
const { body, head, footer, attributes } = Helmet.SSR(app)

const html = `
<!DOCTYPE html>
<html ${attributes.html.toString()}>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    ${head.join('\n')}
  </head>
  <body ${attributes.body.toString()}>
    ${body}
    ${footer.join('\n')}
  </body>
</html>
`

Missing await in ga middleware

I'm using this deno_blog with ga middleware, but Google Analytics not working.
I think I found the cause, it is missing await in this line.

gaReporter(request, ctx.connInfo, res!, start, err);

Reproduce

Here's my main.ts file.

import blog, { ga, redirects } from "blog";

blog({
   ...
  middlewares: [
    // If you want to set up Google Analytics, paste your GA key here.
    ga("G-XXXXXXXXXX"),
  ],
});

Light theme not work at detail page

Light theme not work at detail page

<div class="mt-8 markdown-body" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark"></div>

if i remove data-dark-theme="dark", it's work

"$100" is not rendered correctly

My markdown file is this:

---
title: Hello world!
publish_date: 2022-05-29
---

It costs about $100 to buy a new computer.

but it is rendered to:

<div><p>It costs about </p><div>00 to buy a new computer.<p></p>
</div></div>

Do you have any idea?

I also tested deno-gfm. input:

import { CSS, render } from "https://deno.land/x/[email protected]/mod.ts";
const markdown = "It costs about $100 to buy a new computer.";
const body = render(markdown);
console.log(body)

output:

<p>It costs about $100 to buy a new computer.</p>

Consider supporting inline markdown

Inline markdown could be useful for lightweight markup on blog post titles, and it could be implemented easily with Marked's parseInline function.

Much Needed Features

Finally, I found the Best and Minimal Blog Generator
but it required some options to enhance

  • Custom Font
  • Edit Default CSS or Override CSS for a custom look
  • Canonical URL
  • Pagination
  • default search function
  • robots.txt
  • sitemap

toggle html sanitization

It would be nifty to be able to javascript Canvas API things from within markdown, imo.

many thanks,

feature request: footnotes

This would be a lovely affordance for writing informative, meandering, well-researched, well-referenced blog posts.

As seen here.

Docs?

Hello contributors.

Seeing as this repo is growing in size, I think it would be good to add a Documentation page that explain all the available BlogSettings or how to syntax highlight other files and whatever. Owing to the minimalist nature of this, a single DOCS.md page would be enough for me. RFC

[Request] add static building

Given that (at some point) the deno blog isn't fetching dynamic data but rather a website for all users, the deno blog should be able to generate static files.

Slow Loads

Blog is hosted on deno deploy at https://smote.io and is taking about 7 seconds to load on initial load. Once it's been loaded, it moves normally. There's no warnings or errors coming out of the logs... Is this normal?

Docs: explain how pages get served

From skimming the code, it looks like it searches from the current directory recursively to look for files ending with .md files and loads them all into memory. Maybe explain this in the README?

Incorrect date displayed on posts in dev environment

When working on new posts, edition your sites files, or doing any task while deno task dev is running, the date displayed on posts is a day behind.

---
title: Hello world!
publish_date: 2022-07-13
---

Results in 07/12/22 being displayed in the development environment. In production on Deno Deploy this is a non-issue but I keep having this bug on a variety of Linux distros.

Production
image

BUG: Non-unicode markdown files not support.

Sorry, my english is very poor!

Non-unicode markdown files not support.

Steps

  1. Create markdown file into posts folder, filename use "中文名称.md".
  2. Start deno server deno task dev.
  3. Click 'Read More' on website.
  4. Result is 'Not Found'

image

image

Customize port via environment variable

Currently, there is no way to customize the runtime port via environment variables. This can be irritating, and is an easy fix.

#48 is a pull request to redress this issue. By defining BLOG_PORT one can customize their runtime port. Otherwise, it'll default to 8000. @bartlomieju

Add icon for mastodon link

There isn't currently an icon for Mastodon links. Would you be open to adding one?

I've already personally added one and can submit a PR if that is okay.

error invalid data

deno run -r --allow-read --allow-write https://deno.land/x/blog/init.ts ./blog
cd blog
deno task dev

error

Task dev deno run --allow-net --allow-read --allow-env --watch main.tsx --dev
Watcher Process started.
error: invalid data
    at https://deno.land/x/[email protected]/deps.ts:10:25
Watcher Process failed. Restarting on file change...

deno 1.35.0 linux

I have some CSS and HTML...

I worked out some CSS and HTML and I like what Deno is trying to do. Is there any way to make custom templates and include a custom stylesheet and use custom classes? I'd like to rewrite my blog in Deno...

disable_html_sanitization not working

markdown file looks like this:

---
title: Hello world!
publish_date: 2023-03-09
disable_html_sanitization: true
---

This is my first blog post!

<iframe src="https://editor.p5js.org/capogreco/full/lqJs887v-"></iframe>

Which should show an embed of one of my p5 sketches. Alas, it looks like this:

Screenshot 2023-03-09 at 10 06 49 pm

ie. the iframe was sanitized out. Am I doing something wrong, or is disable_html_sanitization not working?

Ordered & Unordered lists - numbers / dot points not visible

As it says in the title. Neither lists with numbers, ie.

1. first item
2. second item
3. third item

... nor lists with dashes, ie.

- this item
- that item
- the other item

... are showing up with their respective numbers / dot points. Indentation is correct, and the items are fine, just the numbers / dot points seem to be invisible.

Is this a global issue, or just me? Might be a CSS thing?

Adding Plausible Analytics?

I want to implement Plausible Analytics for my blog. This requires linking a script tag in the . From looking at the code, I could fork the repo and add the script to sharedHtmlOptions, however that would mean I would need to swap dependencies which I'd like to avoid. Is there a way to add a <script> tag to the without modifying the source code?

How can you change the text color?

Hi, is there a way I can change my text's theme to light mode? Is there a method in the blog(); method like there is for title, description, author, etc. like in down below?

blog({
  title: "Egyptian Religion....",
  description: "and why it was important to the people...",
  author: "Deno"
)};

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.