mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
fix: a quick changelog fix (#7987)
This commit is contained in:
parent
a237b4e782
commit
fe06ddec5a
1 changed files with 18 additions and 23 deletions
|
|
@ -1,37 +1,32 @@
|
||||||
/// @ts-check
|
/// @ts-check
|
||||||
import fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import matter from 'gray-matter';
|
import { XMLParser } from 'fast-xml-parser';
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
const productUpdatesDirectory = path.join(
|
const feedUrl = 'https://the-guild.dev/graphql/hive/feed.xml';
|
||||||
__dirname,
|
const feed = await fetch(feedUrl).then(async res => {
|
||||||
'../packages/web/docs/src/app/product-updates',
|
if (res.status !== 200) {
|
||||||
);
|
console.log('skip feed building; feed is unavailable.');
|
||||||
|
return [];
|
||||||
const files = fs.globSync('**/*.mdx', { cwd: productUpdatesDirectory });
|
|
||||||
const changelogRecords = [];
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
if (!file.endsWith('.mdx') || file.endsWith('index.mdx')) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filePath = path.join(productUpdatesDirectory, file);
|
const parser = new XMLParser();
|
||||||
const content = fs.readFileSync(filePath, 'utf-8');
|
|
||||||
const { data } = matter(content);
|
|
||||||
|
|
||||||
if (data.title && data.date) {
|
const body = await res.text();
|
||||||
const pathname = file
|
const data = parser.parse(body);
|
||||||
.replace('.mdx', '')
|
return data['rss']?.['channel']?.['item'] ?? [];
|
||||||
.replace('(posts)/', '')
|
});
|
||||||
.replace(/\/page$/, '');
|
|
||||||
|
|
||||||
|
const changelogRecords = [];
|
||||||
|
|
||||||
|
for (const data of feed) {
|
||||||
|
if (data.title && data.pubDate && data.link) {
|
||||||
changelogRecords.push({
|
changelogRecords.push({
|
||||||
date: new Date(data.date).toISOString().split('T')[0],
|
date: new Date(data.pubDate).toISOString().split('T')[0],
|
||||||
href: `https://the-guild.dev/graphql/hive/product-updates/${pathname}`,
|
href: data.link,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
description: data.description || '',
|
description: data.description || '',
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue