GithubHelp home page GithubHelp logo

inkproject / ink Goto Github PK

View Code? Open in Web Editor NEW
1.1K 45.0 119.0 16.68 MB

An elegant static blog generator

Home Page: https://inkproject.github.io/

Go 45.63% HTML 13.21% CSS 29.55% JavaScript 10.24% Shell 0.69% Dockerfile 0.69%
golang javascript static-site-generator blog-engine

ink's Introduction

Introduction

InkPaper is a static blog generator developed in Golang. No dependencies, cross platform, easy to use, fast building times and an elegant theme.

apm

InkPaper - An Elegant Static Blog Generator

Features

  • YAML format configuration
  • Markdown format articles
  • No dependencies, cross platform
  • Super fast build times
  • Continuously improving theme and typography
  • Multiple article authors support
  • Archive and tag generation
  • Real-time preview when saving
  • Offline full-text keyword search
  • $\LaTeX$ style math formula support (MathJax):

$$ \int_{-\infty}^\infty g(x) dx = \frac{1}{2\pi i} \oint_{\gamma} \frac{f(z)}{z-g(x)} dz $$

Quick Start

  • Download & Extract Ink and run ink preview

    Tip:Linux/macOS, use ./ink preview

  • Open http://localhost:8000 in your browser to preview

Website Configuration

Edit config.yml, use this format:

site:
    title: Website Title
    subtitle: Website Subtitle
    limit: Max Article Count Per Page
    theme: Website Theme Directory
    comment: Comment Plugin Variable (Default is disqus username)
    root: Website Root Path # Optional
    lang: Website Language # Support en, zh, ru, ja, de, pt-br, configurable in theme/lang.yml
    url: Website URL # For RSS generating
    link: Article Link Scheme # Default is {title}.html, Support {year}, {month}, {day}, {hour}, {minute}, {second}, {title} variables

authors:
    AuthorID: # Your author ID, used in article's author field
        name: Author Name
        intro: Author Motto
        avatar: Author Avatar Path

build:
    output: Build Output Directory # Optional, default is "public"
    port: Preview Port
    copy:
        - Copied Files When Build
    publish: |
        Excuted command when 'ink publish' is used

Blog Writing

Create a .md file in the source directory (Supports subdirectories). Use this format:

title: Article Title
date: Year-Month-Day Hour:Minute:Second #Created Time. Support timezone, such as " +0800"
update: Year-Month-Day Hour:Minute:Second #Updated Time, optional. Support timezone, such as " +0800"
author: AuthorID
cover: Article Cover Path # Optional
draft: false # Is draft or not, optional
top: false # Place article to top or not, optional
preview: Article Preview, Also use <!--more--> to split in body # Optional
tags: # Optional
    - Tag1
    - Tag2
type: post # Specify type is post or page, optional
hide: false # Hide article or not. Hidden atricles still can be accessed via URL, optional
toc: false # Show table of contents or not, optional
---

Markdown Format's Body

Publish

  • Run ink publish in the blog directory to automatically build and publish
  • Or run ink build to manually deploy generated public directory

Tips: When files changed, ink preview will automatically rebuild the blog. Refresh browser to update.

Customization

Modifying The Theme

The default theme is placed in the theme folder, run npm install and npm run build to rebuild in this folder.

page page.html (article list) and article.html (article), use variable with Golang Template syntax.

New Page

Created any .html file will be copied to source directory, could use all variables on site field in config.yml.

Define Custom Variables

InkPaper supports defining custom variables in pages, which must be placed under site.config in config.yaml, such as:

site:
    config:
        MyVar: "Hello World"

The variable can be referenced in the page by {{.Site.Config.MyVar}}.

Note

Although the field names in other parts of config.yaml are all lowercase, the name of the custom variable must be used correctly. Otherwises, such a variable:

site:
    config:
        MYVAR_aAa: "Hello World"

must be referenced in the page as {{.Site.Config.MYVAR_aAa}}.

Use Functions (Experimental)

InkPaper defines a minimal set of functions that can be used in HTML pages (except for .md source files), such as

{{ readFile "path/to/file" }}

This will read the content of the file path/to/file and include it in the page without any processing.

For file-related functions, when executed in the source directory, the file path is relative to the source directory; when executed in other directories, the file path is relative to the theme (such as theme).

See the source file funcs.go for a list of all functions.

Blog Migration (Beta)

Supports simple Jeklly/Hexo post convertions. Usage:

ink convert /path/_posts

Building from source

