.. leading zeros are required for `frontmatter` to treat them as dates
rather than strings, apparently per the YAML specification.
This was done by script:
```py
import re
import datetime
import pathlib
import sys
import frontmatter
rx = re.compile(r'^(\s*)date_added:.*$', re.M)
for path_str in sys.argv[1:]:
print(path_str)
path = pathlib.Path(path_str)
post = frontmatter.load(path)
date_added = post.get("date_added", "")
if isinstance(date_added, datetime.date):
continue
if isinstance(date_added, str):
try:
date_added = datetime.datetime.strptime(date_added, "%Y-%m-%d")
except ValueError as exc:
print(f"Failed to parse date {date_added} in {path_str}: {exc}")
continue
date_added = date_added.date()
content = path.read_text("utf-8")
new_content = rx.sub(lambda m: f"{m.group(1)}date_added: {date_added}", content)
assert content != new_content
path.write_text(new_content, "utf-8")
```
27 lines
836 B
Markdown
27 lines
836 B
Markdown
---
|
|
layout: download
|
|
board_id: "beaglebone"
|
|
title: "BeagleBone Download"
|
|
name: "BeagleBone"
|
|
manufacturer: "BeagleBoard"
|
|
board_url:
|
|
- "https://beagleboard.org/bone-original"
|
|
board_image: "beaglebone.jpg"
|
|
download_instructions: ""
|
|
downloads_display: true
|
|
blinka: true
|
|
date_added: 2021-04-06
|
|
features:
|
|
- Ethernet
|
|
---
|
|
|
|
BeagleBone is an $89 MSRP, credit-card-sized Linux computer that connects to the Internet and runs software such as Android 4.0 and Ubuntu. With plenty of I/O and processing power for real-time analysis provided by an AM335x 720MHz ARM® processor, BeagleBone can be complemented with cape plug-in boards to augment functionality.
|
|
|
|
- 256MB DDR2 RAM
|
|
- 3D graphics accelerator
|
|
- ARM Cortex-M3 for power management
|
|
- 2x PRU 32-bit RISC CPUs
|
|
- USB client: power, debug and device
|
|
- USB host
|
|
- Ethernet
|
|
- 2x 46 pin headers
|