-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: nuxt 3 support #114
base: master
Are you sure you want to change the base?
feat: nuxt 3 support #114
Conversation
|
||
nuxt.hook('nitro:init', (nitro) => { | ||
nitro.hooks.hook('close', async () => { | ||
const routes = (nitro._prerenderedRoutes || []).filter(prerenderedRoute => prerenderedRoute.fileName?.endsWith('.html')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 routes
is an empty array so that no item
is added to feeds. Need some configuration in somewhere else for it to work?
.eslintrc
Outdated
"rules": { | ||
"no-use-before-define": ["off"], | ||
"@typescript-eslint/no-use-before-define": ["error", { | ||
"functions": false, | ||
"classes": false, | ||
"variables": false, | ||
"typedefs": true | ||
}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, it's convenient to have "typedefs": true
defined in @nuxtjs/eslint-config-typescript
, because it would be common to refer to other types before their definitions.
What do you think?
(note: the other 3 flags are copied from the output of yarn eslint --print-config ./src/module.ts
, so I believe they are defined in somewhere in the extended configs.)
As of v3.3.1, Nuxt supports
I believe now it's time to complete this PR. Is it simply interchangeable, or is there difference from |
It should be interchangeable for the purpose of this module. |
Hmm, if I'm correct, this module has to know all routes inside server route(s) to return feed file(s) as response, and I can't find the way... Current code in my local looks like this. Or, am I totally taking wrong approach? nuxt.hook('pages:extend', (pages) => {
sources.forEach((source, index) => {
const { dst } = addTemplate({
filename: `feed-${source.type}-${index}.mjs`,
getContents: () => `
import { Feed } from 'feed'
import { defineEventHandler } from 'h3'
export default defineEventHandler(async (event) => {
const feed = new Feed()
feed.options = {
generator: 'https://github.com/nuxt-community/feed-module',
}
${pages.forEach((page) => `
feed.addItem({
title: ${page.meta?.title ?? ''},
id: ${page.path},
link: ${page.path},
description: ${page.meta?.description ?? ''},
date: new Date()
})`.trim())}
return feed.${source.type}()
})`.trimStart(),
write: true // debug
})
addServerHandler({
route: source.path,
handler: dst
})
}) |
Another point about which I want to clarify is that, since Nuxt 3 modules are all what is called build modules in Nuxt 2, runtime code that they create can't refer to variables passed to module function itself. Then, there is no safe way to support this modules' |
You can get each generated route via the You're right that we advise against including runtime code in |
Replace nuxt/framework#108 with minimal spec for fast upgrade.
Sorry, I had to recreate PR because I changed my personal email settings.
This draft PR aims to take over nuxt/framework#103 and resolves nuxt/framework#106.
At first, for the next major release, I triaged all the open issues as below (except Renovate Dependency Dashboard (#99)).
My implementation may include some breaking changes in API, as done in nuxt/framework#103, in a way that I believe is good and beneficial enough for users. I would like to discuss with authors and community while developing this PR.
This PR doesn't aim to add Docus-powered documentation, which is handled in nuxt/framework#103, so that we can keep this PR's "done of definition" manageable.
This PR message will be modified as needed.
TODOs
LICENSE
CHANGELOG.md
README.md
spec)async-cache
package is deprecated, can nitro's unstorage layer be an alternative?)common create function for all feedscommon data passed to create function for all feedspath
#9XML from API #70 (need spec)Googlenews.xml #89 (need spec/research)Namespace and custom attributes #95 (blocked by Add extra attributes on <rss> tag jpmonette/feed#98)sources
option can be a function instead offactory
option)data passed to feed sources factory function (not sure about use case, can be deprecated (?))factory
option)Favicon missing when subscribing from RSS-readers. #102 (need research)Out of Scope
asyncData
nuxt/nuxt#10961 (looks stale)options.css
nuxt/bridge#122References