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

[UwU] Unicorn Utterances Redesign #497

Merged
merged 992 commits into from Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
992 commits
Select commit Hold shift + click to select a range
716ea01
fix hint box-sizing & use 100% width when containing a full-width ele…
fennifith Sep 19, 2023
d3d3767
[UwU] Fix table of contents links (#702)
fennifith Sep 19, 2023
98d02a5
prevent buttons from being affected by flex-shrink in the nav header …
fennifith Sep 19, 2023
8506877
[UwU] Fix hint width & box-sizing styles (#704)
fennifith Sep 19, 2023
7ced4fa
[UwU] Fix non-circular nav buttons in tablet mode (#705)
fennifith Sep 19, 2023
bd2606c
fix: word count made more consistent with `wc` usage, etc
crutchcorn Sep 19, 2023
2b17074
fix: add word count delimiter
crutchcorn Sep 19, 2023
141063e
[UwU] Fix word count (#707)
crutchcorn Sep 19, 2023
3ece383
Merge branch 'main' into uwu
crutchcorn Sep 19, 2023
eedccf3
update inline code to match #710
fennifith Sep 21, 2023
405b522
use :focus-visible instead of :focus-within on pagination buttons
fennifith Sep 22, 2023
189258d
[UwU] Update inline code styling (#712)
fennifith Sep 22, 2023
7442bb1
[UwU] Fix pagination focus styling (#713)
fennifith Sep 22, 2023
f5be9fa
apply tab content margin to all child elements by default - fix #706
fennifith Sep 22, 2023
24dc69b
[UwU] Fix tab inner margin not applying to certain elements (#714)
fennifith Sep 23, 2023
7e0bf12
fix: add main landmark to home, add ids and asides to blog pages
crutchcorn Sep 25, 2023
f4290ac
[UwU] Landmark A11Y fixes (#719)
crutchcorn Sep 25, 2023
5f9a6bf
fix: locales should now propegate properly
crutchcorn Sep 25, 2023
1d08443
chore: remove lang from locale component
crutchcorn Sep 25, 2023
419b66e
fix: sitemap generates locales properly
crutchcorn Sep 25, 2023
9a3afa5
fix: improve landmarks per @evelynhathaway and @colabottles guidance
crutchcorn Sep 25, 2023
da3107e
fix: aria-hide icon buttons
crutchcorn Sep 25, 2023
249044b
fix: add accessible name for post tag list
crutchcorn Sep 25, 2023
729c5d4
chore: apply review fixes from @fennifith
crutchcorn Sep 25, 2023
484558e
fix: apply OG fixer to locale
crutchcorn Sep 25, 2023
38ca071
[UwU] More A11Y Fixes (#723)
crutchcorn Sep 25, 2023
27ded97
[UwU] Locale fixes (#722)
crutchcorn Sep 25, 2023
7a60028
fix: ffg tabs now work as intended
crutchcorn Sep 25, 2023
bd1274d
[UwU] Fix FFG tabs (#725)
crutchcorn Sep 25, 2023
c15f826
prevent test post indexing on rss/index pages
fennifith Sep 22, 2023
c91d6d8
fix tsc error; make noindex optional
fennifith Sep 22, 2023
b291c9e
move example post & add noindex prop
fennifith Sep 22, 2023
308eda7
add robots meta tag to exclude noindex posts from search indexing
fennifith Sep 23, 2023
bd0aba6
fix frontmatter indentation
fennifith Sep 23, 2023
1cc9574
change comment to not affect html output
fennifith Sep 23, 2023
6e7b4e7
did filter posts from the sitemap when noindex is true
fennifith Sep 26, 2023
c46de0b
[UwU] Add noindex frontmatter property for test posts (#715)
fennifith Sep 26, 2023
4d75248
fix #724 - adjust post card metadata alignment/wrapping to match post…
fennifith Sep 26, 2023
c5d12af
add redesigned translations header element
fennifith Sep 26, 2023
a8fe95d
use i18n translation for translations box title
fennifith Sep 26, 2023
2b2d935
[UwU] Fix post metadata wrapping behavior (#726)
fennifith Sep 27, 2023
1f7dfb4
fix text style class typo
fennifith Sep 27, 2023
6f852c9
fix #724 - adjust post card metadata alignment/wrapping to match post…
fennifith Sep 26, 2023
897856a
consolidate about page info using mdx
fennifith Sep 21, 2023
ac0e552
add heading ids
fennifith Sep 21, 2023
4f12408
add license component to about page
fennifith Sep 21, 2023
7fac3d0
add banner & updated translation header design
fennifith Sep 22, 2023
89b9356
lazy-load images & prevent some CLS issues
fennifith Sep 22, 2023
eef2620
fix sponsor image sizing
fennifith Sep 22, 2023
20a77b9
fix getTranslatedPage locales sorting
fennifith Sep 27, 2023
5d0baab
fix about page spacing/width breakpoints
fennifith Sep 27, 2023
579577b
display scaled profile images in banner svg
fennifith Sep 27, 2023
c2c3127
fix tsc error
fennifith Sep 27, 2023
cab63ce
fix translations link text style to use bold font
fennifith Sep 27, 2023
6f13e7c
add 33% gradient midpoint, prevent unicorn data from being mutated by…
fennifith Sep 27, 2023
b0d44c6
replace some inline role/sticker svgs with separate files
fennifith Sep 27, 2023
131085f
[UwU] Redesigned translations component (#727)
fennifith Sep 27, 2023
fbcbeb4
remove unused i18n value
fennifith Sep 27, 2023
e0eb465
update theme-color meta tag value
fennifith Sep 27, 2023
bbfc2d0
add license modal for additional attribution text (WIP)
fennifith Sep 28, 2023
6116dec
fix styling issues, allow dismissing by clicking outside the dialog
fennifith Sep 28, 2023
bfba95c
improve license focus styling
fennifith Sep 28, 2023
f39ba7f
fix modal content text color on dark theme
fennifith Sep 28, 2023
3ad39c6
add hover click behavior & container styling
fennifith Sep 28, 2023
4bc7863
begin adding tag image licenses/attribution
fennifith Sep 28, 2023
97eb7dd
hardcode theme-color values, apply in blocking script to prevent load…
fennifith Sep 28, 2023
b0a5d21
[UwU] Update theme-color meta tag value (#730)
fennifith Sep 28, 2023
eaf5cf7
fix dialog scrolling / code block overflow
fennifith Sep 28, 2023
849799c
set scrollbar track backgrounds to transparent
fennifith Sep 29, 2023
8ad5305
change license modal layout to match the cool figma design
fennifith Sep 29, 2023
2304a48
fix C# attribution
fennifith Sep 29, 2023
68a6dab
add contact email for licensing/copyright
fennifith Sep 29, 2023
0cbda6e
replace get-stickers script usage with tags json
fennifith Sep 29, 2023
a38e23a
fix sponsor image sizing/margins
fennifith Sep 29, 2023
1339ee3
fix text colors not adapting to theme & various tsc issues
fennifith Sep 30, 2023
d1ea967
add remaining logo licenses/attributions
fennifith Sep 30, 2023
9a675c0
fix various tags & add warning logs when a tag is not defined
fennifith Sep 30, 2023
d81e71b
remove github copilot tag image
fennifith Sep 30, 2023
9afde1c
[UwU] Set scrollbar track background to transparent (#734)
fennifith Sep 30, 2023
b2d612f
fix #735 - clearer toggle dark mode button label
fennifith Oct 1, 2023
b07eac8
fix #737 - add <li> elements inside related posts list
fennifith Oct 1, 2023
018594c
fix #740 - add the same "Post tags" label to the search section tag list
fennifith Oct 1, 2023
0566928
fix #742 - focus on filter button when the clear button is removed af…
fennifith Oct 1, 2023
8f97997
fix #743 - describe filter post counts with an aria-label
fennifith Oct 1, 2023
4611345
fix #744 - use aria-live="polite" instead of assertive for search status
fennifith Oct 1, 2023
ab5c2f8
fix tsc errors on ref value
fennifith Oct 1, 2023
e5a76b4
fix #739 - use bold + border to display code highlights in place of d…
fennifith Oct 1, 2023
4d00ec3
fix #738 - make twoslash code blocks tabbable, remove if they can't b…
fennifith Oct 1, 2023
e3f849e
remove a duplicate semicolon typo
fennifith Oct 1, 2023
f89ae44
fix #736 - implement button outlines to correctly add the outline-off…
fennifith Oct 1, 2023
25e74c2
increase negative margin on search sidebar to avoid clipping new focu…
fennifith Oct 1, 2023
6688d7d
fix twoslash rehype-transform checking for .class when it should be l…
fennifith Oct 2, 2023
253fcb8
increase dashed border size around code highlights
fennifith Oct 2, 2023
2afcf39
[UwU] Various accessibility fixes (#745)
fennifith Oct 2, 2023
dcecc26
[UwU] Fix code block contrast & tabindex issues (#746)
fennifith Oct 2, 2023
40cef65
[UwU] Fix button outline styling to match spec (#747)
fennifith Oct 2, 2023
6f5f4eb
fix #741 - remove any useId-based props inside select popover/portal
fennifith Oct 2, 2023
7f9d8af
[UwU] Fix invalid <Select> popover IDs (#748)
crutchcorn Oct 2, 2023
2c1099d
Merge branch 'main' into uwu
crutchcorn Oct 2, 2023
59b360b
consolidate about mdx components, implement list/label a11y fixes
fennifith Oct 2, 2023
b3980d9
add about banner-svg alt text
fennifith Oct 2, 2023
485a4d8
set aria-hidden on decorative icons in all markdown components
fennifith Oct 2, 2023
1953554
fix translations component mentioned in #711
fennifith Oct 2, 2023
41e903d
fix #749 - set aria-hidden on post card icons
fennifith Oct 2, 2023
32f6746
fix #750 - add collection/post author list labels
fennifith Oct 2, 2023
beebc37
fix #751 - hide image in search input box
fennifith Oct 2, 2023
8f4b4e3
fix #755 - mark expanded post card image as decorational
fennifith Oct 2, 2023
ee626e5
fix #757 - set aria-hidden on icons in post header
fennifith Oct 2, 2023
c62820c
fix #756 - improve relative pagination button labels
fennifith Oct 2, 2023
81d7148
fix #758 - mark profile section role images as decorational
fennifith Oct 2, 2023
662862b
fix #759 - implement author info a11y improvements
fennifith Oct 2, 2023
c904877
fix #760 - implement achievement list a11y improvements
fennifith Oct 2, 2023
343b116
fix #761 - implement collection page a11y improvements
fennifith Oct 2, 2023
69671f6
fix #754 - label buttons + input inside pagination popover
fennifith Oct 2, 2023
f151f0d
[UwU] Various accessibility fixes No. 2 (#764)
fennifith Oct 2, 2023
17a87ff
[UwU] About page redesign (#711)
crutchcorn Oct 2, 2023
dce8ca1
initial github graphql data + achievements functionality
fennifith Oct 2, 2023
5388650
define more achievements, fix some wording
fennifith Oct 2, 2023
fde6aca
fix achievement / contributor page styling
fennifith Oct 3, 2023
a9c72a9
fix: improve accessibility reading on search page
crutchcorn Oct 3, 2023
a0b72c5
fix: improve sidebar accessibility reading
crutchcorn Oct 3, 2023
921a1b9
[UwU] Improve sidebar accessibility reading (#770)
crutchcorn Oct 3, 2023
9791661
fix: make colors more contrasted
crutchcorn Oct 3, 2023
b6aa5e7
fix: shiki should now work for about page embeds
crutchcorn Oct 3, 2023
768c27c
reimplement achievements as a generator function
fennifith Oct 3, 2023
f1b1c72
add partner achievement, revert roles enum change
fennifith Oct 3, 2023
46c2b3c
[UwU] Search live announcement fixes (#769)
crutchcorn Oct 3, 2023
f6c4bc0
[UwU] Make colors more contrasted (#771)
crutchcorn Oct 3, 2023
4e6745b
[UwU] Fix about shiki (#772)
crutchcorn Oct 3, 2023
64d54a4
fix #767 - add select popup border, remove unused "selectDropdown" class
fennifith Oct 3, 2023
3a9a5a7
[UwU] Fix select border (#773)
fennifith Oct 3, 2023
9a5d774
[UwU] Additional achievement functionality (#768)
fennifith Oct 3, 2023
0e705d4
remove syntax highlighting from social image build script for perf
fennifith Oct 3, 2023
d50e43d
begin implementing redesigned social preview layout
fennifith Oct 3, 2023
a3fd273
optimize author images in social preview generation
fennifith Oct 3, 2023
777a497
use tags.json to get banner image tags
fennifith Oct 3, 2023
53e9856
fix banner image text-shadow styling
fennifith Oct 3, 2023
49150bb
add emoji font to prevent tofu chars in post titles
fennifith Oct 3, 2023
34977c0
add emoji tags to generated banner images
fennifith Oct 3, 2023
569a13e
use "Noto Emoji" font for better contrast in banner images
fennifith Oct 3, 2023
15fb975
[UwU] Social preview image redesign (#774)
fennifith Oct 3, 2023
b1b44ac
fix: mark current translation as `aria-current="page"`
crutchcorn Oct 3, 2023
9bb97e4
[UwU] Minor translation header a11y improvement (#777)
crutchcorn Oct 3, 2023
1b4f051
fix: improve landmark usage on various pages
crutchcorn Oct 3, 2023
658eb58
Update src/views/about/banner-svg.astro
crutchcorn Oct 3, 2023
f243ab8
[UwU] Landmark improvements (#779)
crutchcorn Oct 3, 2023
8f3e3e9
replace heading link remark plugin with onload script/template
fennifith Oct 5, 2023
97fd9ff
prevent "copy link" popups on non-markdown headings (for example, the…
fennifith Oct 5, 2023
57ad5e4
add transition for heading popup border & background color
fennifith Oct 6, 2023
251774b
move dialog behavior (with backdrop onClick - #732) to a separate com…
fennifith Oct 6, 2023
a4311e1
fix #783 - change dialog backdrop colors
fennifith Oct 6, 2023
4185fdd
fix #732 - set overscroll contain on search page dialog contents
fennifith Oct 6, 2023
ac88398
fix jest not resolving "src/..." imports
fennifith Oct 6, 2023
b62f6b2
fix #780 - remove duplicate links from homepage header
fennifith Oct 6, 2023
396fb5e
misc - add typing for translation keys
fennifith Oct 6, 2023
b5506bb
reset search filter dialog state to match parent when re-opening
fennifith Oct 6, 2023
a146d49
implement focus outlines for header links
fennifith Oct 6, 2023
5454478
add heading spans for popup styling on about page
fennifith Oct 6, 2023
bd4d001
add post-body link outline styling
fennifith Oct 6, 2023
ad9a3d4
[UwU] Remove duplicate homepage links (#787)
fennifith Oct 6, 2023
d4200ee
fix heading underline styles not applying
fennifith Oct 6, 2023
b5db671
implement link outline width/offset with rem
fennifith Oct 6, 2023
7858532
[UwU] Search page dialog consistency (#786)
crutchcorn Oct 8, 2023
20eabbf
Remove bigBlock manual blockquotes in Ed's article
crutchcorn Oct 8, 2023
a6b721a
feat: include a number of changes
crutchcorn Oct 5, 2023
cb6552b
chore: update the search bar to be sticky
crutchcorn Oct 8, 2023
53c055d
chore: add select with label text
crutchcorn Oct 8, 2023
7f9e41c
fix: add landmark regions to the search page
crutchcorn Oct 8, 2023
0bbfb0d
chore: remove manual binding of onPress events
crutchcorn Oct 8, 2023
b545007
chore: fix tab ordering on mobile
crutchcorn Oct 8, 2023
6af3f80
chore: remove top padding on result count
crutchcorn Oct 8, 2023
54d2ea2
chore: fix header overlap on focus states
crutchcorn Oct 8, 2023
c5a4c66
fix: remove placeholder from search inputs
crutchcorn Oct 8, 2023
10ed7fd
fix: dark mode toggle and state overlap
crutchcorn Oct 8, 2023
c811422
implement aria-live for "Link copied!" message
fennifith Oct 8, 2023
4c0f6f8
[UwU] Remove search placeholder (#791)
crutchcorn Oct 8, 2023
56bfe5f
[UwU] Implement redesigned heading permalink popups (#785)
fennifith Oct 8, 2023
33178a9
[UwU] Add post-body <a> focus indicator styling (#788)
fennifith Oct 8, 2023
6332fb1
chore: remove inner width of search bar
crutchcorn Oct 8, 2023
b1784dc
Revert "chore: remove manual binding of onPress events"
crutchcorn Oct 8, 2023
677e67b
fix: buttons should now work on mobile
crutchcorn Oct 8, 2023
3427f43
chore: remove additional failing code
crutchcorn Oct 8, 2023
7ad94fd
fix: mobile cancel and filter buttons now work
crutchcorn Oct 9, 2023
f6f4dff
Merge branch 'uwu' into uwu-search-improvements
crutchcorn Oct 9, 2023
3c81c0f
fix: image stretching, code block, and more
crutchcorn Oct 9, 2023
6150624
Update content/blog/non-decimal-numbers-in-tech/index.md
crutchcorn Oct 9, 2023
147da9d
fix: style fixes
crutchcorn Oct 9, 2023
aec9154
fix: relevance sort now works as-intended
crutchcorn Oct 9, 2023
e44a863
[UwU] Search improvements (#790)
crutchcorn Oct 9, 2023
ead146e
[UwU] Minor post fixes (#794)
crutchcorn Oct 9, 2023
025dfb4
chore: replace social banner and about us button language
crutchcorn Oct 10, 2023
f52b788
[UwU] Replace social banner and about us button language (#796)
crutchcorn Oct 10, 2023
2788abb
add additional social link types
fennifith Oct 12, 2023
8de74d3
fix a missing link type in CONTRIBUTING.md
fennifith Oct 12, 2023
ad014c6
fix #797 - achievement button span being overwritten when innerText i…
fennifith Oct 12, 2023
bbd306b
[UwU] Additional social link types (#798)
fennifith Oct 12, 2023
647fa0c
[UwU] Fix replaced achievement button span (#799)
fennifith Oct 12, 2023
63483f1
fix #807 - pagination popup button hydrating in the incorrect order
fennifith Oct 14, 2023
99a106a
fix #800 - use scroll-padding-top to prevent targeted elements from b…
fennifith Oct 14, 2023
5ce10d6
fix #802 - link "view all" buttons to their headings with aria-labell…
fennifith Oct 14, 2023
9301d0a
fix #803 - change dark mode toggle label
fennifith Oct 14, 2023
e5fd0a8
fix #804 - lower homepage content to be under a single h1
fennifith Oct 14, 2023
1ed46ec
fix #805 - reverse the order of dropdown aria-labelledby ids
fennifith Oct 14, 2023
e9bf46d
fix #808 - move role=search to the search <form> element instead of <…
fennifith Oct 14, 2023
7fe5d0a
fix #810 - add correct margins on homepage banner text
fennifith Oct 14, 2023
5fd4087
fix heading order on various pages
fennifith Oct 14, 2023
c2633ef
add a more descriptive aria-label and aria-pressed value to the achie…
fennifith Oct 14, 2023
45e6abe
[UwU] Fix pagination popup hydration order (#812)
fennifith Oct 14, 2023
7bd628a
[UwU] Various site fixes (#813)
fennifith Oct 14, 2023
7db3894
add focus state styling for the pagination popup dialog
fennifith Oct 16, 2023
e141679
[UwU] Pagination popup focus styling (#816)
fennifith Oct 16, 2023
41d6320
fix #814 - restructure blog post layout to fix heading order
fennifith Oct 16, 2023
e4e602c
move <main> element to wrap all page content
fennifith Oct 17, 2023
b423aa7
Merge branch 'main' into uwu
crutchcorn Oct 17, 2023
33133fb
move post content to h3, restructure around "Post contents" heading
fennifith Oct 18, 2023
b7d072c
[UwU] Heading order in blog post layout (#820)
fennifith Oct 18, 2023
a5bac3e
feat: adding word count and icon to post page
crutchcorn Oct 19, 2023
5a65ed7
fix: header overlap
crutchcorn Oct 19, 2023
dc1862b
chore: update icon svg colors
crutchcorn Oct 19, 2023
e7893c6
chore: fix tweet embed styling
crutchcorn Oct 19, 2023
082eda3
[UwU] Add post word count (#824)
crutchcorn Oct 19, 2023
52937bd
fix: article highlights are now corrected
crutchcorn Oct 19, 2023
422b27f
[UwU] Fix tweet embed styling (#825)
crutchcorn Oct 19, 2023
9193da3
[UwU] Astro article highlights corrections (#826)
crutchcorn Oct 19, 2023
247194b
chore: remove manual image spacing and add alt text
crutchcorn Oct 19, 2023
fae5e82
chore: remove originalLink post
crutchcorn Oct 19, 2023
bcb1c0c
feat: round pictures and videos
crutchcorn Oct 19, 2023
d1b26ec
chore: fix about page
crutchcorn Oct 19, 2023
d7fcc8a
fix: hide TOC when not enabled for the page
crutchcorn Oct 19, 2023
cbd4dac
chore: move to token
crutchcorn Oct 19, 2023
3cd2029
Update content/blog/css-fundamentals/index.md
crutchcorn Oct 19, 2023
8580914
[UwU] Round media corners (#831)
crutchcorn Oct 19, 2023
141f9c7
[UwU] Conditionally hide TOC (#832)
crutchcorn Oct 19, 2023
b10a40c
[UwU] CSS article fixes (#828)
crutchcorn Oct 19, 2023
4ae8450
fix series heading acting as a "copy link" target
fennifith Oct 19, 2023
a4467b5
move post series ToC and translation list to post header instead of p…
fennifith Oct 19, 2023
3b3e04f
fix word count toLocaleString
fennifith Oct 19, 2023
666c3c4
revert post layout grid changes (broken layout)
fennifith Oct 19, 2023
94eae04
fix post content centering when the page sidebar is hidden
fennifith Oct 19, 2023
733fc0e
fix grid-template-columns breakpoint specificity
fennifith Oct 19, 2023
9039d76
[UwU] Fix series heading behaving as a "copy link" target (#833)
fennifith Oct 19, 2023
ef47527
fix twitch embedder to transform clip URLs
fennifith Oct 19, 2023
b76029a
fix typo in angular error behavior description
fennifith Oct 19, 2023
e3423a3
fix #822 - add caret-color to search input styles
fennifith Oct 19, 2023
76f66a4
Fix typo in angular error behavior post description (#836)
crutchcorn Oct 19, 2023
9a2cb77
fix: show "Twitch Embed" instead of "Twitch Error"
crutchcorn Oct 19, 2023
7f397aa
[UwU] Fix search caret color (#837)
crutchcorn Oct 19, 2023
3c6ba60
[UwU] Fix twitch clip player embedder (#834)
fennifith Oct 19, 2023
6fab84b
fix tab headings being included in the ToC heading map
fennifith Oct 20, 2023
cc36724
[UwU] Fix ToC tab headings (#838)
crutchcorn Oct 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .eslintrc.cjs
@@ -1,6 +1,7 @@
const tsRules = {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-unused-vars": "off",
};

module.exports = {
Expand All @@ -19,6 +20,7 @@ module.exports = {
rules: {
"no-unused-vars": "off",
"no-mixed-spaces-and-tabs": "off",
"no-useless-escape": "off",
},
overrides: [
{
Expand All @@ -33,7 +35,7 @@ module.exports = {
},
},
{
files: ["*.ts"],
files: ["*.ts", "*.tsx"],
parser: "@typescript-eslint/parser",
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -18,5 +18,8 @@ pnpm-debug.log*
# macOS-specific files
.DS_Store
.idea/
.eslintcache
.eslintcache
.vercel
.puppeteer

.vercel
1 change: 1 addition & 0 deletions .prettierrc
@@ -1,5 +1,6 @@
{
"useTabs": true,
"plugins": ["prettier-plugin-astro"],
"overrides": [
{
"files": ["**/*.astro"],
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -41,9 +41,9 @@ Here's an example of what your entry might look like:
// "description" is a short bio that will be shown on your profile page
"description": "Haskell programmer, fanfiction author, and an omniscient unicorn.",

// Social usernames can include "twitter", "github", "linkedIn",
// "twitch", and "dribbble", as well as a "website" that can be
// anything you want!
// Social usernames can include "twitter", "github", "gitlab",
// "linkedIn", "twitch", "dribbble", "mastodon", "threads", "youtube",
// and "cohost", as well as a "website" that can be anything you want!
"socials": {
"twitter": "UnicornUttrncs",
"github": "unicorn-utterances",
Expand Down
1 change: 0 additions & 1 deletion README.es.md
Expand Up @@ -18,7 +18,6 @@ Este repository actúa como la ubicación del código fuente para el [blog de Un

<a href="https://www.thepolyglotdeveloper.com/" target="_blank" rel="noopener noreferrer sponsored"><img alt="The Polyglot Developer" src="https://unicorn-utterances.com/sponsors/the-polyglot-developer.svg" width="300"/></a>
<a href="https://oceanbit.dev/" target="_blank" rel="noopener noreferrer sponsored"><img alt="OceanBit" src="https://unicorn-utterances.com/sponsors/oceanbit.svg" width="300"/></a>
<a href="https://coderpad.io/" target="_blank" rel="noopener noreferrer sponsored"><img alt="CoderPad" src="https://unicorn-utterances.com/sponsors/coderpad.svg" width="300"/></a>

[Reconocemos todos los patrocinios que compartimos abiertamente en GitHub](https://github.com/unicorn-utterances/unicorn-utterances/issues?q=is%3Aissue+label%3Adisclosure+is%3Aclosed)

Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -18,7 +18,6 @@ This repository acts as the source code location for [the Unicorn Utterances blo

<a href="https://www.thepolyglotdeveloper.com/" target="_blank" rel="noopener noreferrer sponsored"><img alt="The Polyglot Developer" src="https://unicorn-utterances.com/sponsors/the-polyglot-developer.svg" width="300"/></a>
<a href="https://oceanbit.dev/" target="_blank" rel="noopener noreferrer sponsored"><img alt="OceanBit" src="https://unicorn-utterances.com/sponsors/oceanbit.svg" width="300"/></a>
<a href="https://coderpad.io/" target="_blank" rel="noopener noreferrer sponsored"><img alt="CoderPad" src="https://unicorn-utterances.com/sponsors/coderpad.svg" width="300"/></a>

[We disclose every sponsorship we share openly on GitHub](https://github.com/unicorn-utterances/unicorn-utterances/issues?q=is%3Aissue+label%3Adisclosure+is%3Aclosed)

Expand Down
33 changes: 33 additions & 0 deletions __mocks__/data/mock-collection.ts
@@ -0,0 +1,33 @@
import { MockUnicorn, MockUnicornTwo } from "./mock-unicorn";
import { MockLicense } from "./mock-license";
import { ExtendedCollectionInfo, ExtendedPostInfo } from "types/index";
import { MockPost } from "./mock-post";

export const MockCollection: ExtendedCollectionInfo = {
authors: [MockUnicorn.id],
authorsMeta: [MockUnicorn],
Content: () => null,
tags: [],
contentMeta: "",
licenseMeta: null,
publishedMeta: "October 10, 2010",
collectionSlug: null,
excerpt: "This would be an auto generated excerpt of the post in particular",
wordCount: 10000,
coverImgMeta: {
absoluteFSPath: "",
height: 0,
relativePath: "",
relativeServerPath: "",
width: 0,
},
locales: ["en"],
locale: "en",
posts: [MockPost],
slug: "this-collection-name-here",
title: "Collection title",
description: "This is a short description dunno why this would be this short",
coverImg: "img.png",
published: "10-10-2010T00:00:00.000Z",
buttons: [],
};
30 changes: 13 additions & 17 deletions __mocks__/data/mock-post.ts
@@ -1,8 +1,8 @@
import { MockUnicorn, MockUnicornTwo } from "./mock-unicorn";
import { MockLicense } from "./mock-license";
import { PostInfo } from "types/PostInfo";
import { ExtendedPostInfo } from "types/index";

export const MockPost: PostInfo = {
export const MockPost: ExtendedPostInfo = {
excerpt: "This would be an auto generated excerpt of the post in particular",
title: "Post title",
published: "10-10-2010T00:00:00.000Z",
Expand All @@ -14,19 +14,18 @@ export const MockPost: PostInfo = {
license: MockLicense.id,
licenseMeta: MockLicense,
locale: "en",
locales: ["en", "es"],
slug: "this-post-name-here",
headingsWithId: [],
wordCount: 10000,
contentMeta: "",
translations: {
en: "English",
},
Content: {} as never,
suggestedArticles: [] as never,
attached: [],
socialImg: "img.png",
};

export const MockMultiAuthorPost: PostInfo = {
export const MockMultiAuthorPost: ExtendedPostInfo = {
excerpt:
"This would be a second auto generated excerpt of the post in particular",
title: "Another post title",
Expand All @@ -40,19 +39,18 @@ export const MockMultiAuthorPost: PostInfo = {
license: MockLicense.id,
licenseMeta: MockLicense,
locale: "en",
locales: ["en", "es"],
slug: "this-other-post-name-here",
headingsWithId: [],
wordCount: 100000,
contentMeta: "",
translations: {
en: "English",
},
Content: {} as never,
suggestedArticles: [] as never,
attached: [],
socialImg: "img.png",
};

export const MockMuliLanguagePost: PostInfo = {
export const MockMuliLanguagePost: ExtendedPostInfo = {
excerpt:
"This would be a second auto generated excerpt of the post in particular",
title: "Another post title",
Expand All @@ -66,19 +64,18 @@ export const MockMuliLanguagePost: PostInfo = {
license: MockLicense.id,
licenseMeta: MockLicense,
locale: "en",
locales: ["en", "es"],
slug: "this-other-post-name-here",
headingsWithId: [],
wordCount: 100000,
contentMeta: "",
translations: {
es: "Español",
},
Content: {} as never,
suggestedArticles: [] as never,
attached: [],
socialImg: "img.png",
};

export const MockCanonicalPost: PostInfo = {
export const MockCanonicalPost: ExtendedPostInfo = {
excerpt:
"This would be a second auto generated excerpt of the post in particular",
title: "Another post title",
Expand All @@ -93,14 +90,13 @@ export const MockCanonicalPost: PostInfo = {
license: MockLicense.id,
licenseMeta: MockLicense,
locale: "en",
locales: ["en", "es"],
slug: "this-other-post-name-here",
headingsWithId: [],
wordCount: 100000,
contentMeta: "",
translations: {
en: "English",
},
Content: {} as never,
suggestedArticles: [] as never,
attached: [],
socialImg: "img.png",
};
2 changes: 2 additions & 0 deletions __mocks__/data/mock-unicorn.ts
Expand Up @@ -15,6 +15,7 @@ export const MockUnicorn: UnicornInfo = {
github: "ghusrname",
website: "example.com",
},
achievements: [],
pronouns: "they/them",
profileImg:
"https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
Expand Down Expand Up @@ -44,6 +45,7 @@ export const MockUnicornTwo: UnicornInfo = {
github: "ghusrname2",
website: "example.com/2",
},
achievements: [],
pronouns: "they/them",
profileImg:
"https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
Expand Down
6 changes: 6 additions & 0 deletions __mocks__/imports/svg-comp-mock.ts
@@ -0,0 +1,6 @@
export default {
src: "test.svg",
width: 24,
height: 24,
format: "svg",
};
1 change: 1 addition & 0 deletions __mocks__/imports/svg-raw-mock.ts
@@ -0,0 +1 @@
export default "<svg />";
41 changes: 40 additions & 1 deletion __mocks__/jest.setup.js
Expand Up @@ -3,7 +3,28 @@

// Used for __tests__/testing-library.js
// Learn more: https://github.com/testing-library/jest-dom
require("@testing-library/jest-dom/extend-expect");
require("whatwg-fetch");
require("@testing-library/jest-dom/jest-globals");
import "jest-location-mock";

global.plausible = null;

let history = [];

window.history.pushState = (data, unused, url) => {
window.location.assign(url);
history.push(url);
};

window.history.replaceState = (data, unused, url) => {
window.location.assign(url);
history[history.length - 1] = url;
};

window.history.back = () => {
history.pop();
window.location.assign(history[history.length - 1]);
};

global.IntersectionObserver = class IntersectionObserver {
constructor() {}
Expand All @@ -20,3 +41,21 @@ global.IntersectionObserver = class IntersectionObserver {
return null;
}
};

global.React = require("preact");

// https://github.com/jsdom/jsdom/issues/3294
// eslint-disable-next-line no-undef
HTMLDialogElement.prototype.show = jest.fn(function mock() {
this.open = true;
});

// eslint-disable-next-line no-undef
HTMLDialogElement.prototype.showModal = jest.fn(function mock() {
this.open = true;
});

// eslint-disable-next-line no-undef
HTMLDialogElement.prototype.close = jest.fn(function mock() {
this.open = false;
});
55 changes: 44 additions & 11 deletions api/search.ts
Expand Up @@ -2,34 +2,67 @@ import type { VercelRequest, VercelResponse } from "@vercel/node";
import Fuse from "fuse.js";
import { createRequire } from "node:module";

import type { PostInfo } from "types/PostInfo";
import type { ExtendedPostInfo } from "types/index";

const require = createRequire(import.meta.url);
const searchIndex = require("./searchIndex.json");
const index = Fuse.parseIndex(searchIndex.index);
const postIndex = Fuse.parseIndex(searchIndex.postIndex);
const collectionIndex = Fuse.parseIndex(searchIndex.collectionIndex);

const posts = searchIndex.posts;
const collections = searchIndex.collections;

const fuse = new Fuse<PostInfo>(
const postFuse = new Fuse<ExtendedPostInfo>(
posts,
{
threshold: 0.3,
ignoreLocation: true,
includeScore: true,
ignoreFieldNorm: true,
},
index
postIndex,
);

const collectionFuse = new Fuse(
collections,
{
threshold: 0.3,
ignoreLocation: true,
includeScore: true,
ignoreFieldNorm: true,
},
collectionIndex,
);

export default async (req: VercelRequest, res: VercelResponse) => {
// TODO: `pickdeep` only required fields
const searchStr = req?.query?.query as string;
const authorStr = req?.query?.authorId as string;
if (!searchStr) return [];
if (Array.isArray(searchStr)) return [];
let posts = fuse.search(searchStr).map((item) => item.item);
if (authorStr) {
posts = posts.filter((post) => post.authors.includes(authorStr));
if (!searchStr) {
res.send({
posts: [],
totalPosts: 0,
collections: [],
totalCollections: 0,
});
return;
}
if (searchStr === "*") {
res.send({
posts,
totalPosts: posts.length,
collections,
totalCollections: collections.length,
});
return;
}
res.send({ posts, totalPosts: posts.length });
const searchedPosts = postFuse.search(searchStr).map((item) => item.item);
const searchedCollections = collectionFuse
.search(searchStr)
.map((item) => item.item);
res.send({
posts: searchedPosts,
totalPosts: searchedPosts.length,
collections: searchedCollections,
totalCollections: searchedCollections.length,
});
};