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: Include individual text values for each font #149

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jakubkoje
Copy link

Current Situation:
Currently, as reported in #106, it is not possible to include only the requested text for each individual font. The current implementation fetches the entire font data in one call, and there is no way to specify separate text values for each font using the Google API.

Proposed Solution:
To enable this feature, we need to modify the font fetching process and split it into separate calls. By doing so, we can include only the requested text for each font. This adjustment will ensure that the Google API can handle separate text values for individual fonts.

I would love to someone who is more experienced with Nuxt modules to check if the downloading still works as expected.

@jakubkoje
Copy link
Author

jakubkoje commented Aug 5, 2023

I just realized that this could also be implemented in google-fonts-helper. Not sure which way would be better.

Copy link
Collaborator

@ricardogobbosouza ricardogobbosouza left a comment

Choose a reason for hiding this comment

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

Hi @jakubkoje
Thanks for the PR, I made some observations
You also need to add tests 😄

}
})

logger.start('Downloading fonts...')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add outside for


logger.start('Downloading fonts...')
await downloader.execute()
logger.success('Download fonts completed.')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add outside for

Comment on lines +221 to +227
// Disable sanitazions
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID = head.__dangerouslyDisableSanitizersByTagID || {}
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID['gf-script'] = ['innerHTML']
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID['gf-noscript'] = ['innerHTML']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add outside for

for (const url of urls) {
head.script.push({
key: 'gf-script',
innerHTML: `(function(){var l=document.createElement('link');l.rel="stylesheet";l.href="${url}";document.querySelector("head").appendChild(l);})();`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe create a script to create the stylesheet.
In case of several url this script will be duplicated.

Comment on lines +236 to +242
children: `(function(){
var h=document.querySelector("head");
var m=h.querySelector('meta[name="head:count"]');
if(m){m.setAttribute('content',Number(m.getAttribute('content'))+1);}
else{m=document.createElement('meta');m.setAttribute('name','head:count');m.setAttribute('content','1');h.append(m);}
var l=document.createElement('link');l.rel='stylesheet';l.href='${url}';h.appendChild(l);
})();`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe create a script to create the stylesheet.
In case of several url this script will be duplicated.

@sergefy13
Copy link

so is it possible rn?

@jakubkoje
Copy link
Author

so is it possible rn?

Not yet. I don't have much time right now to continue with this pull request, help would be appreciated.

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