18679d9473 | ||
---|---|---|
LICENSE | ||
README.md | ||
feed_generator.php |
README.md
xml-feed-generator
an RSS/atom feed generator for my personal site 🐱 tested to work with PHP version 8.2.
how it works
- match files in a specificied directory.
- load the DOM of each file.
- parse the following elements as children of
<entry>
, in order of priority:
original HTML | feed output |
---|---|
1. class="p-name" |
<title> |
2. <title> in <head> |
|
3. the XML feed title | |
1. datetime attribute of class=dt-updated |
<updated> |
2. datetime attribute of the first <time> element |
|
3. file modification date, retrieved from the server | |
1. datetime attribute of class=dt-published |
<published> |
2. datetime attribute of the first <time> element |
|
3. file creation date, retrieved from the server | |
1. class="p-summary" |
<summary> |
2. <meta property="description"> |
|
1. class="e-content" |
<content> |
2. <article> |
|
1. /path/to/blog/entry | <id> and <link rel="alternate"> |
- output all of the above into a new file named articles.xml (default name, but can be changed).
ways to use
- configure a cron job on your web server to run automatically every now and then.
- if you manage your site with cPanel, here's how to do that.
or
- run the script locally on your machine.
- you can open the file on a local server like five server for vscode or XAMPP.
example output
feel free to check out the resulting file that i've generated.