Here's a brief overview of how the script works:
-
The script requires the csv, yaml, and redcarpet libraries, which will be used to read and write CSV files, extract YAML frontmatter, and parse markdown, respectively.
-
The script initializes the paths to the folder containing the markdown files and the CSV file that will be created.
-
The script opens the CSV file and adds headers for the three columns.
-
The script initializes a Redcarpet markdown parser.
-
The script uses the Dir.glob method to loop through each markdown file in the folder.
-
For each markdown file, the script reads the file contents and extracts the YAML frontmatter using a regular expression.
-
The script extracts the date and title from the frontmatter.
-
The script parses the markdown file into HTML using the Redcarpet parser.
-
The script uses another regular expression to extract all anchor HREF tags from the HTML.
-
The script loops through each URL and adds a new row to the CSV file with the date, title, and URL.
Note that this script assumes that all markdown files in the folder have YAML frontmatter with date and title fields. If your markdown files have different frontmatter or none at all, you'll need to modify the script accordingly.