2.13.95 • Published 1 year ago

@taktikorg/non-porro v2.13.95

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@taktikorg/non-porro

npm version npm downloads License Nuxt

This module provides extra abilities for implementation RSS feed. It's pretty similar to module-feed, but have support nuxt-content.

If you need fully customized feeds, you can freely choose any feed module (this or the mentioned above). But this module can be more flexible.

Features

  • Configured out of the box for nuxt-content
  • Supports general and specialized hooks for both feed kinds
  • Flexible: use configuration defaults (feed, item), mapping (item) or hooks for customization
  • SSR and SSG support

Configured out of the box for nuxt-content

Default settings are:

{
  feeds: {
    '/feed.atom': { revisit: '6h', type: 'atom1', content: true },
    '/feed.xml': { revisit: '6h', type: 'rss2', content: true },
    '/feed.json': { revisit: '6h', type: 'json1', content: true },
  },
  content: {
    item: {
      templateRoots: [true, 'feedme'],
    },
  },
}

General and specialized hooks

// project-name/server/plugins/feedme.ts
import type { NitroApp } from 'nitropack'

// Nitro hooks can be set only in nitro plugin
export default (nitroApp: NitroApp) => {
  // General hook: feedme:handle:content:item
  // Specialized hook: feedme:handle:content:item[*]
  //
  // When specialized hook set, general also will be called
  nitroApp.hooks.hook('feedme:handle:content:item[/contentDefaults.xml]', async ({ feed: { insert, invoke, parsed } }) => {
    if (parsed.title === 'First item') {
      // Invoke in case if item was created by another callback
      const maybeItemOptions = invoke()

      // Insert replaces current item configuration
      insert({
        ...maybeItemOptions,
        category: [
          ...maybeItemOptions?.category ?? [],
          { name: 'content hook processed' },
        ],
      })
    }
  })

  // Specialized hook for default feed
  nitroApp.hooks.hook('feedme:handle[/feed.xml]', async ({ context: { event }, feed: { create } }) => {
    // Create also replaces current feed
    create({ id: '', title: `Special feed for '${event.path}' route`, copyright: '' })
  })

  // General hook for default feed
  nitroApp.hooks.hook('feedme:handle', async ({ context: { event }, feed: { create, invoke } }) => {
    invoke() ?? create({ id: '', title: `Default feed for '${event.path}' route`, copyright: '' })
  })
}

Mapping configuration

Mapping is used for linking feed item object key to the path in parsed content:

{
  item: {
    mapping: [
      // Third item is optional mapping function
      ['date', 'modified', value => value ? new Date(value) : value],
      // When mapping function result is undefined - next variant applied
      ['date', 'created', value => value ? new Date(value) : value],
      // Until the real one value will be set
      ['date', '', () => new Date()],
      // By default mapping is x => x
      ['link', '_path'],
    ],
    // Create default mappings with indicated roots:
    //   [keyof Item /* such as image, id, link */, root + keyof Item]
    //
    // The true value means use empty root:
    //   ['link', 'link']
    //
    // Where any other key means use this as path to value:
    //  ['link', `{root}.link`]
    //
    // Root can be separate by `.` which allows to deep invoking
    templateRoots: [true, 'feedme'],
  }
}

NOTE: Date value is a special case for feed module, so by default mapping provides the next map for the date field: value => value ? new Date(value) : new Date() So in case when you provide your own alias for date - you need to provide map function

NOTE: The mapping function is serialized so its required to not to have any references in outer scopes

Tags

Tags allow to replace node values according to match:

{
  // Allows to pass optional map function
  tags: [
    // This tags replace first empty symbol if value starts with /
    // Example: /link -> urlBase/link
    [/^(?=\/)/, urlBase],
  ],
}

Note: Tags applied recursively, item.field.inner (value) is affected

Quick Setup

  1. Add @taktikorg/non-porro dependency to your project

Use your favorite package manager (I prefer yarn)

yarn add -D @taktikorg/non-porro

pnpm add -D @taktikorg/non-porro

npm install --save-dev @taktikorg/non-porro
  1. Add @taktikorg/non-porro to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    // After nuxt content
    '@nuxt/content',
    '@taktikorg/non-porro'
  ]
})

That's it! You can now use @taktikorg/non-porro in your Nuxt app ✨

keysuuidvpces5globbinariespostcssstreamFloat32Array-0monorepoelasticachequeueeslinttypesafecurlzeroeffect-tsFunction.prototype.nameRegExp#flagspathpromisespinnersreadebselectronStyleSheetharmonyjasminearraybufferworkspace:*assertscloudsearchfigletsyntaxerrorUint32ArraystructuredCloneWebSocketsremovetoArraybabelArrayBufferimportexporteventsargsconstrequirees-shimscjkhttpdragxmlworkflowforkjsdomObject.isreduxcharacternpmec2real-timelocationownmake dirvalidatorcomputed-typesprotoconcatMapes2017atomdefinePropertygetPrototypeOfkeybeanstalkhttpsexecuteisConcatSpreadablesetterWebSocketinstrumentationreact-hooksregular expressiontesterramdatypedfind-upSymbolparseAsyncIteratorroutearktypesimpledbnodejsflatMapWeakSetschemeprefixrm -frflatReactiveExtensionschildidentifiersfetchfindupmochanodequerystringdayjs.envTypedArraydirfromfunction.lengtha11ytsgetOwnPropertyDescriptordeepcopytostringtagtapedescriptorsagenttoolsframersettingsbusysameValueZerosortReflect.getPrototypeOffast-copyregexinputspawnperformancedeterministic6to5getwalkingcommandmatchesoptionxhrchannelmatchAllfolderglobalThisforEachelbObject.valuesassertionpushsliceapiupnameswindowString.prototype.matchAlldynamodbcoerciblefile systemArray.prototype.findLastCSSStyleDeclarationdataViewStreamsBigInt64Arrayvalidatecallbindurlintrinsichooksprivate dataamazonargvtacitcodesES2019ECMAScript 2018utilitynopeimmutableTypeScriptnegativejsonschemapropertiescoveragenativeassigncore-jstrimLeftgroupByglacierindicatorstabletextObservablewhichURLendershrinkwrapSymbol.toStringTagUint8ClampedArrayreversedArray.prototype.includesArrayrfc4122byteWeakMapjestclienttrimEndshellregular-expressionArray.prototype.filter[[Prototype]]animationECMAScript 6hasdeepcloneIteratordatemanagerhasOwnPropertycontainsargument0spinnervalidutilitieses-shim APIweakmapwgetxtermarraylooksetPrototypeOfreversetimeenvironmentserializationcallpicomatchwafparenttelephoneexpressionruntimebyteOffsetsymlinksswfrmESnextspecglobalsclass-validatoristakeregularschematypanionES2023touchMicrosoftbrowserfindpackageprocessselfjapanesepackagestc39fast-deep-copyeslintpluginmodulesstringifybinduser-streamsES2016fullwidthaccessibilitytraverseonceECMAScript 2023@@toStringTagflagmatchStreamgraphqlqueueMicrotasklibphonenumbertyped arraytoReversedtoobjectflattenspringfindLastJSON-Schemareact animationiamMapnpmignoredirectoryES3parserdataviewInt32Arrayzxidlepipesns3dregular expressionsglobaltestingsearchsomelanguagebundlingutil.inspectserializercopycolumntypeofArray.prototype.flattencheckreact-testing-librarycachespeedReactiveXphonereact-hook-formthreedescriptorqslengthwritablehashlinklrupropertybrowserlistpruneio-tsArray.prototype.flatartbinenvironmentsreadableRxJSvaluesautoprefixergenericsslotes2015fnmatchtrimRightroutingmoveInt8Arrayvariableslook-upES2018ES8fpscompilertransportistanbulObservablescollection.es6rdsInt16ArrayextratrimfastcloneArray.prototype.flatMaprecursivees-abstracttypeomitinternalredactfunctionloggingBigUint64ArrayfsES2021objESincludesenvreworkrouter.gitignorePushchaiecmascriptglobal objectyuptrimStartwhatwgcharactersfunctional__proto__Float64ArrayES5efficientmrusetImmediatetypedarraysequalityminimalsuperstructwaitpackage.jsonObject.fromEntriespolyfillcall-bindArray.prototype.containscssreusecolorsemrCSSbinaryObject.definePropertyECMAScript 2016arraysredirectposeextendhtmlmkdirkoreancloudtrailstoragegatewayfileidwritenegative zeroes7zodHyBicircularpopmotionvalidationsharedarraybuffercloudfrontregexpfeedquotecloudformationajaxassertgdprbannerignoreSetdefinewebECMAScript 2019awesomesauceArray.prototype.findLastIndexmapreducelocalrgbformjsObject.keysrandomansicolumnscss-in-jsnamefunctionsclirangeerrorendpointjson-schema-validationes2016optimizerformses2018route53Object.entriesjshintaccessorprotobufconfigmobilepyyamlobjectescapeJSONdom-testing-libraryrulesexpresscolorexecsqsform-validationgetterfulljoistylingcallboundString.prototype.trimjsonapollormdireveryloggerlastcolourtypedarrayhasOwnstyleentriesreadablestreampoint-freewarningparentssinatraoptimisthardlinkstypesfilterES7_.extendrobustjavascriptECMAScript 5fpexecfileesgetintrinsicURLSearchParamschromeuninstallresti18ndebugasciilockfilecensorshebangconsumefastifyairbnboffsetappreduceracorncallbackmakedeepmulti-packagestringloadingmaphas-ownyamlfast-clonepluginlistenerswaapifastpnpm9diffES2017findLastIndexformatreactshamUint16ArrayES2022karmaiterateastsymbolcommandervarsECMAScriptworkertddRFC-6455walkdependency managervesttslibchineseprivateweaksethelperes8groupemojigetopteslintconfigmkdirstestdebuggerstyleguideflagsasynccomparejsdiffoutputimmerdomfantasy-landframeworkpostcss-pluginterminalRxes6seteventDispatcherECMAScript 2021sharedtypescriptbdd$.extend
2.13.95

1 year ago

2.13.94

1 year ago

2.13.93

1 year ago

2.13.92

1 year ago

2.13.91

1 year ago

2.13.90

1 year ago

2.13.89

1 year ago

2.13.88

1 year ago

2.13.87

1 year ago

2.13.86

1 year ago

2.13.85

1 year ago

2.12.85

1 year ago

2.12.84

1 year ago

2.12.83

1 year ago

2.12.82

1 year ago

2.12.81

1 year ago

2.12.80

1 year ago

2.12.79

1 year ago

2.12.78

1 year ago

2.12.77

1 year ago

2.12.76

1 year ago

2.12.75

1 year ago

2.12.74

1 year ago

2.12.73

1 year ago

2.12.72

1 year ago

2.12.71

1 year ago

2.12.70

1 year ago

2.12.69

1 year ago

2.12.68

1 year ago

2.12.67

1 year ago

2.11.67

1 year ago

2.11.66

1 year ago

2.11.65

1 year ago

2.11.64

1 year ago

2.11.63

1 year ago

2.10.63

1 year ago

2.10.62

1 year ago

2.10.61

1 year ago

2.10.60

1 year ago

2.10.59

1 year ago

2.10.58

1 year ago

2.10.57

1 year ago

2.10.56

1 year ago

2.10.55

1 year ago

2.10.54

1 year ago

2.10.53

1 year ago

2.10.52

1 year ago

2.10.51

1 year ago

2.10.50

1 year ago

2.10.49

1 year ago

2.10.48

1 year ago

2.10.47

1 year ago

2.9.47

1 year ago

2.9.46

1 year ago

2.9.45

1 year ago

2.8.45

1 year ago

2.8.44

1 year ago

2.8.43

1 year ago

2.8.42

1 year ago

2.7.42

1 year ago

2.7.41

1 year ago

1.7.41

1 year ago

1.7.40

1 year ago

1.6.40

1 year ago

1.6.39

1 year ago

1.6.38

1 year ago

1.6.37

1 year ago

1.6.36

1 year ago

1.6.35

1 year ago

1.6.34

1 year ago

1.6.33

1 year ago

1.6.32

1 year ago

1.6.31

1 year ago

1.5.31

1 year ago

1.5.30

1 year ago

1.5.29

1 year ago

1.5.28

1 year ago

1.5.27

1 year ago

1.5.26

1 year ago

1.5.25

1 year ago

1.4.25

1 year ago

1.4.24

1 year ago

1.3.24

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago