|
183 | 183 | "\n",
|
184 | 184 | "def _fp_convert(fm:dict, path:Path):\n",
|
185 | 185 | " \"Make fastpages frontmatter Quarto complaint and add redirects.\"\n",
|
| 186 | + " fs = _file_slug(path)\n", |
186 | 187 | " if _is_jekyll_post(path):\n",
|
187 | 188 | " fm = compose(_fp_fm, _fp_image)(fm)\n",
|
188 | 189 | " if 'permalink' in fm: fm['aliases'] = [f\"{fm['permalink'].strip()}\"]\n",
|
189 |
| - " else: fm['aliases'] = [f'{_cat_slug(fm) + _file_slug(path)}']\n", |
| 190 | + " else: fm['aliases'] = [f'{_cat_slug(fm) + fs}']\n", |
| 191 | + " if not fm.get('date'): \n", |
| 192 | + " _,y,m,d,_ = fs.split('/')\n", |
| 193 | + " fm['date'] = f'{y}-{m}-{d}'\n", |
190 | 194 | " \n",
|
| 195 | + " if fm.get('summary') and not fm.get('description'): fm['description'] = fm['summary']\n", |
| 196 | + " if fm.get('tags') and not fm.get('categories'): \n", |
| 197 | + " if isinstance(fm['tags'], str): fm['categories'] = fm['tags'].split()\n", |
| 198 | + " elif isinstance(fm['tags'], list): fm['categories'] = fm['tags']\n", |
191 | 199 | " for k in ['title', 'description']:\n",
|
192 | 200 | " if k in fm: fm[k] = _rm_quote(fm[k])\n",
|
193 | 201 | " if fm.get('comments'): fm.pop('comments') #true by itself is not a valid value for comments https://quarto.org/docs/output-formats/html-basics.html#commenting, and the default is true\n",
|
|
302 | 310 | "categories:\n",
|
303 | 311 | "- fastcore\n",
|
304 | 312 | "- fastai\n",
|
| 313 | + "date: '2020-09-01'\n", |
305 | 314 | "description: A unique python library that extends the python programming language\n",
|
306 | 315 | " and provides utilities that enhance productivity.\n",
|
307 | 316 | "draft: 'true'\n",
|
|
341 | 350 | "categories:\n",
|
342 | 351 | "- fastcore\n",
|
343 | 352 | "- fastai\n",
|
| 353 | + "date: '2020-09-01'\n", |
344 | 354 | "description: A unique python library that extends the python programming language\n",
|
345 | 355 | " and provides utilities that enhance productivity.\n",
|
346 | 356 | "draft: 'true'\n",
|
|
362 | 372 | "badges: true\n",
|
363 | 373 | "categories:\n",
|
364 | 374 | "- jupyter\n",
|
| 375 | + "date: '2020-02-20'\n", |
365 | 376 | "description: A tutorial of fastpages for Jupyter notebooks.\n",
|
366 | 377 | "image: images/chart-preview.png\n",
|
367 | 378 | "output-file: 2020-02-20-test.html\n",
|
|
466 | 477 | "- /markdown/2020/01/14/test-markdown-post\n",
|
467 | 478 | "categories:\n",
|
468 | 479 | "- markdown\n",
|
| 480 | + "date: '2020-01-14'\n", |
469 | 481 | "description: A minimal example of using markdown with fastpages.\n",
|
470 | 482 | "layout: post\n",
|
471 | 483 | "title: An Example Markdown Post\n",
|
|
477 | 489 | "\n",
|
478 | 490 | "## Basic setup\n",
|
479 | 491 | "\n",
|
480 |
| - "Jekyll requires blog post files to be named according t\n" |
| 492 | + "Jekyll requires blog post files to b\n" |
481 | 493 | ]
|
482 | 494 | }
|
483 | 495 | ],
|
|
499 | 511 | "- /markdown/2020/01/14/test-markdown-post\n",
|
500 | 512 | "categories:\n",
|
501 | 513 | "- markdown\n",
|
| 514 | + "date: '2020-01-14'\n", |
502 | 515 | "description: A minimal example of using markdown with fastpages.\n",
|
503 | 516 | "layout: post\n",
|
504 | 517 | "title: An Example Markdown Post\n",
|
|
518 | 531 | "source": [
|
519 | 532 | "#hide\n",
|
520 | 533 | "_res = fp_md_fm('../../tests/2022-09-06-homeschooling.md')\n",
|
521 |
| - "assert \"aliases:\\n- /2022/09/06/homeschooling\" in _res" |
| 534 | + "test_eq(_res,\n", |
| 535 | + "\"\"\"---\n", |
| 536 | + "aliases:\n", |
| 537 | + "- /2022/09/06/homeschooling\n", |
| 538 | + "author: Rachel Thomas\n", |
| 539 | + "categories:\n", |
| 540 | + "- advice\n", |
| 541 | + "- health\n", |
| 542 | + "date: '2022-09-06'\n", |
| 543 | + "description: You can permanently damage your back, neck, and wrists from working without\n", |
| 544 | + " an ergonomic setup. Learn how to create one for less at home.\n", |
| 545 | + "image: /images/ergonomic1-short.jpg\n", |
| 546 | + "summary: You can permanently damage your back, neck, and wrists from working without\n", |
| 547 | + " an ergonomic setup. Learn how to create one for less at home.\n", |
| 548 | + "tags: advice health\n", |
| 549 | + "title: 'Essential Work-From-Home Advice: Cheap and Easy Ergonomic Setups'\n", |
| 550 | + "\n", |
| 551 | + "---\n", |
| 552 | + "\n", |
| 553 | + "Lorem ipsum\n", |
| 554 | + "\"\"\")" |
522 | 555 | ]
|
523 | 556 | },
|
524 | 557 | {
|
|
636 | 669 | "text/markdown": [
|
637 | 670 | "---\n",
|
638 | 671 | "\n",
|
639 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L111){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 672 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L118){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
640 | 673 | "\n",
|
641 | 674 | "### _repl_v1dir\n",
|
642 | 675 | "\n",
|
|
647 | 680 | "text/plain": [
|
648 | 681 | "---\n",
|
649 | 682 | "\n",
|
650 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L111){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 683 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L118){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
651 | 684 | "\n",
|
652 | 685 | "### _repl_v1dir\n",
|
653 | 686 | "\n",
|
|
745 | 778 | "text/markdown": [
|
746 | 779 | "---\n",
|
747 | 780 | "\n",
|
748 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L123){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 781 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L130){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
749 | 782 | "\n",
|
750 | 783 | "### _convert_callout\n",
|
751 | 784 | "\n",
|
|
756 | 789 | "text/plain": [
|
757 | 790 | "---\n",
|
758 | 791 | "\n",
|
759 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L123){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 792 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L130){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
760 | 793 | "\n",
|
761 | 794 | "### _convert_callout\n",
|
762 | 795 | "\n",
|
|
889 | 922 | "text/markdown": [
|
890 | 923 | "---\n",
|
891 | 924 | "\n",
|
892 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L130){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 925 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L137){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
893 | 926 | "\n",
|
894 | 927 | "### _convert_video\n",
|
895 | 928 | "\n",
|
|
900 | 933 | "text/plain": [
|
901 | 934 | "---\n",
|
902 | 935 | "\n",
|
903 |
| - "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L130){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 936 | + "[source](https://github.com/fastai/nbdev/blob/master/nbdev/migrate.py#L137){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
904 | 937 | "\n",
|
905 | 938 | "### _convert_video\n",
|
906 | 939 | "\n",
|
|
1065 | 1098 | "- /markdown/2020/01/14/test-markdown-post-COPY\n",
|
1066 | 1099 | "categories:\n",
|
1067 | 1100 | "- markdown\n",
|
| 1101 | + "date: '2020-01-14'\n", |
1068 | 1102 | "description: A minimal example of using markdown with fastpages.\n",
|
1069 | 1103 | "layout: post\n",
|
1070 | 1104 | "title: An Example Markdown Post\n",
|
|
0 commit comments