Skip to content
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(document-driven): add document-driven as a @nuxt/content feature #1279

Merged
merged 17 commits into from Jun 23, 2022

Conversation

Tahul
Copy link
Contributor

@Tahul Tahul commented Jun 22, 2022

❓ Type of change

  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)

📚 Description

This PR adds documentDriven as a new feature for the module.

This feature basically is a more generic approach than @docus/base.

It offers more flexibility while preserving the same features as a default.

Here is a preview from the config object:

const defaultDocumentDrivenConfig = {
  // Will fetch page globally
  page: true,
  // Will fetch navigation globally
  navigation: true,
  // Will fetch surround globally
  surround: true,
  // `globals` key definition
  globals: {
    // Will fetch `_theme.yml` and put it in `globals.theme`
    theme: {
      where: [
        {
          _id: 'content:_theme.yml'
        }
      ],
      without: ['_']
    }
  },
  // Will use `theme` global to fallback on layout resolution
  layoutFallbacks: ['theme'],
  // Will inject pre-configured `[...slug].vue` page
  injectPage: true
}

These datas becomes globally available via the useDocumentDriven() composable:

const { page, navigation, surround, globals } = useDocumentDriven()

I updated the documentation with new pages:

/guide/writing/document-driven
/api/composables/use-document-driven
/api/composables/use-content-helpers
/api/configuration (new content)
/examples/document-driven/hello-world (new example)

This PR also deeply refactors the playground/ and test/ directories.

You can now run scoped playground with these commands:

yarn dev => `playground/basic`
yarn dev basic => `playground/basic`
yarn dev document-driven => `playground/document-driven`

Same applies to test:

yarn test => `Run all test suite`
yarn test basic => `basic.test.ts`
yarn test module => `module.test.ts`
yarn test document-driven => `document-driven.test.ts`

Any feedback to the API or implementation is more than welcome!

📝 Checklist

  • I have updated the documentation accordingly.

TODO:

@netlify
Copy link

netlify bot commented Jun 22, 2022

Deploy Preview for nuxt-content ready!

Name Link
🔨 Latest commit 7c8650a
🔍 Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/62b4907587a6b2000854b966
😎 Deploy Preview https://deploy-preview-1279--nuxt-content.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Tahul Tahul requested review from farnabaz and Atinux and removed request for farnabaz June 22, 2022 15:26
@Atinux
Copy link
Member

Atinux commented Jun 23, 2022

Beautiful work @Tahul ❤️

I think we could go with

const { page, navigation, surround, globals } = useContent()

And warn to say that this composable is available only with content.documentDrivent mode activated.

Tahul and others added 3 commits June 23, 2022 13:34
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@Tahul
Copy link
Contributor Author

Tahul commented Jun 23, 2022

Beautiful work @Tahul ❤️

I think we could go with

const { page, navigation, surround, globals } = useContent()

And warn to say that this composable is available only with content.documentDrivent mode activated.

yaaaay! 🚀

Pushing that really soon!

@Tahul
Copy link
Contributor Author

Tahul commented Jun 23, 2022

@Atinux ; I renamed useDocumentDriven into useContent :)

WDYT about merging this feature?

Copy link
Member

Atinux commented Jun 23, 2022

I would like to have also a review from @farnabaz

@Atinux
Copy link
Member

Atinux commented Jun 23, 2022

I think you can also rename the composable filename @Tahul

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Tahul Tahul merged commit 2880bee into main Jun 23, 2022
@Tahul Tahul deleted the feat/document-driven branch June 23, 2022 16:20
@Tahul Tahul restored the feat/document-driven branch June 27, 2022 12:18
@Tahul Tahul deleted the feat/document-driven branch June 27, 2022 12:19
@farnabaz farnabaz mentioned this pull request Aug 12, 2022
farnabaz pushed a commit that referenced this pull request Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants