notion2hugo

package module
v0.0.0-...-80d4578 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 9 Imported by: 0

README

notion2hugo

Convert Notion pages to Hugo-style Markdown

You can build your own blog like notion-blog, but with a static site generator Hugo.

Install

go get github.com/km2/notion2hugo

Usage

package main

import (
    "os"

    "github.com/kjk/notionapi"
    "github.com/km2/notion2hugo"
)

func main() {
    client := &notionapi.Client{}
    pageID := os.Getenv("NOTION_PAGE_ID")

    page, err := client.DownloadPage(pageID)
    if err != nil {
        panic(err)
    }

    converter := notion2hugo.NewConverter(client, page).
        PostDir("content/posts").
        StaticDir("static")

    if err := converter.ToMarkdown(); err != nil {
        panic(err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

type Converter struct {
	*tomarkdown.Converter
	// contains filtered or unexported fields
}

func NewConverter

func NewConverter(client *notionapi.Client, page *notionapi.Page) *Converter

NewConverter returns a converter for a Notion page.

func (*Converter) BlockRenderFunc

func (c *Converter) BlockRenderFunc(b *notionapi.Block) bool

func (*Converter) FrontMatterConverter

func (c *Converter) FrontMatterConverter(converter *frontmatter.Converter) *Converter

func (*Converter) PostDir

func (c *Converter) PostDir(path string) *Converter

func (*Converter) RenderImage

func (c *Converter) RenderImage(b *notionapi.Block)

func (*Converter) RenderPage

func (c *Converter) RenderPage(b *notionapi.Block)

func (*Converter) StaticDir

func (c *Converter) StaticDir(path string) *Converter

func (*Converter) ToMarkdown

func (c *Converter) ToMarkdown() error

func (*Converter) ToMarkdownWithFrontMatter

func (c *Converter) ToMarkdownWithFrontMatter(columns [][]*notionapi.TextSpan, format frontmatter.Format) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL