2020-03-06 18:59:36 +08:00
|
|
|
|
const path = require('path')
|
2020-11-22 06:09:56 +08:00
|
|
|
|
const visit = require('unist-util-visit')
|
2021-07-11 04:51:06 +08:00
|
|
|
|
const unified = require('unified')
|
|
|
|
|
const markdown = require('remark-parse')
|
|
|
|
|
const html = require('remark-html')
|
2020-03-06 18:59:36 +08:00
|
|
|
|
|
|
|
|
|
function addStyleResource(rule) {
|
|
|
|
|
rule.use('style-resource')
|
|
|
|
|
.loader('style-resources-loader')
|
|
|
|
|
.options({
|
|
|
|
|
patterns: [
|
|
|
|
|
path.resolve(__dirname, './src/variables.scss'),
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 06:09:56 +08:00
|
|
|
|
function tableWrapper() {
|
|
|
|
|
return async tree => {
|
|
|
|
|
visit(
|
|
|
|
|
tree,
|
|
|
|
|
'table',
|
|
|
|
|
(node, index, parent) => {
|
|
|
|
|
if (node.type === 'table' && parent.type === 'root') {
|
|
|
|
|
const original = { ...node }
|
|
|
|
|
|
|
|
|
|
node.type = 'div'
|
|
|
|
|
node.children = [original]
|
|
|
|
|
node.data = {
|
|
|
|
|
hProperties: {
|
|
|
|
|
class: 'table-wrapper',
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-08 04:02:22 +08:00
|
|
|
|
module.exports = {
|
2020-10-13 02:18:18 +08:00
|
|
|
|
siteName: 'tiptap',
|
2021-07-11 04:51:06 +08:00
|
|
|
|
siteUrl: 'https://www.tiptap.dev/',
|
2021-02-08 21:53:20 +08:00
|
|
|
|
titleTemplate: '%s – tiptap editor',
|
2021-02-05 18:10:34 +08:00
|
|
|
|
icon: './src/favicon.svg',
|
2019-12-08 04:02:22 +08:00
|
|
|
|
port: 3000,
|
|
|
|
|
plugins: [
|
|
|
|
|
{
|
|
|
|
|
use: '@gridsome/vue-remark',
|
|
|
|
|
options: {
|
2020-04-18 23:05:29 +08:00
|
|
|
|
typeName: 'DocPage',
|
2020-04-24 16:03:15 +08:00
|
|
|
|
baseDir: './src/docPages',
|
2020-11-06 21:20:00 +08:00
|
|
|
|
template: './src/templates/DocPage/index.vue',
|
2019-12-08 04:02:22 +08:00
|
|
|
|
plugins: [
|
|
|
|
|
'@gridsome/remark-prismjs',
|
2020-08-19 02:42:54 +08:00
|
|
|
|
'remark-container',
|
2020-09-27 16:29:01 +08:00
|
|
|
|
'remark-toc',
|
2020-11-22 06:09:56 +08:00
|
|
|
|
tableWrapper,
|
2019-12-08 04:02:22 +08:00
|
|
|
|
],
|
2020-04-19 05:00:47 +08:00
|
|
|
|
remark: {
|
|
|
|
|
autolinkHeadings: {
|
|
|
|
|
content: {
|
|
|
|
|
type: 'text',
|
2020-09-24 05:38:11 +08:00
|
|
|
|
value: '#',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-04-17 18:55:53 +08:00
|
|
|
|
},
|
2019-12-08 04:02:22 +08:00
|
|
|
|
},
|
2021-07-10 00:24:23 +08:00
|
|
|
|
{
|
|
|
|
|
use: '@gridsome/vue-remark',
|
|
|
|
|
options: {
|
|
|
|
|
typeName: 'Post',
|
|
|
|
|
baseDir: './src/posts',
|
|
|
|
|
template: './src/templates/Post/index.vue',
|
|
|
|
|
route: '/blog/:slug',
|
|
|
|
|
plugins: [
|
|
|
|
|
'@gridsome/remark-prismjs',
|
|
|
|
|
'remark-container',
|
|
|
|
|
'remark-toc',
|
|
|
|
|
tableWrapper,
|
|
|
|
|
],
|
|
|
|
|
remark: {
|
|
|
|
|
autolinkHeadings: {
|
|
|
|
|
content: {
|
|
|
|
|
type: 'text',
|
|
|
|
|
value: '#',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-07-11 04:51:06 +08:00
|
|
|
|
{
|
|
|
|
|
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 doesn’t.
|
|
|
|
|
// 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,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-03-06 18:59:36 +08:00
|
|
|
|
],
|
2021-07-10 00:24:23 +08:00
|
|
|
|
transformers: {
|
|
|
|
|
remark: {
|
|
|
|
|
// global remark options
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-09-30 16:01:16 +08:00
|
|
|
|
runtimeCompiler: true,
|
2020-10-02 04:52:31 +08:00
|
|
|
|
configureWebpack: {
|
|
|
|
|
node: {
|
|
|
|
|
fs: 'empty',
|
|
|
|
|
child_process: 'empty',
|
|
|
|
|
tls: 'empty',
|
|
|
|
|
net: 'empty',
|
|
|
|
|
},
|
2020-10-02 05:58:48 +08:00
|
|
|
|
externals: {
|
|
|
|
|
canvas: 'commonjs canvas',
|
|
|
|
|
},
|
2020-10-02 04:52:31 +08:00
|
|
|
|
},
|
2020-03-06 18:59:36 +08:00
|
|
|
|
chainWebpack(config) {
|
|
|
|
|
// Load variables for all vue-files
|
|
|
|
|
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
|
|
|
|
|
|
|
|
|
|
types.forEach(type => {
|
|
|
|
|
addStyleResource(config.module.rule('scss').oneOf(type))
|
|
|
|
|
})
|
|
|
|
|
},
|
2019-12-08 04:02:22 +08:00
|
|
|
|
}
|