Skip to content

Commit

Permalink
pref:remove shortcodes to another repository,fix markdown table row
Browse files Browse the repository at this point in the history
  • Loading branch information
nonacosa committed Jan 2, 2023
1 parent 6f3a126 commit deb1104
Show file tree
Hide file tree
Showing 31 changed files with 26 additions and 31,079 deletions.
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var rootCmd = &cobra.Command{
}
api := pkg.NewAPI()
files := pkg.NewFiles(config)
files.CopyShortCodes(config.HomePath)
tm := pkg.New()
caches := pkg.NewNotionCaches()
ns := pkg.NewNotionSite(api, tm, files, config, caches)
Expand Down
30 changes: 15 additions & 15 deletions notion-site.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
notion:
databaseId: 2bd00e5dfff3449ba81e0142f8af9bbb
filterProp: Status
filterValue:
- Finished
- Published
- RePublish
publishedValue: Published
markdown:
homePath: ../notion-site-doc


#blog
#notion:
# databaseId: df7fb0e4e0114268b973f9d3e9a39982
# databaseId: 2bd00e5dfff3449ba81e0142f8af9bbb
# filterProp: Status
# filterValue:
# - Finished
# - Published
# - RePublish
# publishedValue: Published
#markdown:
# homePath: ../notion-hugo-website-builder
# homePath: ../notion-site-doc


#blog
notion:
databaseId: df7fb0e4e0114268b973f9d3e9a39982
filterProp: Status
filterValue:
- Finished
- Published
- RePublish
publishedValue: Published
markdown:
homePath: ../notion-hugo-website-builder
17 changes: 0 additions & 17 deletions pkg/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,6 @@ func (files *Files) saveTo(reader io.Reader, rawURL, distDir string) (string, er
return filename, err
}

func (files *Files) CopyShortCodes(home string) {
src := filepath.Join("pkg", "shortcodes")
dst := filepath.Join(home, "layouts", "shortcodes")
err := os.RemoveAll(dst)
if err != nil {
fmt.Errorf("couldn't del folder: %s", err)
}
files.copyDir(src, dst)
src = filepath.Join("pkg", "shortcodes", "static")
dst = filepath.Join(home, "static", "notion-site")
err = os.RemoveAll(dst)
if err != nil {
fmt.Errorf("couldn't del folder: %s", err)
}
files.copyDir(src, dst)
}

func (files *Files) copyDir(src, dst string) error {
_, err := os.Stat(src)
if err != nil {
Expand Down
30 changes: 10 additions & 20 deletions pkg/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (tm *ToMarkdown) GenContentBlocks(blocks []notion.Block, depth int) error {
}

// todo configurable
if tm.ContentBuffer.Len() > 60 && !hasMoreTag {
if tm.ContentBuffer.Len() > 60 && !hasMoreTag && !tm.NotionProps.IsSettingFile {
addMoreTag = tm.ContentBuffer.Len() > 60
hasMoreTag = true
}
Expand Down Expand Up @@ -373,38 +373,28 @@ func ConvertTable(rows []notion.Block) string {
if len(rows) == 0 {
return ""
}
var head = ""
l := len((rows[0]).(*notion.TableRowBlock).Cells)
for i := 0; i < l; i++ {
head += "| "
if i == l-1 {
head += "|\n"
}
}
for i := 0; i < l; i++ {
head += "| - "
if i == l-1 {
head += "|\n"
}
}
buf.WriteString(head)
for _, row := range rows {
for i, row := range rows {
rowBlock := row.(*notion.TableRowBlock)
buf.WriteString(ConvertRow(rowBlock))
if i == 1 {
buf.WriteString(ConvertRow(rowBlock, "---"))
}
buf.WriteString(ConvertRow(rowBlock, ""))
}

return buf.String()
}

func ConvertRow(r *notion.TableRowBlock) string {
func ConvertRow(r *notion.TableRowBlock, fmt string) string {
var rowMd = ""
for i, cell := range r.Cells {
if i == 0 {
rowMd += "|"
}
for _, rich := range cell {
a := ConvertRich(rich)
print(a)
if fmt != "" {
a = fmt
}
rowMd += " " + a + " |"

}
Expand Down
6 changes: 0 additions & 6 deletions pkg/shortcodes/audio.html

This file was deleted.

24 changes: 0 additions & 24 deletions pkg/shortcodes/bilibili.html

This file was deleted.

22 changes: 0 additions & 22 deletions pkg/shortcodes/bookmark.html

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/shortcodes/callout.html

This file was deleted.

Loading

0 comments on commit deb1104

Please sign in to comment.