Local Build

  1. Install Golang environment
  2. Run git clone https://github.com/InkProject/ink && cd ink && go install to compile and install ink
  3. Run ink preview $GOPATH/src/github.com/InkProject/ink/template to preview blog

Docker Build (Example)

  1. Clone code git clone [email protected]:InkProject/ink.git
  2. Build image docker build -t ink . in source directory
  3. Run container docker run -p 8888:80 ink

Theme

Related Tutorials

License

CC Attribution-NonCommercial License 4.0

Reporting An Issue

https://github.com/InkProject/ink/issues

These blogs are driven by InkPaper

ink's People

Contributors

bronger avatar dependabot[bot] avatar dignissimus avatar dozen avatar dr4g0nsr avatar fofen avatar gnawux avatar hannesdejager avatar imeoer avatar lipengfeihb avatar shallowclouds avatar shery avatar sombriks avatar taadis avatar vorons avatar w568w 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ink's Issues

感觉不错,特意来感谢一下!

看了下感觉挺好的,官网挺好看的。

之前用 jekyll 做博客那个默认主题不好看,然后随便看了一下第三方的 jekyll 主题也不咋样。
感觉纸小墨不错。
话说官网 http://www.chole.io/ 能放一个 DEMO 吗?
就是搭建出来之后默认样式长什么样子。

谢谢。

How to contribute?

For example, i want to add one option in config.yaml and add one template in theme folder,
i have already modified parser.go 's SiteConfig and just can't let my template condition judgement work.
articel.html

{{template "moe" .}}

_moe.html

{{if .Site.Moe}}
balabala
{{end}}

config.yml

site:
    ...
    moe: true

parser.go

