diff --git a/rss/generate-rss.js b/rss/generate-rss.js index ab24789..eae4748 100644 --- a/rss/generate-rss.js +++ b/rss/generate-rss.js @@ -1,5 +1,6 @@ const fs = require('fs'); const RSS = require('rss'); +const axios = require('axios'); // Read index.json const index = JSON.parse(fs.readFileSync('content/index.json', 'utf8')); @@ -19,13 +20,19 @@ const feed = new RSS({ // Loop over the articles in the index and add them to the feed for (const articleId in index) { const article = index[articleId]; + + const response = await axios.get("blog.drewery.uk/raw/" + articleId); + feed.item({ title: article.title, description: 'You can add a description here', url: `https://yourwebsite.com/${articleId}`, // URL of the article date: article.date, + + // Add the article content as HTML + content: response.data }); } // Write the XML to a file -fs.writeFileSync('rss.xml', feed.xml()); +fs.writeFileSync('rss.xml', feed.xml()); \ No newline at end of file diff --git a/rss/package.json b/rss/package.json index 7db3fad..ecb568b 100644 --- a/rss/package.json +++ b/rss/package.json @@ -9,6 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "rss": "^1.2.2" + "rss": "^1.2.2", + "axios": "^0.21.1" } -} +} \ No newline at end of file diff --git a/site/Pages/Raw.razor b/site/Pages/Raw.razor new file mode 100644 index 0000000..c4b8673 --- /dev/null +++ b/site/Pages/Raw.razor @@ -0,0 +1,39 @@ +@layout EmptyLayout +@inject HttpClient Http +@inject IJSRuntime JsRuntime +@page "/raw/{Id}" +@using Markdig + +@code { + [Parameter] + public string? Id { get; set; } + + string? _content; + + protected override async Task OnParametersSetAsync() + { + var markdown = await Http.GetStringAsync($"https://raw.githubusercontent.com/adam-drewery/blog/main/content/{Id}.md") + ?? throw new InvalidOperationException("Failed to get blog content"); + + _content = Markdown.ToHtml(markdown); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await JsRuntime.InvokeVoidAsync("fitImages"); + await JsRuntime.InvokeVoidAsync("highlightCode"); + } +} + +
+
+
+
+
+ @if (_content != null) { @((MarkupString)_content) } +
+
+
+
+
+
\ No newline at end of file diff --git a/site/Shared/EmptyLayout.razor b/site/Shared/EmptyLayout.razor new file mode 100644 index 0000000..57d84b2 --- /dev/null +++ b/site/Shared/EmptyLayout.razor @@ -0,0 +1,2 @@ +@inherits LayoutComponentBase +@Body \ No newline at end of file