diff --git a/app/feed/atom/route.ts b/app/feed/atom/route.ts new file mode 100644 index 0000000..b3cfd7d --- /dev/null +++ b/app/feed/atom/route.ts @@ -0,0 +1,12 @@ +import { buildFeed } from "utils/buildFeed"; + +export const revalidate = false; + +export async function GET() { + return new Response(buildFeed().atom1(), { + headers: { + "Content-Type": "application/atom+xml; charset=utf-8", + "Cache-Control": "public, max-age=3600", + }, + }); +} diff --git a/app/feed/json/route.ts b/app/feed/json/route.ts new file mode 100644 index 0000000..fa08718 --- /dev/null +++ b/app/feed/json/route.ts @@ -0,0 +1,12 @@ +import { buildFeed } from "utils/buildFeed"; + +export const revalidate = false; + +export async function GET() { + return new Response(buildFeed().json1(), { + headers: { + "Content-Type": "application/feed+json; charset=utf-8", + "Cache-Control": "public, max-age=3600", + }, + }); +} diff --git a/app/feed/rss/route.ts b/app/feed/rss/route.ts new file mode 100644 index 0000000..d19fb81 --- /dev/null +++ b/app/feed/rss/route.ts @@ -0,0 +1,12 @@ +import { buildFeed } from "utils/buildFeed"; + +export const revalidate = false; + +export async function GET() { + return new Response(buildFeed().rss2(), { + headers: { + "Content-Type": "application/rss+xml; charset=utf-8", + "Cache-Control": "public, max-age=3600", + }, + }); +} diff --git a/app/layout.tsx b/app/layout.tsx index e35bfbe..05dfba3 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -7,6 +7,11 @@ import './globals.css' const Layout = ({ children }: any) => ( + + + + + @@ -34,12 +39,7 @@ const Layout = ({ children }: any) => ( }, 'divider', { - link: 'https://git.chora.studio/explore/repos', - title: 'git', - target: '_blank', - }, - { - link: '/research/feed', + link: '/feed/rss', title: 'rss', target: '_blank', }, @@ -69,14 +69,19 @@ const Layout = ({ children }: any) => ( target: '', title: 'services', }, + { + link: '/feed/rss', + title: 'rss', + target: '_blank', + }, { link: 'https://git.chora.studio/explore/repos', title: 'git', target: '_blank', }, { - link: '/research/feed', - title: 'rss', + link: '/key.asc', + title: 'pgp', target: '_blank', }, ]} @@ -118,16 +123,22 @@ const Layout = ({ children }: any) => ( { title: 'more links', items: [ + { + link: '/feed/rss', + title: 'rss', + target: '_blank', + }, { link: 'https://git.chora.studio/explore/repos', title: 'git', target: '_blank', }, { - link: '/research/feed', - title: 'rss', + link: '/key.asc', + title: 'pgp', target: '_blank', - },], + }, + ], }, ]} /> diff --git a/app/research/feed/route.ts b/app/research/feed/route.ts deleted file mode 100644 index e16d2a3..0000000 --- a/app/research/feed/route.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Feed } from "feed"; -import { getArtifacts } from "utils"; - -const SITE_URL = "https://chora.studio/research"; - -function getAllArtifacts() { - return [ - ...getArtifacts('about'), - ...getArtifacts('concepts'), - ...getArtifacts('tutorials'), - ] -} - -export const revalidate = false; - -export async function GET() { - const feed = new Feed({ - title: "chora research", - description: "chora research", - id: SITE_URL, - link: SITE_URL, - language: "en", - feedLinks: { rss2: `${SITE_URL}/feed` }, - ttl: 60, - }); - - for (const a of getAllArtifacts()) { - feed.addItem({ - title: a.title, - id: `${SITE_URL}/${a.category}/${a.id}`, - link: `${SITE_URL}/${a.category}/${a.id}`, - description: a.description, - date: a.created, - }); - } - - return new Response(feed.rss2(), { - headers: { - "Content-Type": "application/rss+xml; charset=utf-8", - "Cache-Control": "public, max-age=3600", - }, - }); -} diff --git a/public/key.asc b/public/key.asc new file mode 100644 index 0000000..cb586f7 --- /dev/null +++ b/public/key.asc @@ -0,0 +1,13 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEav+VlBYJKwYBBAHaRw8BAQdA70d670oZGo4AvlCqbxqgM+0u4TPJa3XkfBqV +QkDuFEW0I2Nob3JhIHN0dWRpbyA8Y29udGFjdEBjaG9yYS5zdHVkaW8+iJAEExYK +ADgWIQRWiSpiiJynA0ZwpKdgblby/xqZeAUCav+VlAIbAwULCQgHAgYVCgkICwIE +FgIDAQIeAQIXgAAKCRBgblby/xqZeF0CAQC/UbB5EVdmj28tvQ4uJ+k0G0+iAFPJ +AFtecs9w+yRjDAEA9OkUyZOhKGbiBlX6sBBNH6e6zo+oM4kNAKCftblVxwW4OARq +/5WUEgorBgEEAZdVAQUBAQdA+t+sKdDzPUAwaKVlwQw12YScO2XVQSHrkkXvO3m2 +UFMDAQgHiHgEGBYKACAWIQRWiSpiiJynA0ZwpKdgblby/xqZeAUCav+VlAIbDAAK +CRBgblby/xqZeA7EAP9BfLf95kq8V1a8AclicIwHc4+boTeFSjU9UhgoNXXSqgD9 +FXv374OXscR4azTXMni31bwMcpfpokUqQ093ix79DAk= +=a/sf +-----END PGP PUBLIC KEY BLOCK----- diff --git a/utils/buildFeed.ts b/utils/buildFeed.ts new file mode 100644 index 0000000..ab507d5 --- /dev/null +++ b/utils/buildFeed.ts @@ -0,0 +1,51 @@ +import { Feed } from "feed"; +import { getArtifacts } from "utils"; + +// const SITE_URL = "http://localhost:3000"; +const SITE_URL = "https://chora.studio"; + +function getAllArtifacts() { + return [ + // ...getArtifacts('about'), + ...getArtifacts('concepts'), + // ...getArtifacts('tutorials'), + ] +} + +export function buildFeed() { + const feed = new Feed({ + title: "Chora Studio's Feed", + description: "Chora Studio's Feed", + id: SITE_URL, + link: SITE_URL, + language: "en", + favicon: `${SITE_URL}/favicon.ico`, + feedLinks: { + atom: `${SITE_URL}/feed/atom`, + json: `${SITE_URL}/feed/json`, + rss2: `${SITE_URL}/feed/rss`, + }, + author: { name: "Chora Studio" }, + copyright: "Creative Commons", + ttl: 60, + }); + + for (const a of getAllArtifacts()) { + feed.addItem({ + title: a.title, + id: `${SITE_URL}/${a.category}/${a.id}`, + link: `${SITE_URL}/${a.category}/${a.id}`, + description: a.description, + date: a.updated, + published: a.created, + author: [{ name: a.author }], + category: [{ name: a.category }], + // content: a.content, + // audio: a.audio, + // video: a.video, + copyright: "Creative Commons", + }); + } + + return feed; +}