added rss feeds

This commit is contained in:
Nico 2023-05-09 12:26:03 +02:00
parent b602b45c05
commit 3d00b4d3cb
36 changed files with 127 additions and 3 deletions

View File

@ -11,9 +11,11 @@ declare module "astro-i18n" {
export function l<Uri extends RouteUri>(
route: Uri | string & {},
...args: keyof RouteParams extends Uri
? [params?: Record<string, string>, targetLangCode?: LangCode, routeLangCode?: LangCode]
: [params: RouteParams[Uri], targetLangCode?: LangCode, routeLangCode?: LangCode]
...args: Uri extends keyof RouteParams
? undefined extends RouteParams[Uri]
? [params?: Record<string, string>, targetLangCode?: LangCode, routeLangCode?: LangCode]
: [params: RouteParams[Uri], targetLangCode?: LangCode, routeLangCode?: LangCode]
: [params?: Record<string, string>, targetLangCode?: LangCode, routeLangCode?: LangCode]
): string
export function t<Path extends TranslationPath>(

View File

@ -15,6 +15,7 @@
"dependencies": {
"@astrojs/image": "^0.16.7",
"@astrojs/mdx": "^0.19.1",
"@astrojs/rss": "^2.4.1",
"@astrojs/sitemap": "^1.3.0",
"astro": "2.4.3",
"astro-i18n": "^1.6.10"

View File

@ -7,6 +7,9 @@ dependencies:
'@astrojs/mdx':
specifier: ^0.19.1
version: 0.19.1(astro@2.4.3)(rollup@3.21.5)
'@astrojs/rss':
specifier: ^2.4.1
version: 2.4.1
'@astrojs/sitemap':
specifier: ^1.3.0
version: 1.3.0
@ -138,6 +141,13 @@ packages:
prismjs: 1.29.0
dev: false
/@astrojs/rss@2.4.1:
resolution: {integrity: sha512-c+j6Dwxc/t50/v7xhM88RKbxh9SjaQMw0IdLeeOqQAdcLT2Me7nUUWwx0BbPnu6RO0YxT5Up1Sl/OdrA60tfSw==}
dependencies:
fast-xml-parser: 4.2.2
kleur: 4.1.5
dev: false
/@astrojs/sitemap@1.3.0:
resolution: {integrity: sha512-s1/v9MfnxVLvH5v4edK02bBAOMp5tuEvhPT1pJ2qaqXM6QZuqatk/xQU3kuWebQh+yqnD2yBeeHbmfwr4gG1vw==}
dependencies:
@ -1777,6 +1787,13 @@ packages:
micromatch: 4.0.5
dev: false
/fast-xml-parser@4.2.2:
resolution: {integrity: sha512-DLzIPtQqmvmdq3VUKR7T6omPK/VCRNqgFlGtbESfyhcH2R4I8EzK1/K6E8PkRCK2EabWrUHK32NjYRbEFnnz0Q==}
hasBin: true
dependencies:
strnum: 1.0.5
dev: false
/fastq@1.15.0:
resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==}
dependencies:
@ -3540,6 +3557,10 @@ packages:
engines: {node: '>=12'}
dev: false
/strnum@1.0.5:
resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==}
dev: false
/style-to-object@0.4.1:
resolution: {integrity: sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==}
dependencies:

View File

@ -5,6 +5,7 @@ lang: en
slug: "2022"
excerpt: Changes in my services, the website and myself.
tags: ["Freelance"]
type: articles
createdAt: "2022-06-08T14:24:06.000Z"
---

View File

@ -5,6 +5,7 @@ lang: en
slug: "2023"
excerpt: New changes.
tags: ["Freelance"]
type: articles
createdAt: "2023-02-03T17:41:00.000Z"
---

View File

@ -5,6 +5,7 @@ lang: en
slug: "after-effects-expressions"
excerpt: Expressions in After Effects have always been blurry for me. I know they exist, I know they're powerful, I know it could save a lot of time and clean complex keyframe filled compositions but… They are hard to learn!
tags: ["Design"]
type: articles
createdAt: "2019-04-24T09:00:00.000Z"
code: true
---

View File

@ -6,6 +6,7 @@ slug: "faq"
draft: true
excerpt: Why, how et and especially what.
tags: ["Freelance"]
type: articles
createdAt: "2022-06-22T15:34:45.000Z"
---

View File

@ -6,6 +6,7 @@ slug: "gratuiste"
draft: true
excerpt: Translation in progress, stay tuned ;)
tags: ["Design", "Freelance"]
type: articles
createdAt: "2017-05-27T07:47:36.000Z"
---

View File

