pkg

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagsProp     = "Tags"
	PositionProp = "Position"
)
View Source
const Bilibili = "bilibili.com"
View Source
const Gist = "gist.github.com"
View Source
const Jsfiddle = "jsfiddle.net"
View Source
const RegexBili = `((?<=\.com\/video\/).*(?=\/))|((?<=bvid=).*(?=&cid?))`
View Source
const RegexJsfiddle = `(?<=jsfiddle\.net\/).*(?=\/)`
View Source
const RegexTwitterId = `(?<=status\/).*(?=\?)`
View Source
const RegexTwitterUser = `(?<=com\/).*(?=\/status)`
View Source
const RegexYoutube = `(?<=\.com\/watch\?v=).*`
View Source
const Twitter = "twitter.com"

Variables

View Source
var ColorMap = map[string]string{
	"gray":              grayColor,
	"brown":             brownColor,
	"orange":            orangeColor,
	"yellow":            yellowColor,
	"green":             greenColor,
	"blue":              blueColor,
	"purple":            purpleColor,
	"pink":              pinkColor,
	"red":               redColor,
	"gray_background":   grayBackground,
	"brown_background":  brownBackground,
	"orange_background": orangeBackground,
	"yellow_background": yellowBackground,
	"green_background":  greenBackground,
	"blue_background":   blueBackground,
	"purple_background": purpleBackground,
	"pink_background":   pinkBackground,
	"red_background":    redBackground,
}

Functions

func CamelCaseToUnderscore added in v1.0.6

func CamelCaseToUnderscore(s string) string

func ConvertRich added in v1.1.0

func ConvertRich(t notion.RichText) string

func ConvertRichText added in v1.1.0

func ConvertRichText(t []notion.RichText) string

func ConvertRow added in v1.1.0

func ConvertRow(r *notion.TableRowBlock, fmt string) string

func ConvertTable added in v1.1.0

func ConvertTable(rows []notion.Block) string

func DefaultConfigInit added in v1.1.0

func DefaultConfigInit() error

func FindTextP

func FindTextP(ori string, pre string) string

func FindUrlContext added in v1.0.6

func FindUrlContext(regex string, url string) string

func GetBlockType added in v1.0.6

func GetBlockType(block any) string

func Run added in v1.1.0

func Run(ns *NotionSite) error

Types

type Config added in v1.1.0

type Config struct {
	Notion   `yaml:"notion"`
	Markdown `yaml:"markdown"`
}

type Files added in v1.1.0

type Files struct {
	Permission               uint32
	MediaPath                string
	Position                 string
	FileName                 string
	FileFolderPath           string
	FilePath                 string
	HomePath                 string
	DefaultMarkdownName      string
	DefaultMediaFolderName   string
	DefaultgalleryFolderName string

	CurrentNTPL string
	// contains filtered or unexported fields
}

func NewFiles added in v1.1.0

func NewFiles(config Config) (files *Files)

func (*Files) DownloadMedia added in v1.1.0

func (files *Files) DownloadMedia(dynamicMedia any) error

type FrontMatter added in v1.1.0

type FrontMatter struct {
	Title        interface{}   `yaml:",flow"`
	Status       interface{}   `yaml:",flow"`
	Position     interface{}   `yaml:",flow"`
	Categories   []interface{} `yaml:",flow"`
	Tags         []interface{} `yaml:",flow"`
	Keywords     []interface{} `yaml:",flow"`
	CreateAt     interface{}   `yaml:",flow"`
	Author       interface{}   `yaml:",flow"`
	IsTranslated interface{}   `yaml:",flow"`
	Lastmod      interface{}   `yaml:",flow"`
	Description  interface{}   `yaml:",flow"`
	Draft        interface{}   `yaml:",flow"`
	ExpiryDate   interface{}   `yaml:",flow"`
	//PublishDate   interface{}   `yaml:",flow"`
	Show_comments interface{} `yaml:",flow"`
	//Calculate Chinese word count accurately. Default is true
	//IsCJKLanguage interface{} `yaml:",flow"`
	Slug   interface{} `yaml:",flow"`
	Image  interface{} `yaml:",flow"`
	Weight interface{} `yaml:",flow"`
}

type Markdown added in v1.1.0

type Markdown struct {
	HomePath        string `yaml:"homePath"`
	ImagePublicLink string `yaml:"imagePublicLink"`

	// Optional:
	GroupByMonth bool   `yaml:"groupByMonth,omitempty"`
	Template     string `yaml:"template,omitempty"`
}

type MdBlock added in v1.1.0

type MdBlock struct {
	notion.Block

	Depth int
	Extra map[string]interface{}
	// contains filtered or unexported fields
}

type MediaBlock added in v1.1.0