type SiteConfig struct {
	...
	Moe      bool

if i run ink preview, the console said

template: article:148:33: executing "moe" at <.Site.Moe>: can't evaluate field Moe in type main.SiteConfig

关于theme设置

因为每次更改主题都需要更改配置文件中的site中的theme字段和build中的copy段,如果主题较多,挑选主题的时候,每次需要一个一个改,会比较麻烦。
希望更换主题的时候只需要更改一处就好。
可以考虑把

copy:
    - theme/css
    - theme/js
    - theme/favicon.ico
    - theme/robots.txt

这段直接放到主题里面。

关于添加自定义配置字段的需求

情景

目前使用多说评论系统,模板中需使用一个key来对文章做唯一映射。目前使用.Date勉强可用。但不好维护。

需求

希望能够在article中添加一个可以user-define的字段。我便可以自定义一个字段来储存文章的多说评论的key

Footer content wont change when I edit about.me.html then rebuild?

Hi Folks,

I made the following change in the copyright section of the /source/about.me.html file then rebuilt the blog, but it's still showing the (c) symbol on the blog, despite the code looking like this in the /public/about.me.html file. Am I doing something wrong or is this an issue?

            <span class="copyright">
                {{.Site.Title}} <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">CC-BY 4.0</a> 
                <script type="text/javascript">
                    document.write(new Date().getFullYear());
                </script>
            </span>

[Feature Request] 添加统计逻辑

描述

时兴的博客框架都会支持各种诸如谷歌统计之类的服务,会提高框架的可用性,希望 ink 也可以实现一个。

关于RSS全文输出

试了下订阅,发现只能输出到预览,请问有办法全文输出么?

似乎没法使用Markdown的注释?

喂猫是English……算了不管了我就用中文写好了

嘛,举个例子:

*等身的作业* [^HW]

[^HW]: 引用自《纪念伏尔泰逝世一百周年的演说》

等身的作业 ^HW

Parsing Time Month Out of Range

When previewing or building blog with command of ./ink preview, the error of parsing time “2016-2-18 14:15:00 -0800”: month out of range appears.

screen shot 2016-02-20 at 15 07 36

The actual time written within the .md file
screen shot 2016-02-20 at 15 07 50

Could this happen because of the wrong time format I wrote?
I have tried with year of 2015 with month 2(February) but it still appears to have the same error of time month out of range.
screen shot 2016-02-20 at 15 19 27

Any year-month-day formatting, with month less than 10 does not work.
screen shot 2016-02-20 at 15 20 21

If the month value is greater than 10, for any year, there is no error.
Kind of confused by this strange problem but can’t really find any solution.
Much appreciated for helping.

Preview list page without any format conversion

Preview list page without any format conversion.
This may not be a bug,but this is not an graceful show,can you solve this problem to be optimized yet?
source code:

func ParseArticleConfig(markdownPath string) (config *ArticleConfig, content string) {
    ·······
    // Parse preview splited by MORE_SPLIT
    previewAry := strings.SplitN(content, MORE_SPLIT, 2)
    if len(config.Preview) <= 0 && len(previewAry) > 1 {
        config.Preview = previewAry[0]
        content = strings.Replace(content, MORE_SPLIT, "", 1)
    }
    return config, content
}

ink publish err

[root@weixin-6r7c4 blog]# ../ink publish
Building ink-blog-tool-en
Building ink-blog-tool
Copying source/images
Copying theme/bundle
Copying theme/favicon.png
Copying theme/robots.txt

Finished to build in public folder (12.534257ms)
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

如何在默认主题添加Instantclick啊?

我实验了好几次都不行,点击后无法加载正常网页。
这是我用的代码:
`<script src="//huangwuwen.firadio.net/ink/bundle/instantclick.min.js?v=3.1.0" data-no-instant></script>

<script data-no-instant>InstantClick.init();</script>`

install error

github.com/InkProject/ink/serve.go:73: web.Put undefined (type ink.Web has no field or method Put)
github.com/InkProject/ink/serve.go:74: web.Delete undefined (type ink.Web has no field or method Delete)

看看有没有这样的问题,我今天安装出现这个问题了 ^_^

Pages as markdown files

why cant pages also be added as markdown files to unify the process instead of html pages

improvement on copying files

希望能添加这样的功能:在article中增加copy配置字段,生成html时将对应文件复制至html的相同目录下。这样可以方便管理本地资源,提供一个可以在同一个article里面把资源跟markdown放一起的管理方法。

我现在的目录结构是这样的:blog/source/{year}/{month}/{article.name}/,每篇文章我会建立一个目录,然后把md和本地图片什么的都放到这个目录里面。

从 Jekyll 迁移的日期格式问题

post 的 metadata 这里,Jekyll 的 date 定义形式如 2015-04-12,没有时分秒字段,在使用 ink convert _post 迁移到 ink 后,无法渲染页面。报如下错误:

�[31;1mparsing time "2012-08-18" as "2006-01-02 15:04:05": cannot parse "" as "15"
[0m

手动添加时分秒字段如 22:17:16 可以解决问题,希望提供兼容功能。谢谢。:)

搜索功能

最近在移植主题到Ink,首页模板有{{template "search" .}}_search.html模板没修改过,但是还是不能搜索。
searchWorker.js 和 index.json 都正常,问题出现在哪里呢?

关于引用路径

由于目前生成的html中使用的引用全部都是绝对路径,导致页面只有在根目录下才能正常访问。执行替换"/"./后(暴力替换为相对路径)才可以部分正常访问。

问是否能将所有本地引用路径改为相对路径?

Disable disqus

我没有看到官方提供的关掉 disqus 的方法,如果注释掉的话会向 '.disqus.com' 发起个无用的请求并且被 503。

如果有跟我一样强迫症的朋友可以用注入方式解决 503 的问题

config.yml:
  ...
  disqus: '; return; '
  ...

关于inkpaper的3个问题请教

你好,猫叔,开发和维护辛苦了。我这里有3个关于inkpaper的问题想请教一下。

1、可以自己把评论换成多说吗?

2、作为静态博客,评论的数据是存储在哪里的呢?

3、是不是现在由markdown转成html,还不支持代码高亮呢?(我试了下Objective-C,似乎是还没有代码高亮)。还有是不是还不支持markdown的大纲功能呢?([TOC])

linux ink preview error

root@OpenWrt:/myblog/ink_linux_386# ./ink preview
./ink: line 1: syntax error: unexpected "("

关于替换评论插件

你好,猫叔。

关于替换评论插件的问题想咨询下你。

我发现在生成的文章html最后,都有这一段代码:

    <script type="text/javascript">
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//somebody.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>

要替换评论插件,是不是要删除所有文章html的这段代码呢?那么,我想咨询下:

  1. 生成这段代码的 go 文件在哪里呢?(在build.go里好像没有)。
  2. 如果我想用 多说 评论插件,是不是需要修改build代码,让程序自动在每个文章html加入调用这个插件的代码呢?
  3. 如果需要加入代码,那能否提示一下代码该怎么写呢?

(抱歉,问题比较小白。打扰了。)

support article category in Archive

Add category for each article and to group all articles by category instead of Year.

(also can anyone give me some advice so that I may implement this by myself. I'm currently reading relevant code and try to implement, but some advice may helps a lot.)

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.