@ -6,6 +6,7 @@ slug: "sci-hub-unblock"
key: "scihub"
excerpt: "In March 2019, the Paris Regional Court ruled in favour of the publishers of scientific articles Elsevier and Springer Nature by ordering internet service providers to block access to these two websites. Here is how to access them if they are blocked in your country anyway."
tags: ["Internet", "Science"]
type: articles
createdAt: "2019-03-31T07:47:36.000Z"
updatedAt: "2022-12-27T12:08:00.000Z"
---

View File

@ -5,6 +5,7 @@ lang: en
slug: "the-day-I-jamd"
excerpt: Ooh, yeah! All right! Were jammin
tags: ["Dev", "Jamstack"]
type: articles
createdAt: "2020-10-08T09:00:00.000Z"
updatedAt: "2022-12-27T15:40:06.000Z"
---

View File

@ -5,6 +5,7 @@ lang: en
slug: "video-compression"
excerpt: How to gain precious weight when encoding videos.
tags: ["Design"]
type: articles
createdAt: "2021-05-05T09:00:00.000Z"
updatedAt: "2022-06-08T14:24:06.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "2022"
excerpt: Évolution des services, du site et de moi-même.
tags: ["Freelance"]
type: articles
createdAt: "2022-06-08T14:24:06.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "2023"
excerpt: Suite des évolutions.
tags: ["Freelance"]
type: articles
createdAt: "2023-02-03T17:41:00.000Z"
---

View File

@ -6,6 +6,7 @@ draft: true
slug: "after-effects-expressions"
excerpt: En cours de traduction, revenez bientôt ;)
tags: ["Design"]
type: articles
createdAt: "2019-04-24T09:00:00.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "faq"
excerpt: Pourquoi, comment et surtout quèsaco.
tags: ["Freelance"]
type: articles
createdAt: "2022-06-22T15:34:45.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "gratuiste"
excerpt: "Jai cherché un moyen de mettre mes compétences au service dautrui et je pense avoir trouvé: je vais travailler gratuitement pour des associations."
tags: ["Graphisme", "Freelance"]
type: articles
createdAt: "2017-05-27T07:47:36.000Z"
updatedAt: "2022-12-27T15:36:06.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "sci-hub-blocage"
excerpt: "Le tribunal de grande instance de Paris a ordonné aux fournisseurs daccès à internet de bloquer laccès à sci-hub. Voici comment contourner les blocages mis en place."
tags: ["Internet", "Science"]
type: articles
createdAt: "2019-03-31T07:47:36.000Z"
updatedAt: "2022-12-27T12:08:00.000Z"
---

View File

@ -5,6 +5,7 @@ lang: fr
slug: "the-day-I-jamd"
excerpt: Ooh, yeah! All right! Were jammin
tags: ["Dev", "Jamstack"]
type: articles
createdAt: "2020-10-08T07:47:36.000Z"
updatedAt: "2022-12-27T15:40:06.000Z"
---

View File

@ -6,6 +6,7 @@ draft: true
slug: "video-compression"
excerpt: Pas encore traduit
tags: ["Design"]
type: articles
createdAt: "2021-05-05T09:00:00.000Z"
updatedAt: "2022-06-08T14:24:06.000Z"
---

View File

@ -6,6 +6,7 @@ const articles = defineCollection({
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
tags: z.array(z.string()), // An array of strings
type: z.string(),
// Parse pubDate as a browser-standard `Date` object
createdAt: z.string().transform((str) => new Date(str)),
updatedAt: z
@ -23,6 +24,7 @@ const fragments = defineCollection({
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
tags: z.array(z.string()), // An array of strings
type: z.string(),
// Parse pubDate as a browser-standard `Date` object
createdAt: z.string().transform((str) => new Date(str)),
updatedAt: z

View File

@ -6,6 +6,7 @@ slug: "acme-sh-tls-cert"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: Real cert have curves.
tags: ["security"]
type: snippets
---
## Disclaimer

View File

@ -6,6 +6,7 @@ slug: "array-vs-array"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: My peak javascript
tags: ["nuxt.js"]
type: snippets
---
## Context

View File

@ -7,6 +7,7 @@ draft: true
excerpt: Easy to grab and use hover effects.
tags: ["CSS"]
code: true
type: snippets
createdAt: "2020-10-08T09:00:00.000Z"
---

View File

@ -7,6 +7,7 @@ slug: "image-full"
createdAt: "2020-09-15T09:00:00.000Z"
updatedAt: "2022-06-08T14:24:06.000Z"
tags: ["CSS"]
type: snippets
---
[Go back to available snippets](/en/snippets)

View File

@ -7,6 +7,7 @@ createdAt: "2022-06-08T14:24:06.000Z"
updatedAt: "2022-09-08T13:43:33.000Z"
excerpt: When the most used gql module doesn't work…
tags: ["nuxt.js"]
type: snippets
---
## The problem

View File

@ -6,6 +6,7 @@ slug: "super-cookies"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: It's a real recipe, not a joke about annoying files.
tags: ["food"]
type: snippets
---
import AstroImage from "../../../components/AstroImage.astro";

View File

@ -5,6 +5,7 @@ lang: en
slug: "toulouse-fun"
excerpt: Gonna have to trust me on this ¯\_(ツ)_/¯
tags: ["lifestyle"]
type: snippets
createdAt: "2022-06-22T15:34:45.000Z"
---

View File

@ -6,6 +6,7 @@ slug: "acme-sh-tls-cert"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: La sécurité avec des courbes.
tags: ["sécurité"]
type: fragments
---
## Attention

View File

@ -7,6 +7,7 @@ slug: "array-vs-array"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: En cours de traduction.
tags: ["nuxt.js"]
type: fragments
---
[Voir les fragments disponibles](/fragments)

View File

@ -6,6 +6,7 @@ slug: "buttons"
draft: true
excerpt: Quelques effets de survol faciles à récupérer et utiliser.
tags: ["CSS"]
type: fragments
code: true
createdAt: "2020-10-08T09:00:00.000Z"
---

View File

@ -7,6 +7,7 @@ createdAt: "2020-09-15T09:00:00.000Z"
updatedAt: "2022-06-08T14:24:06.000Z"
excerpt: Faire déborder une image de son conteneur sans tout casser.
tags: ["CSS"]
type: fragments
---
import AstroImage from "../../../components/AstroImage.astro";

View File

@ -7,6 +7,7 @@ createdAt: "2022-06-08T14:24:06.000Z"
updatedAt: "2022-09-08T13:43:33.000Z"
excerpt: Quand le module gql le plus utilisé ne fonctionne pas…
tags: ["nuxt.js"]
type: fragments
---
## Le problème

View File

@ -6,6 +6,7 @@ slug: "super-cookies"
createdAt: "2022-06-08T14:24:06.000Z"
excerpt: C'est vraiment une recette hein, pas une blague sur les fichiers temporaires.
tags: ["cuisine"]
type: fragments
---
import AstroImage from "../../../components/AstroImage.astro";

View File

@ -7,6 +7,7 @@ slug: "toulouse-fun"
createdAt: "2022-06-22T15:34:45.000Z"
excerpt: En cours de traduction.
tags: ["lifestyle"]
type: fragments
---
[Voir les fragments disponibles](/fragments)

34
src/pages/en/rss.xml.js Normal file
View File

@ -0,0 +1,34 @@
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
export async function get(context) {
const articles = await getCollection("articles", ({ data }) => {
return data.lang === "en" && !data.draft;
});
const fragments = await getCollection("fragments", ({ data }) => {
return data.lang === "en" && !data.draft;
});
const posts = articles.concat(fragments);
return rss({
// `<title>` field in output xml
title: "Nicolas Arduin",
// `<description>` field in output xml
description: "Articles from nardu.in",
// Pull in your project "site" from the endpoint context
// https://docs.astro.build/en/reference/api-reference/#contextsite
site: context.site,
// Array of `<item>`s in output xml
// See "Generating items" section for examples using content collections and glob imports
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.createdAt,
description: post.data.subtitle,
lang: post.data.lang,
// Compute RSS link from post `slug`
// This example assumes all posts are rendered as `/blog/[slug]` routes
link: `/en/${post.data.type}/${post.slug}/`,
})),
// (optional) inject custom xml
customData: `<language>en-us</language>`,
});
}

34
src/pages/rss.xml.js Normal file
View File

@ -0,0 +1,34 @@
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
export async function get(context) {
const articles = await getCollection("articles", ({ data }) => {
return data.lang === "fr" && !data.draft;
});
const fragments = await getCollection("fragments", ({ data }) => {
return data.lang === "fr" && !data.draft;
});
const posts = articles.concat(fragments);
return rss({
// `<title>` field in output xml
title: "Nicolas Arduin",
// `<description>` field in output xml
description: "Articles publiés sur nardu.in",
// Pull in your project "site" from the endpoint context
// https://docs.astro.build/en/reference/api-reference/#contextsite
site: context.site,
// Array of `<item>`s in output xml
// See "Generating items" section for examples using content collections and glob imports
items: posts.map((post) => ({
title: post.data.title,
pubDate: post.data.createdAt,
description: post.data.subtitle,
lang: post.data.lang,
// Compute RSS link from post `slug`
// This example assumes all posts are rendered as `/blog/[slug]` routes
link: `/${post.data.type}/${post.slug}/`,
})),
// (optional) inject custom xml
customData: `<language>fr-fr</language>`,
});
}