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

flarum-tags does not export any JS functions to use in extensions #3707

Closed
n-peugnet opened this issue Dec 12, 2022 · 3 comments
Closed

flarum-tags does not export any JS functions to use in extensions #3707

n-peugnet opened this issue Dec 12, 2022 · 3 comments

Comments

@n-peugnet
Copy link
Contributor

Current Behavior

The documentation about importing from extensions explains how to import from flarum-tags extension. So I was hoping to be able to use the tagLabel function this way. But it turns out nothing is exported by this extension. Which is unfortunate when trying to follow the exemple.

This issue has already been reported on the forum but has not received any answer.

Steps to Reproduce

  1. Follow this documentation page : https://docs.flarum.org/extend/extending-extensions
  2. Expect to be able to use some functions from the demonstrated flarum-tags extension
  3. Find out after many tries that nothing is actually exported by this extension

Expected Behavior

The flarum-tags extension should export at least some of its functions. Not only to make fix the exemple in the docs but also to give more possibilities to extension developers.

As the tags extension is almost always installed, it may be interesting to extend its features. And giving access to function to allow displaying tags would be very useful.

Screenshots

No response

Environment

  • Flarum version: 1.6.2
  • Website URL: localhost
  • Webserver: PHP Built-in web server
  • Hosting environment: local machine
  • PHP version: 8.1.12
  • Browser: Mozilla Firefox 107.0.1

Output of php flarum info

Output of "php flarum info", run this in terminal in your Flarum directory.

Possible Solution

Add exports for at least tagLabel, tagsLabel and tagIcon to flarum-tags to make them accessible to extensions.

Additional Context

No response

@davwheat
Copy link
Member

Tags does export its JS, but not in the standard way used for 3rd party extensions.

The documentation needs to be changed to reflect this.

You can import this function like so:

import tagLabel from 'flarum/tags/helpers/tagLabel';

@n-peugnet
Copy link
Contributor Author

You can import this function like so:

import tagLabel from 'flarum/tags/helpers/tagLabel';

Thank you, this is working as expected! It seems the Webpack step is not needed with this method of import:

module.exports = require('flarum-webpack-config')({
    // Provide the extension IDs of all extensions from which your extension will be importing.
    // Do this for both full and optional dependencies.
    useExtensions: ['flarum-tags']
});

@SychO9
Copy link
Member

SychO9 commented Apr 15, 2023

flarum/docs#456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants