This would make sharing links to the page much easier.
For example, https://carbon.now.sh/?code=Hello%20world!&theme=blackboard would pre-fill the editor with "Hello world!" and apply the Blackboard theme. Everything else would fall back to the default settings, of course.
If this would be a welcome addition, I'll open a PR for it.
I think the only issue with this is mainly the length of the code – we've only got 2048 characters to work with, minus the theme. One thing we could do is use base32768 to shorten that code significantly, but it leads to ugly-looking URLs.
For example,
const hello = () => {
console.log('Hello World!');
}
(56 chars)
Encodes to:
堗臼铤⋆凃堜曚䙨㫐㖏橯圂Ⴃ㇝荆闌壷䅛鍅Ꮄ榋堑蒠総徖㽈䬥㧰穏 (29 chars)
Just for fun, I also tried encoding the server.js file (1077 chars). It encodes to:
堗臼铤ᴗ槣濵赆䙽㙹㾜唍㵦価䏕靀飅怙瀪䞌嵖駻盡脾飇圗▯䩎䲗⨫䰉炰䷍帙䀘吤飰祻搙赈䚢帒䒔⫮䵶凱န杄译愔苹䭄鲆ꇃ謕蜢飓夙➊䞌嵖駻盡茪黔㙞湼猎㶖燳㫠甼诘恳炢枬嵖駻盡蜾飔㙞湼⫮䵶傫怰着飏堒茼谬絇埒枝䫨劀㻘⡈㗏档㿁朠㬆闎怚▹Ⰾ衣轣栩蔦诓忷㾛甥譄ꃂ㮽⢜粀㛞疨ᚮ⏆ꇃ篭輲闎㧐✩橤㵇㦻⻕赆哅嶛⦳灊霆䆻怭躠蟐幰㖈㐌緧䞃鋡漪鲀擴棸鑍趗䝃䟅茨鋅㙞湸呮ᑦ憋瞩煂鯅怚㡘听洦凱䛤㩔賕嶑荺呍衧懳᧠眰蟎墖㾜殄═睡ሉ煈鯒嵰⠜猎㤂ᔓ㰌碠掞ᛐ▨ᖍᯖ馃埵誰飅延▼猎売饻᧱洰仅徙▯两═睡ݠ暠䚣帗䌛鏬祆觛䋠瓪碲䍓煨Ⰾ䵢溱ݠ暠ꏉឞ棢犎⎢駣濵蜢飅㩔燽Ⳍ終枡䫀ꄜ䚻ᛐ▸鑍趗䝃珵譌诒㙞湹啮⏆击猀硴⠠㙹羼甬綂騋珴眺闒娐自ᚮ泶騩䋤硴⠠㙹羼甬綂馛㰐皮嗁垗莽ᚥ桢槳㰄纠飅忴湯两ᯗᔁ怩焼諅彴䋙咅桧㥫猐暮嗁垗莽ᚥ㣐皱ݠ蒾䚩奰䋛鑎椢ᔓ㯹漪颀戒综⫬鲲ᒳ瀝肠铅抚Ꮘᖎ岷㧳㰈茮诔㩓爪歅桢槳㰄纠飅忴湯两ᯗᔁ怩焼諅彴䋙咅桧㥫猐暮喇㱐䋙咅起冋灄碲⠊㙐⩋詭鶦榋瀽祆讌㙺䋞䩌㴦䝃䏕躠跉怚Ꮘᖎ岷㧳㰈茮诔㩓烩诤⋆⥳㟱炲⠊㙐⩋詬㵆潣㯹潀闉嶚䌂橤⏖凳翵誼雏怚⠉豎淖爃矵誮劀垗罾偬㵧䅫漙筆闎㩽湻ⴍ糷䠑ݼ鄺袇㙾炫ᖎ䲗⨫䰉炰䵮㷴㺛狭沷㧙搱锲體夙➊䭡䛢Ⴃ珵譌诒㵶䂜铬終槣搩躸䚥徙▯两═睡ݠ朲貀㩲苼殄␆槳搼未飒ᛐ▨ᖌ嵖駻搑炼鋏姴㹏橪䲖⤣諡蔼䚨悚䉎汅鴦ꆻᦑ眾駔䍒䔜㐮䶇酡䩨暠ꏉឞ炢ɿ
(539 chars)
Yeah, that's right although I think 2048 characters would be an edge case here. Perhaps we could have a permalink button that automatically creates a Gist from the code if it was more than 2048 chars.
Alternatively, we could enable this functionality only on links with a Gist ID and not have the content in the URL.
I don't think the content should be in the URL (: Open to loading the settings from URL params.
How would this interact with loading & saving the settings from local storage?
I wouldn't want my settings to be reset, just because I clicked a link with pre-configured settings.
On the other hand I might want to persist the shared settings. 🤔
Most helpful comment
I don't think the content should be in the URL (: Open to loading the settings from URL params.