add og images, add json and xml feed, fix minor issues

This commit is contained in:
Hans Pagel
2021-07-10 22:51:06 +02:00
parent 2e40a827fb
commit 2fefcf31da
15 changed files with 298 additions and 171 deletions

View File

@@ -1,5 +1,8 @@
const path = require('path')
const visit = require('unist-util-visit')
const unified = require('unified')
const markdown = require('remark-parse')
const html = require('remark-html')
function addStyleResource(rule) {
rule.use('style-resource')
@@ -35,6 +38,7 @@ function tableWrapper() {
module.exports = {
siteName: 'tiptap',
siteUrl: 'https://www.tiptap.dev/',
titleTemplate: '%s tiptap editor',
icon: './src/favicon.svg',
port: 3000,
@@ -84,6 +88,67 @@ module.exports = {
},
},
},
{
use: 'gridsome-plugin-feed',
options: {
// Required: array of `GraphQL` type names you wish to include
contentTypes: ['Post'],
// Optional: any properties you wish to set for `Feed()` constructor
// See https://www.npmjs.com/package/feed#example for available properties
feedOptions: {
title: 'tiptap blog',
description: 'The headless editor framework for web artisans.',
language: 'en',
// TODO: Should work, but doesnt.
// https://github.com/onecrayon/gridsome-plugin-feed
// https://www.npmjs.com/package/feed
favicon: './src/favicon.svg',
},
// === All options after this point show their default values ===
// Optional; opt into which feeds you wish to generate, and set their output path
rss: {
enabled: true,
output: '/feed.xml',
},
json: {
enabled: true,
output: '/feed.json',
},
// Optional: the maximum number of items to include in your feed
maxItems: 10,
// Optional: an array of properties passed to `Feed.addItem()` that will be parsed for
// URLs in HTML (ensures that URLs are full `http` URLs rather than site-relative).
// To disable this functionality, set to `null`.
htmlFields: ['description', 'content'],
// Optional: if you wish to enforce trailing slashes for site URLs
enforceTrailingSlashes: false,
// Optional: a method that accepts a node and returns true (include) or false (exclude)
// Example: only past-dated nodes: `filterNodes: (node) => node.date <= new Date()`
filterNodes: () => true,
// Optional: a method that accepts a node and returns an object for `Feed.addItem()`
// See https://www.npmjs.com/package/feed#example for available properties
// NOTE: `date` field MUST be a Javascript `Date` object
nodeToFeedItem: node => {
const content = unified()
.use(markdown)
.use(html)
.processSync(node.content)
.toString()
return {
title: node.title,
date: node.published_at,
description: node.teaser,
content,
author: [
{
name: node.author,
},
],
}
},
},
},
],
transformers: {
remark: {