type MediaBlock struct {
	notion.ImageBlock
	notion.VideoBlock
	notion.PDFBlock
	notion.AudioBlock
	notion.FileBlock
}

type Notion added in v1.1.0

type Notion struct {
	DatabaseID     string   `yaml:"databaseId"`
	FilterProp     string   `yaml:"filterProp"`
	FilterValue    []string `yaml:"filterValue"`
	PublishedValue string   `yaml:"publishedValue"`
}

type NotionAPI added in v1.1.0

type NotionAPI struct {
	Client *notion.Client
}

func NewAPI added in v1.1.0

func NewAPI() *NotionAPI

func (*NotionAPI) CheckHasChildDataBase added in v1.1.0

func (api *NotionAPI) CheckHasChildDataBase(blocks []notion.Block, cb func(bool, string)) bool

func (*NotionAPI) FindBlockChildrenCommentLoop added in v1.1.0

func (api *NotionAPI) FindBlockChildrenCommentLoop(client *notion.Client, blockArr []notion.Block, cursor string) (blocks []notion.Comment, err error)

type NotionCache added in v1.1.0

type NotionCache struct {
	ParentPropInfo  *NotionProp
	ParentFilesInfo *Files
	ChildDatabaseId string
}

func NewNotionCaches added in v1.1.0

func NewNotionCaches() []*NotionCache

type NotionCaches added in v1.1.0

type NotionCaches struct {
	TODO []*NotionCache
}

func (*NotionCaches) SetCache added in v1.1.0

func (caches *NotionCaches) SetCache(blockId string)

type NotionProp added in v1.1.0

type NotionProp struct {
	Name             string
	Title            string
	Status           string
	Categories       []string
	Tags             []string
	Position         string
	FileName         string
	Description      string
	CreateAt         *time.Time
	Author           string
	LastMod          time.Time
	ExpiryDate       time.Time
	PublishDate      time.Time
	ShowComments     *bool
	Slug             string
	Types            string
	IsSettingFile    bool
	IsCustomNameFile bool
}

func NewNotionProp added in v1.1.0

func NewNotionProp(page notion.Page) (np *NotionProp)

func (*NotionProp) GetFileName added in v1.1.0

func (np *NotionProp) GetFileName() string

func (*NotionProp) GetTitle added in v1.1.0

func (np *NotionProp) GetTitle() (title string)

func (*NotionProp) IsCustomNameMdFile added in v1.1.0

func (np *NotionProp) IsCustomNameMdFile() bool

IsCustomNameMdFile no setting type but has custom file name

func (*NotionProp) IsFolder added in v1.1.0

func (np *NotionProp) IsFolder() bool

func (*NotionProp) IsSetting added in v1.1.0

func (np *NotionProp) IsSetting() bool

type NotionSite added in v1.1.0

type NotionSite struct {
	// contains filtered or unexported fields
}

func NewNotionSite added in v1.1.0

func NewNotionSite(api *NotionAPI, tm *ToMarkdown, files *Files, config Config, caches []*NotionCache) *NotionSite

func (*NotionSite) SetFileInfo added in v1.1.0

func (ns *NotionSite) SetFileInfo(position string)

type ToMarkdown added in v1.1.0

type ToMarkdown struct {
	NotionProps       *NotionProp
	Files             *Files
	FrontMatter       map[string]interface{}
	ContentBuffer     *bytes.Buffer
	ImgSavePath       string
	ImgVisitPath      string
	ArticleFolderPath string
	ContentTemplate   string
	// contains filtered or unexported fields
}

func New added in v1.1.0

func New() *ToMarkdown

func (*ToMarkdown) EnableExtendedSyntax added in v1.1.0

func (tm *ToMarkdown) EnableExtendedSyntax(target string)

func (*ToMarkdown) ExtendedSyntaxEnabled added in v1.1.0

func (tm *ToMarkdown) ExtendedSyntaxEnabled() bool

func (*ToMarkdown) GenBlock added in v1.1.0

func (tm *ToMarkdown) GenBlock(bType string, block MdBlock, addMoreTag bool, skip bool) error

GenBlock notion to hugo shortcodes template

func (*ToMarkdown) GenContentBlocks added in v1.1.0

func (tm *ToMarkdown) GenContentBlocks(blocks []notion.Block, depth int) error

func (*ToMarkdown) GenFrontMatter added in v1.1.0

func (tm *ToMarkdown) GenFrontMatter(writer io.Writer) error

func (*ToMarkdown) GenerateTo added in v1.1.0

func (tm *ToMarkdown) GenerateTo(ns *NotionSite) error

func (*ToMarkdown) WithFrontMatter added in v1.1.0

func (tm *ToMarkdown) WithFrontMatter(page notion.Page)

Jump to

Keyboard shortcuts

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