-
Notifications
You must be signed in to change notification settings - Fork 355
Addition Nodes in HTML head #56
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
base: master
Are you sure you want to change the base?
Conversation
Details are moved to plugin's readme.md
Removed the optional arguments of .head (Reverted last commit.)
…addition-node-in-head
|
Oh, I was about to create same PR 👍 Right now we end up doing a pretty much the copy of the already prepared |
It seems we all have this issue. Since I want to keep using current code of my theme, I am using forked version of Publish and I have to keep it updated with upstream. It sometimes causes conflicts with other plugins. Btw do you have any suggestion on improvement this implementation? I am wondering if there is a better way to do it... |
|
@Ze0nC I just made my own header function for now until this PR is merged. |
Off topic question: do you find any way to modify the content after generation of HTML, just like the Modifier in Plot. |
I put a STRING_KEY in my article which I replace with the actual text while building page. |
JohnSundell
left a comment
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.
Thanks a lot for this @Ze0nC. Just remove the static var, and I'll gladly merge this in. I agree that Plot probably needs a way to modify nodes after they were created. I'll see if I can find some time to work on figuring something out for that soon, and if you have any ideas, feel free to submit a PR. I'm really grateful for all of your contributions 🙂
| /// - parameter rssFeedPath: The path to any RSS feed to associate with the | ||
| /// resulting HTML page. Default: `feed.rss`. | ||
| /// - parameter rssFeedTitle: An optional title for the page's RSS feed. | ||
| /// - parameter additionalNodes: Optional additional nodes for the page. |
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.
for the page -> to add to the resulting <head> element.
|
|
||
| public extension Node where Context == HTML.DocumentContext { | ||
| /// Additional nodes of head. These nodes will be added to head of whole site. | ||
| static var additionalWholeSiteHeadNodes: [Node<HTML.HeadContext>] = [] |
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.
I don't think adding globally mutable state is a good idea. I understand the use case for this, but I think it should be solved in other ways, for example by creating a site-specific head extension which then composes these universal nodes into Publish's head(for...) call.
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.
I agree with you. Global variable is not a clean way to do.
Let me consider a better implementation.
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.
I'd just remove it for now, so that we can merge the other change in 🙂
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.
I have removed it.
…addition-node-in-head
… Context == HTML.DocumentContext
|
Hi @JohnSundell ! I have finished my defense so now I have more free time on it! After some considerations and trials I found it is hard for me to implement it without using global variable, so I would like to discuss with you. First of all, we need to store the nodes in some place, and I have considered:
I have considered for some days but haven't figured it out. Cheers, |
|
Hi @JohnSundell. I hope you are doing well recently.
When the above change, it is possible to:
However, it is not perfect:
I hope this implementation is better then previous one. Cheers, |
|
why isn't this PR merged ? |
|
I hope this PR will be merged soon. |
|
I'm looking forward to this great feature! When can this PR be merged? |
|
So there's no implemented way of adding a Script tag at this moment? |
|
I was looking for a solution to this as well, but I'm thinking it would be nice to have it as a plugin or additional publishing step. My reason for this is that I'd like to easily switch it on/off depending on whether I'm deploying for production or test. |
Hi @JohnSundell, sorry for requesting pulling so frequently.
Here is one about an API change. The idea is in early stage and I want to discuss about it with you if you are interested.
About the change
additionalNodesargument inheadfunction to specify addition nodes for pages.I really appreciate the idea of "javascript-free", but sometimes we need to embed javascript in html head, such as when using Google Analytics.
Therefore, I needed a way to add customized additional whole site nodes.
I have tried to write an extension in
extension Node where Context == HTML.HeadContextin my own package. But I think it might be better to include the ability to add additional nodes in the official Publish repo.usage example
One example is adding Google Analytics to Publish, which requires script node in head.
I have made demo plugin which uses the additionalWholeSiteHeadNodes property.
Another example is writing articles which need specific .js files. I have tried to show LaTeX equations with MathJax, so I need to add MathJaX script on some pages (not all). In this case the 'additionalNodes' argument is helpful.
Please consider the request when convienent.
Cheers,
Zhijin