Skip to content

Commit deb1104

Browse files
committed
pref:remove shortcodes to another repository,fix markdown table row
1 parent 6f3a126 commit deb1104

31 files changed

Lines changed: 26 additions & 31079 deletions

‎cmd/root.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var rootCmd = &cobra.Command{
2525
}
2626
api := pkg.NewAPI()
2727
files := pkg.NewFiles(config)
28-
files.CopyShortCodes(config.HomePath)
2928
tm := pkg.New()
3029
caches := pkg.NewNotionCaches()
3130
ns := pkg.NewNotionSite(api, tm, files, config, caches)

‎notion-site.yaml‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
notion:
2-
databaseId: 2bd00e5dfff3449ba81e0142f8af9bbb
3-
filterProp: Status
4-
filterValue:
5-
- Finished
6-
- Published
7-
- RePublish
8-
publishedValue: Published
9-
markdown:
10-
homePath: ../notion-site-doc
11-
12-
13-
#blog
141
#notion:
15-
# databaseId: df7fb0e4e0114268b973f9d3e9a39982
2+
# databaseId: 2bd00e5dfff3449ba81e0142f8af9bbb
163
# filterProp: Status
174
# filterValue:
185
# - Finished
196
# - Published
207
# - RePublish
218
# publishedValue: Published
229
#markdown:
23-
# homePath: ../notion-hugo-website-builder
10+
# homePath: ../notion-site-doc
11+
12+
13+
#blog
14+
notion:
15+
databaseId: df7fb0e4e0114268b973f9d3e9a39982
16+
filterProp: Status
17+
filterValue:
18+
- Finished
19+
- Published
20+
- RePublish
21+
publishedValue: Published
22+
markdown:
23+
homePath: ../notion-hugo-website-builder

‎pkg/file.go‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,6 @@ func (files *Files) saveTo(reader io.Reader, rawURL, distDir string) (string, er
224224
return filename, err
225225
}
226226

227-
func (files *Files) CopyShortCodes(home string) {
228-
src := filepath.Join("pkg", "shortcodes")
229-
dst := filepath.Join(home, "layouts", "shortcodes")
230-
err := os.RemoveAll(dst)
231-
if err != nil {
232-
fmt.Errorf("couldn't del folder: %s", err)
233-
}
234-
files.copyDir(src, dst)
235-
src = filepath.Join("pkg", "shortcodes", "static")
236-
dst = filepath.Join(home, "static", "notion-site")
237-
err = os.RemoveAll(dst)
238-
if err != nil {
239-
fmt.Errorf("couldn't del folder: %s", err)
240-
}
241-
files.copyDir(src, dst)
242-
}
243-
244227
func (files *Files) copyDir(src, dst string) error {
245228
_, err := os.Stat(src)
246229
if err != nil {

‎pkg/markdown.go‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (tm *ToMarkdown) GenContentBlocks(blocks []notion.Block, depth int) error {
247247
}
248248

249249
// todo configurable
250-
if tm.ContentBuffer.Len() > 60 && !hasMoreTag {
250+
if tm.ContentBuffer.Len() > 60 && !hasMoreTag && !tm.NotionProps.IsSettingFile {
251251
addMoreTag = tm.ContentBuffer.Len() > 60
252252
hasMoreTag = true
253253
}
@@ -373,38 +373,28 @@ func ConvertTable(rows []notion.Block) string {
373373
if len(rows) == 0 {
374374
return ""
375375
}
376-
var head = ""
377-
l := len((rows[0]).(*notion.TableRowBlock).Cells)
378-
for i := 0; i < l; i++ {
379-
head += "| "
380-
if i == l-1 {
381-
head += "|\n"
382-
}
383-
}
384-
for i := 0; i < l; i++ {
385-
head += "| - "
386-
if i == l-1 {
387-
head += "|\n"
388-
}
389-
}
390-
buf.WriteString(head)
391-
for _, row := range rows {
376+
for i, row := range rows {
392377
rowBlock := row.(*notion.TableRowBlock)
393-
buf.WriteString(ConvertRow(rowBlock))
378+
if i == 1 {
379+
buf.WriteString(ConvertRow(rowBlock, "---"))
380+
}
381+
buf.WriteString(ConvertRow(rowBlock, ""))
394382
}
395383

396384
return buf.String()
397385
}
398386

399-
func ConvertRow(r *notion.TableRowBlock) string {
387+
func ConvertRow(r *notion.TableRowBlock, fmt string) string {
400388
var rowMd = ""
401389
for i, cell := range r.Cells {
402390
if i == 0 {
403391
rowMd += "|"
404392
}
405393
for _, rich := range cell {
406394
a := ConvertRich(rich)
407-
print(a)
395+
if fmt != "" {
396+
a = fmt
397+
}
408398
rowMd += " " + a + " |"
409399

410400
}

‎pkg/shortcodes/audio.html‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎pkg/shortcodes/bilibili.html‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎pkg/shortcodes/bookmark.html‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎pkg/shortcodes/callout.html‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)