typography style updates; sort rss by publish date
This commit is contained in:
@@ -6,6 +6,7 @@ import { write_text } from '../fs';
|
||||
import { AuthorConfig, app_version } from '../conf';
|
||||
import { map_output_file_to_url } from './helpers';
|
||||
import { DateTime } from 'luxon';
|
||||
import { FileMetadata } from '../metadata';
|
||||
|
||||
export interface RSSEntry {
|
||||
url: string;
|
||||
@@ -84,11 +85,21 @@ export async function write_rss_if_needed(state: BuildState) {
|
||||
// channel.ele('image').txt('');
|
||||
// channel.ele('skipHours').txt('');
|
||||
// channel.ele('skipDays').txt('');
|
||||
|
||||
let entries: (RSSEntry & { metadata: FileMetadata, first_seen: number })[] = [ ];
|
||||
|
||||
for (const entry of state.rss[index] || [ ]) {
|
||||
const item = channel.ele('item');
|
||||
const in_file = entry.in_file.slice(state.conf.input.root.length);
|
||||
const metadata = state.new_metadata.files[in_file];
|
||||
entries.push({ ...entry, metadata, first_seen: DateTime.fromISO(metadata.first_seen_time).toUnixInteger() });
|
||||
}
|
||||
|
||||
entries = entries.sort((a, b) => {
|
||||
return b.first_seen - a.first_seen;
|
||||
});
|
||||
|
||||
for (const entry of entries) {
|
||||
const item = channel.ele('item');
|
||||
|
||||
item.ele('link').txt(entry.url);
|
||||
|
||||
@@ -111,7 +122,7 @@ export async function write_rss_if_needed(state: BuildState) {
|
||||
}
|
||||
|
||||
item.ele('guid').txt(entry.url);
|
||||
item.ele('pubDate').txt(DateTime.fromISO(metadata.first_seen_time).toRFC2822());
|
||||
item.ele('pubDate').txt(DateTime.fromISO(entry.metadata.first_seen_time).toRFC2822());
|
||||
|
||||
if (entry.html_content) {
|
||||
item.ele('content:encoded').ele({ $: entry.html_content });
|
||||
|
Reference in New Issue
Block a user